Publish Release #28
This file contains 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
# SPDX-FileCopyrightText: 2023 iteratec GmbH | |
# | |
# SPDX-License-Identifier: Apache-2.0 | |
# This workflow will publish a Java project with Maven | |
# For Maven Release plugin see: https://maven.apache.org/maven-release/maven-release-plugin/ | |
# For GitHub release see: https://github.com/marketplace/actions/gh-release | |
name: Publish Release | |
# If input is empty we automatically bump the version | |
on: | |
workflow_dispatch: | |
inputs: | |
customversion: | |
description: 'Custom version, e.g., 1.0.0-beta (optional)' | |
required: false | |
default: '' | |
nextversion: | |
description: 'Next development version, e.g., 1.0.0-SNAPSHOT (optional)' | |
required: false | |
default: '' | |
jobs: | |
publish-release: | |
runs-on: ubuntu-22.04 | |
if: github.repository == 'secureCodeBox/defectdojo-client-java' | |
permissions: | |
contents: write # needed for release creation | |
steps: | |
- name: Validate next version input # Exit when version has no -SNAPSHOT suffix | |
if: github.event.inputs.nextversion != '' | |
run: | | |
if [[ "${{ inputs.nextversion }}" != *-SNAPSHOT ]]; then exit 1; fi | |
- name: Releasing custom version | |
if: github.event.inputs.customversion != '' | |
run: echo "Releasing version ${{ github.event.inputs.customversion }}" | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # required by previous_tag | |
ref: ${{ github.head_ref }} | |
token: ${{ secrets.SCB_BOT_USER_TOKEN }} | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 17 | |
distribution: temurin | |
server-id: ossrh | |
server-username: MAVEN_USERNAME | |
server-password: MAVEN_PASSWORD | |
gpg-private-key: ${{ secrets.SIGNING_KEY }} | |
gpg-passphrase: MAVEN_GPG_PASSPHRASE | |
- name: Import GPG key | |
uses: crazy-max/ghaction-import-gpg@v6 | |
with: | |
gpg_private_key: ${{ secrets.SCB_BOT_GPG_KEY }} | |
passphrase: ${{ secrets.SCB_BOT_GPG_PASSPHRASE }} | |
git_user_signingkey: true | |
git_tag_gpgsign: true | |
git_commit_gpgsign: true | |
git_committer_name: secureCodeBoxBot | |
git_committer_email: [email protected] | |
# CASE: Version set | |
- name: "[Custom version] Release & Publish" | |
if: github.event.inputs.customversion != '' # input "customversion" not empty | |
run: mvn -B release:prepare release:perform -DreleaseVersion=${{ github.event.inputs.customversion }} -DdevelopmentVersion=${{ github.event.inputs.nextversion }} -P release | |
env: | |
GITHUB_TOKEN: ${{ secrets.SCB_BOT_USER_TOKEN }} | |
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} | |
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} | |
MAVEN_GPG_PASSPHRASE: ${{ secrets.SIGNING_PASSWORD }} | |
# CASE: NO Version set | |
- name: "[Auto version] Release & Publish" | |
if: github.event.inputs.customversion == '' # input "customversion" empty | |
run: mvn -B release:prepare release:perform -DdevelopmentVersion=${{ github.event.inputs.nextversion }} -P release | |
env: | |
GITHUB_TOKEN: ${{ secrets.SCB_BOT_USER_TOKEN }} | |
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} | |
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} | |
MAVEN_GPG_PASSPHRASE: ${{ secrets.SIGNING_PASSWORD }} | |
- name: "Extract maven version" # required for following change readme step | |
id: extract-version | |
run: | | |
MVN_VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec) | |
echo "MVN_VERSION=$MVN_VERSION" >> $GITHUB_OUTPUT | |
# Required for creation of GitHub release | |
- name: "Get previous tag" | |
id: previous_tag | |
uses: WyriHaximus/github-action-get-previous-tag@v1 | |
- name: "Create GitHub Release" | |
uses: softprops/action-gh-release@v1 | |
with: | |
token: ${{ github.token }} # could be replaced with personal access token | |
tag_name: ${{ steps.previous_tag.outputs.tag }} | |
generate_release_notes: true |