--- name: release on: push: branches: - main jobs: release: name: Release runs-on: ubuntu-latest if: ${{ !startsWith(github.event.head_commit.message, 'Release') }} steps: - name: Checkout uses: actions/checkout@v3 with: fetch-depth: 0 - name: Set up Environment run: | apt update apt install -y zip mkdir -p /root/.jreleaser touch /root/.jreleaser/config.properties - name: Determine next version uses: https://github.com/obfu5c8/action-svu id: generate_next_version with: type: auto force-increment: true no-metadata: false no-pre-release: false no-build: false strip-prefix: true prefix: '' suffix: '' - name: Install syft uses: https://github.com/anchore/sbom-action/download-syft@v0 id: install_syft with: syft-version: v1.18.1 - name: Set new version run: | NEW_VERSION=${{steps.generate_next_version.outputs.version}} echo NEW_VERSION=$NEW_VERSION >> "$GITHUB_ENV" echo "New version: $NEW_VERSION" - name: Cache Java and Maven software uses: https://github.com/actions/cache@v3 with: path: ~/.sdkman key: ${{ runner.os }}-sdkman restore-keys: | ${{ runner.os }}-sdkman env: ACTIONS_STEP_DEBUG: true - name: Cache local Maven repository uses: https://github.com/actions/cache@v3 with: path: ~/.m2/repository key: ${{ runner.os }}-maven restore-keys: | ${{ runner.os }}-maven env: ACTIONS_STEP_DEBUG: true - name: Install Java & Maven uses: https://github.com/sdkman/sdkman-action@main id: sdkman - name: Set Version env: MAVEN_USERNAME: ${{ secrets.NEXUS_USERNAME }} MAVEN_CENTRAL_TOKEN: ${{ secrets.NEXUS_PASSWORD }} MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} run: | export GPG_TTY=$(tty) git config user.name "${{ github.event.head_commit.committer.name }}" git config user.email "${{ github.event.head_commit.committer.email }}" mvn -B --file pom.xml versions:set -DnewVersion=${{ env.NEW_VERSION }} - name: Run JReleaser (Changelog) uses: https://w9r.dev/actions/release-action@main with: arguments: changelog --debug setup-java: false continue-on-error: true env: JRELEASER_OUTPUT_DIRECTORY: target JRELEASER_PROJECT_VERSION: ${{ env.NEW_VERSION }} JRELEASER_GITEA_TOKEN: ${{ secrets.JRELEASER_GITEA_TOKEN }} JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }} JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_PRIVATE_KEY }} - name: Commit and push changes run: | git config user.name "${{ github.event.head_commit.committer.name }}" git config user.email "${{ github.event.head_commit.committer.email }}" git add pom.xml CHANGELOG.md git commit -a -m "Release ${{ env.NEW_VERSION }}" git push - name: Build package run: | mvn -B --file pom.xml package - name: Run JReleaser (Assemble) uses: https://w9r.dev/actions/release-action@main with: arguments: assemble --debug setup-java: false continue-on-error: true env: JRELEASER_OUTPUT_DIRECTORY: target JRELEASER_PROJECT_VERSION: ${{ env.NEW_VERSION }} JRELEASER_GITEA_TOKEN: ${{ secrets.JRELEASER_GITEA_TOKEN }} JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }} JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_PRIVATE_KEY }} - name: Run JReleaser (Release) uses: https://w9r.dev/actions/release-action@main with: arguments: release --debug setup-java: false env: JRELEASER_OUTPUT_DIRECTORY: target JRELEASER_PROJECT_VERSION: ${{ env.NEW_VERSION }} JRELEASER_GITEA_TOKEN: ${{ secrets.JRELEASER_GITEA_TOKEN }} JRELEASER_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.GPG_PUBLIC_KEY }} JRELEASER_GPG_SECRET_KEY: ${{ secrets.GPG_PRIVATE_KEY }} # Persist logs - name: JReleaser release trace if: always() uses: https://gitea.com/actions/upload-artifact@v3 with: name: jreleaser-trace path: target/jreleaser/trace.log - name: JReleaser release properties if: always() uses: https://gitea.com/actions/upload-artifact@v3 with: name: jreleaser-properties path: target/jreleaser/output.properties