Skip to content

Create Release

Create Release #2

name: Create Release
on:
workflow_dispatch:
inputs:
versionTag:
description: 'Version Tag (semantic version)'
required: true
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '21'
settings-path: ${{ github.workspace }}
- name: Load local Maven repository cache
uses: actions/cache@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up git
run: |
git config --global user.email "[email protected]"
git config --global user.name "JohnnyQ5"
- name: Set version in Maven project
run: mvn versions:set -DnewVersion=${{ github.event.inputs.versionTag }}
- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Create Release Notes
if: ${{ !startsWith(github.ref, 'refs/tags/')
&& !( contains(github.event.inputs.versionTag, 'alpha')
|| contains(github.event.inputs.versionTag, 'beta')
|| contains(github.event.inputs.versionTag, 'rc')) }}
uses: actions/github-script@v7
with:
github-token: ${{secrets.JOHNNY_Q5_REPORTS_TOKEN}}
script: |
await github.request(`POST /repos/${{ github.repository }}/releases`, {
tag_name: "${{ github.event.inputs.versionTag }}",
generate_release_notes: true
});
- name: Create Pre-Release Notes
if: ${{ !startsWith(github.ref, 'refs/tags/')
&& ( contains(github.event.inputs.versionTag, 'alpha')
|| contains(github.event.inputs.versionTag, 'beta')
|| contains(github.event.inputs.versionTag, 'rc')) }}
uses: actions/github-script@v7
with:
github-token: ${{secrets.JOHNNY_Q5_REPORTS_TOKEN}}
script: |
await github.request(`POST /repos/${{ github.repository }}/releases`, {
tag_name: "${{ github.event.inputs.versionTag }}",
generate_release_notes: true,
prerelease: true
});
- name: Publish artefact to QBiC Nexus Repository
run: mvn --quiet --settings $GITHUB_WORKSPACE/.github.settings.xml deploy
env:
MAVEN_REPO_USERNAME: ${{ secrets.NEXUS_USERNAME }}
MAVEN_REPO_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
- name: Switch to new branch
run: git checkout -b release/set-version-to-${{ github.event.inputs.versionTag }}
- name: Set remote branch
run: git push --set-upstream origin release/set-version-to-${{ github.event.inputs.versionTag }}
- name: Checkin commit
run: git commit . -m 'Set version to ${{ github.event.inputs.versionTag }}'
- name: Push to Github
run: git push
- name: Open PR with version bump
uses: actions/github-script@v7
with:
github-token: ${{secrets.JOHNNY_Q5_REPORTS_TOKEN}}
script: |
await github.request(`POST /repos/${{ github.repository }}/pulls`, {
title: 'Update version to ${{ github.event.inputs.versionTag }}',
head: 'release/set-version-to-${{ github.event.inputs.versionTag }}',
base: 'main'
});