Skip to content

Release

Release #23

Workflow file for this run

name: Release
on:
workflow_dispatch:
inputs:
release_version:
description: 'Release version (e.g. 3.6). If unspecified, derived from POM version by removing -dev suffix.'
required: false
next_version:
description: 'Next development version (e.g. 3.7-dev). If unspecified, bumps minor version and appends -dev.'
required: false
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Set up JDK 17
uses: actions/setup-java@v5
with:
java-version: '17'
distribution: 'temurin'
cache: maven
server-id: jboss-releases-repository
server-username: NEXUS_USER
server-password: NEXUS_TOKEN
- name: Determine versions
id: versions
run: |
POM_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "POM version: $POM_VERSION"
if [ -n "${{ github.event.inputs.release_version }}" ]; then
RELEASE_VERSION="${{ github.event.inputs.release_version }}"
else
RELEASE_VERSION="${POM_VERSION%-dev}"
if [ "$RELEASE_VERSION" = "$POM_VERSION" ]; then
echo "::error::POM version '$POM_VERSION' does not end with -dev and no release version was specified."
exit 1
fi
fi
if [ -n "${{ github.event.inputs.next_version }}" ]; then
NEXT_VERSION="${{ github.event.inputs.next_version }}"
else
MAJOR="${RELEASE_VERSION%%.*}"
MINOR="${RELEASE_VERSION#*.}"
NEXT_MINOR=$((MINOR + 1))
NEXT_VERSION="${MAJOR}.${NEXT_MINOR}-dev"
fi
echo "Release version: $RELEASE_VERSION"
echo "Next version: $NEXT_VERSION"
echo "release_version=$RELEASE_VERSION" >> "$GITHUB_OUTPUT"
echo "next_version=$NEXT_VERSION" >> "$GITHUB_OUTPUT"
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Set release version
run: |
mvn versions:set -DnewVersion=${{ steps.versions.outputs.release_version }} -DgenerateBackupPoms=false
git commit -am "Release ${{ steps.versions.outputs.release_version }}"
- name: Build and deploy
run: mvn clean deploy -Prelease -DskipTests
env:
NEXUS_USER: ${{ secrets.NEXUS_USER }}
NEXUS_TOKEN: ${{ secrets.NEXUS_TOKEN }}
MAVEN_GPG_KEY: ${{ secrets.GPG_ARMORED }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
- name: Tag release
run: |
git tag -a "v${{ steps.versions.outputs.release_version }}" -m "Release ${{ steps.versions.outputs.release_version }}"
- name: Set next development version
run: |
mvn versions:set -DnewVersion=${{ steps.versions.outputs.next_version }} -DgenerateBackupPoms=false
git commit -am "Next version ${{ steps.versions.outputs.next_version }}"
- name: Push changes and tag
run: |
git push origin HEAD
git push origin "v${{ steps.versions.outputs.release_version }}"
- name: Generate release notes
id: notes
env:
GH_TOKEN: ${{ github.token }}
run: |
RELEASE_VERSION="${{ steps.versions.outputs.release_version }}"
PREV_TAG=$(git tag --sort=-v:refname | grep -v "v${RELEASE_VERSION}" | head -1)
echo "Previous tag: $PREV_TAG"
NOTES_FILE=$(mktemp)
echo "## What's New in ${RELEASE_VERSION}" >> "$NOTES_FILE"
echo "" >> "$NOTES_FILE"
# Collect issues closed by commits in this release
ISSUES=$(git log "${PREV_TAG}..v${RELEASE_VERSION}" --oneline \
| grep -oP '#\d+' | sort -t'#' -k2 -n -u | tr -d '#')
if [ -n "$ISSUES" ]; then
echo "### Issues" >> "$NOTES_FILE"
echo "" >> "$NOTES_FILE"
for issue in $ISSUES; do
TITLE=$(gh issue view "$issue" --json title -q '.title' 2>/dev/null || echo "")
STATE=$(gh issue view "$issue" --json state -q '.state' 2>/dev/null || echo "")
if [ -n "$TITLE" ]; then
if [ "$STATE" = "CLOSED" ]; then
echo "- ~~#${issue}~~ ${TITLE}" >> "$NOTES_FILE"
else
echo "- #${issue} ${TITLE}" >> "$NOTES_FILE"
fi
fi
done
echo "" >> "$NOTES_FILE"
fi
# Categorize commits
echo "### Changes" >> "$NOTES_FILE"
echo "" >> "$NOTES_FILE"
git log "${PREV_TAG}..v${RELEASE_VERSION}" --oneline --no-merges \
| grep -v "Release \|Next version \|Bump " \
| sed 's/^[0-9a-f]* /- /' >> "$NOTES_FILE"
echo "" >> "$NOTES_FILE"
echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${PREV_TAG}...v${RELEASE_VERSION}" >> "$NOTES_FILE"
echo "notes_file=$NOTES_FILE" >> "$GITHUB_OUTPUT"
- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "v${{ steps.versions.outputs.release_version }}" \
--title "Release ${{ steps.versions.outputs.release_version }}" \
--notes-file "${{ steps.notes.outputs.notes_file }}"