From 6bcc824a20dfa443a6e2662aa93396fa5e31a54d Mon Sep 17 00:00:00 2001 From: Johann Pardanaud Date: Sat, 21 Dec 2024 16:43:18 +0100 Subject: [PATCH] wip sign + publish --- .github/workflows/deploy-website.yml | 2 +- .github/workflows/release.yml | 98 ++++++++++++------- .github/workflows/test.yml | 2 +- ...kkurate.kmp-library-conventions.gradle.kts | 2 +- ...akkurate.publishing-conventions.gradle.kts | 36 +++---- 5 files changed, 76 insertions(+), 64 deletions(-) diff --git a/.github/workflows/deploy-website.yml b/.github/workflows/deploy-website.yml index ed111055..3fbbd5f3 100644 --- a/.github/workflows/deploy-website.yml +++ b/.github/workflows/deploy-website.yml @@ -1,5 +1,5 @@ name: Deploy documentation and API reference -on: [ push, pull_request ] +#on: [ push, pull_request ] # Gives the workflow permissions to clone the repo and create a page deployment permissions: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 193ef6ad..4af4e661 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,52 +3,76 @@ on: push # workflow_dispatch: # inputs: # version: -# description: 'The version number to use' +# description: 'The version number to use (ex: 1.22.3)' # required: true # type: string +#env: +# RELEASE_VERSION: ${{ inputs.version }} jobs: - create-release-pr: - name: Create a pull request for the release - runs-on: ubuntu-latest - permissions: - contents: write +# create-release-pr: +# name: Create a pull request for the release +# runs-on: ubuntu-latest +# permissions: +# contents: write +# +# steps: +# - name: Install chan CLI +# run: npm install -g @geut/chan +# +# - name: Checkout repository +# uses: actions/checkout@v4 +# +# - name: Write a new release to CHANGELOG.md +# run: chan release $RELEASE_VERSION --release-prefix="" +# +# - name: Update Akkurate's version in build files +# run: | +# echo 'version = "'$RELEASE_VERSION'"' > ./buildSrc/src/main/kotlin/akkurate.version.gradle.kts; +# sed -ri 's|CONFIG_JSON_VERSION *:.*|CONFIG_JSON_VERSION: '$RELEASE_VERSION'|g' ./.github/workflows/deploy-website.yml; +# sed -ri 's||g' ./documentation/v.list; +# sed -ri 's||g' ./documentation/writerside.cfg; +# +## - name: Commit and push +## uses: stefanzweifel/git-auto-commit-action@v5 +## with: +## commit_message: release ${{ inputs.version }} +## branch: release/${{ inputs.version }} +## create_branch: true +## commit_author: Johann Pardanaud +## tagging_message: ${{ inputs.version }} +# +# - name: Create a draft release +# env: +# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} +# run: chan show $RELEASE_VERSION | tail -n +2 | gh release create $RELEASE_VERSION --title "Akkurate $RELEASE_VERSION" --draft --notes-file - + publish: + name: Publish to Maven Central Repository + runs-on: macos-latest steps: - - name: Install chan CLI - run: npm install -g @geut/chan - - name: Checkout repository uses: actions/checkout@v4 - - name: Write a new release to CHANGELOG.md - env: -# RELEASE_VERSION: ${{ inputs.version }} - RELEASE_VERSION: 0.99.0 - run: chan release $RELEASE_VERSION --release-prefix="" + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: zulu + + - name: Validate Gradle wrapper + uses: gradle/actions/wrapper-validation@v3 - - name: Update Akkurate's version in build files - env: -# RELEASE_VERSION: ${{ inputs.version }} - RELEASE_VERSION: 0.99.0 - run: | - echo 'version = "'$RELEASE_VERSION'"' > ./buildSrc/src/main/kotlin/akkurate.version.gradle.kts; - sed -ri 's|CONFIG_JSON_VERSION *:.*|CONFIG_JSON_VERSION: '$RELEASE_VERSION'|g' ./.github/workflows/deploy-website.yml; - sed -ri 's||g' ./documentation/v.list; - sed -ri 's||g' ./documentation/writerside.cfg; + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 -# - name: Commit and push -# uses: stefanzweifel/git-auto-commit-action@v5 -# with: -# commit_message: release ${{ inputs.version }} -# branch: release/${{ inputs.version }} -# create_branch: true -# commit_author: Johann Pardanaud -# tagging_message: ${{ inputs.version }} + - run: ls /Users/runner/hostedtoolcache/Java_Zulu_jdk/17.0.13-11/arm64 - - name: Create a draft release - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# RELEASE_VERSION: ${{ inputs.version }} - RELEASE_VERSION: 0.99.0 - run: chan show $RELEASE_VERSION | tail -n +2 | gh release create $RELEASE_VERSION --title "Akkurate $RELEASE_VERSION" --draft --notes-file - +# - name: Publish to Maven Central Repository +# env: +# ORG_GRADLE_PROJECT_signingKey: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGKEY }} +# ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.ORG_GRADLE_PROJECT_SIGNINGPASSWORD }} +# SONATYPE_URL: ${{ vars.SONATYPE_URL }} +# SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }} +# SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }} +# run: ./gradlew publish diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9e00a095..5836820d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,5 +1,5 @@ name: Run tests -on: [ push, pull_request ] +#on: [ push, pull_request ] jobs: test: diff --git a/buildSrc/src/main/kotlin/akkurate.kmp-library-conventions.gradle.kts b/buildSrc/src/main/kotlin/akkurate.kmp-library-conventions.gradle.kts index 6d4b2821..bcae5f03 100644 --- a/buildSrc/src/main/kotlin/akkurate.kmp-library-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/akkurate.kmp-library-conventions.gradle.kts @@ -7,7 +7,7 @@ plugins { kotlin { explicitApi() - jvmToolchain(8) +// jvmToolchain(8) sourceSets { all { diff --git a/buildSrc/src/main/kotlin/akkurate.publishing-conventions.gradle.kts b/buildSrc/src/main/kotlin/akkurate.publishing-conventions.gradle.kts index be282290..d46227c6 100644 --- a/buildSrc/src/main/kotlin/akkurate.publishing-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/akkurate.publishing-conventions.gradle.kts @@ -4,41 +4,29 @@ plugins { signing } -ext["signing.keyId"] = System.getenv("SIGNING_KEY_ID") -ext["signing.password"] = System.getenv("SIGNING_PASSWORD") -ext["signing.secretKeyRingFile"] = System.getenv("SIGNING_SECRET_KEY_RING_FILE") -ext["sonatypeUsername"] = System.getenv("SONATYPE_USERNAME") -ext["sonatypePassword"] = System.getenv("SONATYPE_PASSWORD") - -fun hasExtra(name: String) = ext[name] != null -fun getExtra(name: String) = ext[name]?.toString() - publishing { // Configure maven central repository repositories { maven { name = "sonatype" - credentials { - username = getExtra("sonatypeUsername") - password = getExtra("sonatypePassword") - } - val isSnapshot = project.version.toString().endsWith("-SNAPSHOT") - if (isSnapshot) { - setUrl("https://s01.oss.sonatype.org/content/repositories/snapshots/") - } else { - setUrl("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/") + System.getenv("SONATYPE_URL")?.let { setUrl(it) } + + credentials { + username = System.getenv("SONATYPE_USERNAME") + password = System.getenv("SONATYPE_PASSWORD") } } } } -// Signing artifacts. Signing.* extra properties values will be used -if (hasExtra("signing.keyId") && - hasExtra("signing.password") && - hasExtra("signing.secretKeyRingFile") -) { - signing { +// Signing artifacts +signing { + val signingKey: String? by project + val signingPassword: String? by project + useInMemoryPgpKeys(signingKey, signingPassword) + + if (signingKey !== null && signingPassword !== null) { sign(publishing.publications) } }