From 8dd9bb49e3fd31bb447966c58052e388e6da9e5c Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 30 Jun 2024 15:05:03 -0400 Subject: [PATCH] Version 0.0.1-dev - Sign Artifact --- .github/workflows/{publish.yml => main.yml} | 41 ++++++++++++++++--- .../workflows/{checks.yml => pr-checks.yml} | 4 +- build.gradle.kts | 30 +++++++++++--- gradle/libs.versions.toml | 2 +- 4 files changed, 62 insertions(+), 15 deletions(-) rename .github/workflows/{publish.yml => main.yml} (73%) rename .github/workflows/{checks.yml => pr-checks.yml} (91%) diff --git a/.github/workflows/publish.yml b/.github/workflows/main.yml similarity index 73% rename from .github/workflows/publish.yml rename to .github/workflows/main.yml index fcadad0..e66df59 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,4 @@ -name: Publish +name: Main Branch on: # Runs on pushes targeting the default branch @@ -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: @@ -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 }} @@ -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: '' diff --git a/.github/workflows/checks.yml b/.github/workflows/pr-checks.yml similarity index 91% rename from .github/workflows/checks.yml rename to .github/workflows/pr-checks.yml index 16d5149..e71ae71 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/pr-checks.yml @@ -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"] diff --git a/build.gradle.kts b/build.gradle.kts index 2735ee2..85ce4b1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,8 @@ 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 { @@ -7,7 +10,9 @@ buildscript { 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 } } @@ -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 } } @@ -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, + ) + ) } } } - } \ No newline at end of file + } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 9db3a2e..dc48d91 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -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"