On workflow dispatch start maven release #22
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This workflow will build a Java project with Maven | |
| # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven | |
| name: On workflow dispatch start maven release | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| releaseversion: | |
| description: 'Release version' | |
| required: true | |
| default: "0.2.6" | |
| # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| # See https://stackoverflow.com/a/61421306/15619 | |
| env: | |
| RELEASE_VERSION: ${{github.event.inputs.releaseversion}} | |
| steps: | |
| - run: echo "Will perform a maven release with public version ${{ github.event.inputs.releaseversion }}" | |
| - uses: actions/checkout@v6 | |
| with: | |
| ref: main | |
| fetch-depth: '0' | |
| # Changing the token here in fact impacts the way mvn pushes data back to the repo, | |
| # Including the fact this very file will get updated during release | |
| token: ${{ secrets.TOKEN_FOR_GITHUB }} | |
| - name: Import GPG key | |
| id: import_gpg | |
| uses: crazy-max/ghaction-import-gpg@v6.1.0 | |
| with: | |
| gpg_private_key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} | |
| passphrase: ${{ secrets.MAVEN_GPG_PASSPHRASE }} | |
| - name: List gpg keys (there should be only one) | |
| run: gpg -K | |
| - name: Setup git configuration | |
| run: | | |
| git config --global user.email "aadarchi-releaser-bot@users.noreply.github.com" | |
| git config --global user.name "🤖 Aadarchi releaser bot" | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v5 | |
| with: | |
| java-version: '17' | |
| distribution: 'adopt' | |
| cache: maven | |
| server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml | |
| server-username: ${{ secrets.OSS_SONATYPE_USERNAME }} | |
| server-password: ${{ secrets.OSS_SONATYPE_PASSWORD }} | |
| - name: Do not forget to configure Maven Settings! | |
| uses: s4u/maven-settings-action@v3.0.0 | |
| with: | |
| override: true | |
| githubServer: true | |
| servers: | | |
| [{ | |
| "id": "central", | |
| "username": "${{ secrets.SONATYPE_PORTAL_TOKEN_USERNAME }}", | |
| "password": "${{ secrets.SONATYPE_PORTAL_TOKEN_SECRET }}" | |
| }] | |
| properties: | | |
| [ | |
| {"aadarchi.github.token": "${{ secrets.TOKEN_FOR_GITHUB }}" }, | |
| {"aadarchi.gitlab.token": "${{ secrets.TOKEN_FOR_GITLAB }}" }, | |
| {"releaseVersion": "${{env.RELEASE_VERSION}}" }, | |
| {"username": "git"}, | |
| {"password": "${{ secrets.GITHUB_TOKEN }}"} | |
| ] | |
| - name: Build with Maven | |
| run: mvn --no-transfer-progress -B release:prepare release:perform -Prelease --file pom.xml | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| MAVEN_GPG_PASSPHRASE: ${{secrets.MAVEN_GPG_PASSPHRASE}} | |
| - name: Get created tag name (for GitHub release creation) | |
| id: tag | |
| run: echo "CREATED_GIT_TAG=$(git describe --tags --abbrev=0)" >> "$GITHUB_OUTPUT" | |
| - name: Create associated GitHub release | |
| uses: lakto/gren-action@v2.0.0 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.TOKEN_FOR_GITHUB }} | |
| with: | |
| options: "--override --data-source=issues --prerelease --limit=1 --tags=${{ steps.tag.outputs.CREATED_GIT_TAG }}" |