Skip to content

Commit

Permalink
Version 0.0.1-dev - Sign Artifact
Browse files Browse the repository at this point in the history
  • Loading branch information
handstandsam committed Jun 30, 2024
1 parent 74ea49b commit 8dd9bb4
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 15 deletions.
41 changes: 35 additions & 6 deletions .github/workflows/publish.yml → .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish
name: Main Branch

on:
# Runs on pushes targeting the default branch
Expand All @@ -14,7 +14,7 @@ permissions:
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "publish"
group: "main"
cancel-in-progress: false

jobs:
Expand All @@ -31,17 +31,18 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '21'
java-version: '17'
check-latest: true

- name: Gradle Wrapper Validation
uses: gradle/actions/wrapper-validation@v3


- name: Test on Ubuntu
run: ./gradlew assemble check --no-build-cache --no-daemon --stacktrace

# Deploy to Github Pages
deploy:
github-pages:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
Expand Down Expand Up @@ -93,24 +94,52 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '21'
java-version: '17'
check-latest: true

- name: Gradle Wrapper Validation
uses: gradle/actions/wrapper-validation@v3

- name: Retrieve Version from gradle.properties
run: echo "VERSION_NAME=$(cat gradle.properties | grep "^version=" | awk -F'=' '{print $2}')" >> $GITHUB_ENV

- name: Publish Snapshot
run: ./gradlew :invert-models:publish :invert-gradle-plugin:publish --no-configuration-cache --stacktrace
if: success() && endsWith(env.VERSION_NAME, '-SNAPSHOT')
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}


publish-release:
needs:
- test-ubuntu
runs-on: ubuntu-latest
if: github.repository == 'square/invert' && github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
timeout-minutes: 25

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '17'
check-latest: true

- name: Gradle Wrapper Validation
uses: gradle/actions/wrapper-validation@v3

- name: Retrieve Version from gradle.properties
run: echo "VERSION_NAME=$(cat gradle.properties | grep "^version=" | awk -F'=' '{print $2}')" >> $GITHUB_ENV

- name: Publish release (main only)
run: ./gradlew :invert-models:closeAndReleaseRepository :invert-gradle-plugin:closeAndReleaseRepository --no-configuration-cache --stacktrace
run: ./gradlew :invert-models:publishAndReleaseToMavenCentral :invert-gradle-plugin:publishAndReleaseToMavenCentral --no-configuration-cache --stacktrace
if: success() && !endsWith(env.VERSION_NAME, '-SNAPSHOT')
env:
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.SONATYPE_NEXUS_USERNAME }}
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.SONATYPE_NEXUS_PASSWORD }}
ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.ARTIFACT_SIGNING_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ''
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
name: Checks

on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]
# Runs on PRs targeting the default branch
pull_request:
branches: ["main"]

Expand Down
30 changes: 25 additions & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import com.vanniktech.maven.publish.SonatypeHost
import com.vanniktech.maven.publish.KotlinJvm
import com.vanniktech.maven.publish.KotlinMultiplatform
import com.vanniktech.maven.publish.JavadocJar

buildscript {
repositories {
mavenLocal()
mavenCentral()
google()
gradlePluginPortal()
maven { url = uri("https://oss.sonatype.org/service/local/repositories/snapshots/content") } // SNAPSHOT Versions for statik
maven {
url = uri("https://oss.sonatype.org/service/local/repositories/snapshots/content")
} // SNAPSHOT Versions for statik
}
}

Expand All @@ -16,7 +21,9 @@ allprojects {
mavenCentral()
google()
gradlePluginPortal()
maven { url = uri("https://oss.sonatype.org/service/local/repositories/snapshots/content") } // SNAPSHOT Versions for statik
maven {
url = uri("https://oss.sonatype.org/service/local/repositories/snapshots/content")
} // SNAPSHOT Versions for statik
}
}

Expand All @@ -39,11 +46,24 @@ subprojects
it.afterEvaluate {
val hasPublishPlugin = it.plugins.hasPlugin("com.vanniktech.maven.publish.base")
if (hasPublishPlugin) {
val extension = it.extensions.getByType(MavenPublishBaseExtension::class.java)
extension.apply {
it.extensions.getByType(MavenPublishBaseExtension::class.java).apply {
publishToMavenCentral(SonatypeHost.S01, automaticRelease = true)
signAllPublications()
configure(
KotlinJvm(
javadocJar = JavadocJar.None(),
// whether to publish a sources jar
sourcesJar = true,
)
)
configure(
KotlinMultiplatform(
javadocJar = JavadocJar.None(),
// whether to publish a sources jar
sourcesJar = true,
)
)
}
}
}
}
}
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ javax-inject = "1"
kotlin = "2.0.0"
kotlinx-serialization = "1.6.3"
ktor = "2.3.11"
vanniktech-maven-publish = "0.28.0"
vanniktech-maven-publish = "0.29.0"
jetbrains-compose = "1.6.10"
ksp = "1.9.23-1.0.20"
truth = "1.4.2"
Expand Down

0 comments on commit 8dd9bb4

Please sign in to comment.