From b29f578d882a9bc9d2c736833ccf6d795e66cf2a Mon Sep 17 00:00:00 2001 From: Chris Laprun Date: Wed, 30 Oct 2024 22:52:59 +0100 Subject: [PATCH] fix: snapshot releases (#986) * wip: check snapshot release Signed-off-by: Chris Laprun * wip: switch to new release snapshot workflow Signed-off-by: Chris Laprun * wip: rename to try to trigger it Signed-off-by: Chris Laprun * wip: try to activate new snapshot workflow Signed-off-by: Chris Laprun * fix: properly declare output of prepare-version job Signed-off-by: Chris Laprun --------- Signed-off-by: Chris Laprun --- .github/workflows/release-snapshot.yml | 85 +++++++++++++++----------- 1 file changed, 49 insertions(+), 36 deletions(-) diff --git a/.github/workflows/release-snapshot.yml b/.github/workflows/release-snapshot.yml index eb8ed7c5..74be017a 100644 --- a/.github/workflows/release-snapshot.yml +++ b/.github/workflows/release-snapshot.yml @@ -1,7 +1,7 @@ -name: Release snapshot +name: Deploy Snapshot on: - workflow_call: + workflow_dispatch: inputs: branch: type: string @@ -10,28 +10,35 @@ on: version: type: string required: false - secrets: - GPG_PRIVATE_KEY: - required: true - OSSRH_USERNAME: - required: true - OSSRH_TOKEN: - required: true - GPG_PASSPHRASE: - required: true -concurrency: - group: "${{ github.workflow }}-${{ github.ref }}" - cancel-in-progress: true + workflow_call: + inputs: + branch: + type: string + required: false + default: 'main' + version: + type: string + required: false defaults: run: shell: bash +permissions: + attestations: write + id-token: write + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: - release-snapshot: + prepare-version: runs-on: ubuntu-latest - + outputs: + version: ${{steps.snapshot-version.outputs.version}} steps: - uses: actions/checkout@v4 with: @@ -40,27 +47,33 @@ jobs: - uses: actions/setup-java@v4 with: distribution: 'temurin' - java-version: 17 + java-version: 21 cache: 'maven' - server-id: ossrh - server-username: MAVEN_USERNAME - server-password: MAVEN_PASSWORD - gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} - gpg-passphrase: MAVEN_GPG_PASSPHRASE - - name: Change version to "${{inputs.version}}" if needed - if: ${{ inputs.version != '' }} + - name: Retrieve and export project version + id: project-version run: | - echo "Set version to ${{inputs.version}}" - ./mvnw versions:set -DnewVersion="${{inputs.version}}" versions:commit -Puse-snapshots - - - name: Output information - run: echo "Release snapshot for branch ${{inputs.branch}} with version $(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)" - - - name: Deploy maven snapshot + version=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout) + echo "Project version: ${version}" + echo "version=${version}" >> $GITHUB_OUTPUT + + - name: Override project version if requested + id: snapshot-version run: | - ./mvnw -B deploy -DperformRelease -Dno-samples -Dno-docs -Prelease,use-snapshots - env: - MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} - MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} - MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + if [ -z "${{inputs.version}}" ]; + then + echo "version=${{steps.project-version.outputs.version}}" >> $GITHUB_OUTPUT + else + echo "Version override requested: ${{inputs.version}}" + echo "version=${{inputs.version}}" >> $GITHUB_OUTPUT + fi + + deploy-snapshot: + name: Deploy Snapshots + uses: quarkiverse/.github/.github/workflows/perform-release.yml@main + secrets: inherit + needs: + - prepare-version + with: + ref: main + version: ${{needs.prepare-version.outputs.version}} \ No newline at end of file