| Marc Kupietz | 7e54885 | 2026-06-08 22:55:03 +0200 | [diff] [blame] | 1 | name: Release |
| 2 | |
| 3 | on: |
| 4 | push: |
| 5 | tags: |
| 6 | - 'v*' |
| 7 | |
| 8 | jobs: |
| 9 | release: |
| 10 | runs-on: ubuntu-latest |
| 11 | steps: |
| 12 | - uses: actions/checkout@v4 |
| 13 | |
| 14 | - name: Set up JDK 21 |
| 15 | uses: actions/setup-java@v4 |
| 16 | with: |
| 17 | distribution: 'temurin' |
| 18 | java-version: '21' |
| 19 | cache: 'maven' |
| 20 | |
| 21 | - name: Build Indexer jar |
| margaretha | 516f93a | 2026-06-23 11:10:27 +0200 | [diff] [blame] | 22 | run: mvn -B package |
| Marc Kupietz | 7e54885 | 2026-06-08 22:55:03 +0200 | [diff] [blame] | 23 | |
| 24 | - name: Get version and pre-release status |
| 25 | id: get_version |
| 26 | run: | |
| 27 | TAG_NAME=${GITHUB_REF#refs/tags/} |
| 28 | echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT |
| 29 | # Changes file headings have no leading "v" (e.g. "0.65 2026-05-12"). |
| 30 | echo "version=${TAG_NAME#v}" >> $GITHUB_OUTPUT |
| 31 | if [[ "$TAG_NAME" =~ (alpha|beta|rc) ]]; then |
| 32 | echo "prerelease=true" >> $GITHUB_OUTPUT |
| 33 | else |
| 34 | echo "prerelease=false" >> $GITHUB_OUTPUT |
| 35 | fi |
| 36 | |
| 37 | - name: Extract release notes from Changes |
| 38 | id: changelog |
| 39 | run: | |
| 40 | VERSION="${{ steps.get_version.outputs.version }}" |
| 41 | # Pull the section for this version: everything between the heading |
| 42 | # line that starts with "<version> " and the next version heading. |
| 43 | # The Changes file is authored by hand (Gerrit workflow, no PRs to |
| 44 | # mine for notes). |
| 45 | NOTES=$(awk -v ver="$VERSION" ' |
| 46 | /^[0-9]+\.[0-9]/ { |
| 47 | if ($1 == ver) { flag=1; next } |
| 48 | else if (flag) { exit } |
| 49 | } |
| 50 | flag { print } |
| 51 | ' Changes) |
| 52 | if [ -z "$(echo "$NOTES" | tr -d '[:space:]')" ]; then |
| 53 | echo "No Changes section found for $VERSION; falling back to a generic body." >&2 |
| 54 | NOTES="Release ${{ steps.get_version.outputs.tag_name }}" |
| 55 | fi |
| 56 | { |
| 57 | echo "notes<<__CHANGELOG_EOF__" |
| 58 | echo "$NOTES" |
| 59 | echo "__CHANGELOG_EOF__" |
| 60 | } >> "$GITHUB_OUTPUT" |
| 61 | |
| 62 | - name: Create Release |
| 63 | uses: softprops/action-gh-release@v2 |
| 64 | with: |
| 65 | body: ${{ steps.changelog.outputs.notes }} |
| 66 | tag_name: ${{ steps.get_version.outputs.tag_name }} |
| margaretha | 50cff35 | 2026-06-23 11:23:48 +0200 | [diff] [blame] | 67 | name: ${{ steps.get_version.outputs.tag_name }} |
| Marc Kupietz | 7e54885 | 2026-06-08 22:55:03 +0200 | [diff] [blame] | 68 | prerelease: ${{ steps.get_version.outputs.prerelease }} |
| 69 | files: | |
| 70 | target/Krill-Indexer.jar |
| 71 | env: |
| 72 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |