diff --git a/.github/workflows/release-perform.yml b/.github/workflows/release-perform.yml index 0a60775a..5fd1a0a7 100644 --- a/.github/workflows/release-perform.yml +++ b/.github/workflows/release-perform.yml @@ -9,6 +9,10 @@ on: tag: description: 'Tag to release' required: true + ref: + description: 'Branch or tag to deploy' + type: string + required: false dry_run: description: 'Dry run the release' required: false @@ -47,7 +51,7 @@ jobs: steps: - uses: actions/checkout@v4 with: - ref: ${{github.ref}} + ref: ${{inputs.ref || github.ref}} - name: Gather versions id: versions diff --git a/.github/workflows/release-snapshot-old.yml b/.github/workflows/release-snapshot-old.yml new file mode 100644 index 00000000..eb8ed7c5 --- /dev/null +++ b/.github/workflows/release-snapshot-old.yml @@ -0,0 +1,66 @@ +name: Release snapshot + +on: + workflow_call: + inputs: + branch: + type: string + required: false + default: 'main' + 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 + +defaults: + run: + shell: bash + +jobs: + release-snapshot: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + with: + ref: "${{inputs.branch}}" + + - uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 17 + 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 != '' }} + 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 + 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 }} diff --git a/.github/workflows/release-snapshot-on-push-selected-branches.yml b/.github/workflows/release-snapshot-on-push-selected-branches.yml index caa301fc..5fe9ab44 100644 --- a/.github/workflows/release-snapshot-on-push-selected-branches.yml +++ b/.github/workflows/release-snapshot-on-push-selected-branches.yml @@ -10,11 +10,6 @@ defaults: jobs: release-snapshot: - uses: ./.github/workflows/release-snapshot.yml + uses: release-snapshot.yml with: - branch: "${{github.ref}}" - secrets: - GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} - OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} - OSSRH_TOKEN: ${{ secrets.OSSRH_TOKEN }} - GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} \ No newline at end of file + branch: "${{github.ref}}" \ No newline at end of file diff --git a/.github/workflows/release-snapshot.yml b/.github/workflows/release-snapshot.yml index eb8ed7c5..6c9c0d3f 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,33 @@ 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 - steps: - uses: actions/checkout@v4 with: @@ -40,27 +45,27 @@ 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 + - name: Retrieve and export project version + run: | + version=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout) + echo "Project version: ${version}" + echo "version=${version}" >> $GITHUB_OUTPUT + + - name: Override project version if requested if: ${{ inputs.version != '' }} run: | - echo "Set version to ${{inputs.version}}" - ./mvnw versions:set -DnewVersion="${{inputs.version}}" versions:commit -Puse-snapshots + echo "Version override requested: ${{inputs.version}}" + echo "version=${{inputs.version}}" >> $GITHUB_OUTPUT - - 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 - 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 }} + 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