From 62e1498330c6f42052a3ffe18ff9f73932ca4379 Mon Sep 17 00:00:00 2001 From: cooked Date: Wed, 16 Oct 2024 12:19:19 +0100 Subject: [PATCH] Add CI Job for Maven Central Publishing Co-authored-by: Daniel Milnes Co-authored-by: DJ --- .github/workflows/release.yml | 49 +++++++++++++++++++++++++++++++++++ build.gradle | 15 +++-------- 2 files changed, 53 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..98f3bba --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,49 @@ +name: Publish Release Artifacts +on: + release: + types: [ created ] + +permissions: + contents: write + packages: write + id-token: write + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: '0' + - name: Set up Java + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'temurin' + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@v1 + - name: Set Gradle App Version to ${{ github.event.release.tag_name }} + run: sed -i "s/version = '.*'/version = '${{ github.event.release.tag_name }}'/g" build.gradle + - name: Publish package + uses: gradle/gradle-build-action@v2.11.1 + with: + arguments: publish + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Publish package to Maven Central + uses: gradle/gradle-build-action@v2.11.1 + with: + arguments: jreleaserFullRelease + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.JRELEASER_MAVENCENTRAL_USERNAME }} + JRELEASER_MAVENCENTRAL_TOKEN: ${{ secrets.JRELEASER_MAVENCENTRAL_TOKEN }} + JRELEASER_GPG_SECRET_KEY: "${{ secrets.JRELEASER_GPG_SECRET_KEY }}" + JRELEASER_GPG_PUBLIC_KEY: "${{ secrets.JRELEASER_GPG_PUBLIC_KEY }}" + JRELEASER_GPG_PASSPHRASE: "${{ secrets.JRELEASER_GPG_PASSPHRASE }}" + JRELEASER_GITHUB_TOKEN: ${{ github.token }} + JRELEASER_MAVENCENTRAL_STAGE: "FULL" + - name: Add Artifact to GitHub Release + uses: softprops/action-gh-release@v1 + with: + files: build/libs/disruptor-proxy-*.jar diff --git a/build.gradle b/build.gradle index 9e4d328..31bdf85 100644 --- a/build.gradle +++ b/build.gradle @@ -29,7 +29,8 @@ plugins { defaultTasks 'checkstyleTest', 'checkstyleMain', 'build' group = 'com.lmax' -version = new Version(major: 2, minor: 2, revision: 0) +// The below is updated by CI during the release +version = '1.0.0' ext { fullName = 'Disruptor-Proxy' @@ -130,18 +131,10 @@ jreleaser { url = 'https://central.sonatype.com/api/v1/publisher' stagingRepository('build/staging-deploy') applyMavenCentralRules = true + closeRepository = true + releaseRepository = true } } } } } - -class Version { - int major, minor = 0, revision = 0 - boolean snapshot - String stage - - String toString() { - "$major.$minor.$revision${stage ? '.' + stage : ''}${snapshot ? '-SNAPSHOT' : ''}" - } -}