blob: c57bad9483b34c1c306a9156ee04d3578bb13eda [file] [log] [blame]
name: Release
on:
push:
tags:
- 'v*'
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
cache: 'maven'
- name: Build Indexer jar
run: mvn -B -DskipTests package
- name: Get version and pre-release status
id: get_version
run: |
TAG_NAME=${GITHUB_REF#refs/tags/}
echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT
# Changes file headings have no leading "v" (e.g. "0.65 2026-05-12").
echo "version=${TAG_NAME#v}" >> $GITHUB_OUTPUT
if [[ "$TAG_NAME" =~ (alpha|beta|rc) ]]; then
echo "prerelease=true" >> $GITHUB_OUTPUT
else
echo "prerelease=false" >> $GITHUB_OUTPUT
fi
- name: Extract release notes from Changes
id: changelog
run: |
VERSION="${{ steps.get_version.outputs.version }}"
# Pull the section for this version: everything between the heading
# line that starts with "<version> " and the next version heading.
# The Changes file is authored by hand (Gerrit workflow, no PRs to
# mine for notes).
NOTES=$(awk -v ver="$VERSION" '
/^[0-9]+\.[0-9]/ {
if ($1 == ver) { flag=1; next }
else if (flag) { exit }
}
flag { print }
' Changes)
if [ -z "$(echo "$NOTES" | tr -d '[:space:]')" ]; then
echo "No Changes section found for $VERSION; falling back to a generic body." >&2
NOTES="Release ${{ steps.get_version.outputs.tag_name }}"
fi
{
echo "notes<<__CHANGELOG_EOF__"
echo "$NOTES"
echo "__CHANGELOG_EOF__"
} >> "$GITHUB_OUTPUT"
- name: Create Release
uses: softprops/action-gh-release@v2
with:
body: ${{ steps.changelog.outputs.notes }}
tag_name: ${{ steps.get_version.outputs.tag_name }}
name: Release ${{ steps.get_version.outputs.tag_name }}
prerelease: ${{ steps.get_version.outputs.prerelease }}
files: |
target/Krill-Indexer.jar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}