Skip to content

Commit 1e4b16d

Browse files
committed
ci: automate GitHub Releases on version tags
Add a release job that triggers on v* tags, extracts the relevant CHANGELOG section via awk, and creates a GitHub Release with gh cli. Depends on unit and integration passing before publishing.
1 parent d88d611 commit 1e4b16d

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: CI
33
on:
44
push:
55
branches: [main]
6+
tags: ['v*']
67
pull_request:
78
branches: [main]
89

@@ -45,3 +46,27 @@ jobs:
4546
exit 0
4647
fi
4748
mvn -B -Dtest='*IntegrationTest' test
49+
50+
release:
51+
needs: [unit, integration]
52+
runs-on: ubuntu-latest
53+
if: startsWith(github.ref, 'refs/tags/v')
54+
permissions:
55+
contents: write
56+
steps:
57+
- uses: actions/checkout@v4
58+
- name: Extract changelog for ${{ github.ref_name }}
59+
id: changelog
60+
run: |
61+
VERSION="${GITHUB_REF_NAME#v}"
62+
NOTES=$(awk "/^## \[$VERSION\]/{found=1; next} found && /^## \[/{exit} found{print}" CHANGELOG.md)
63+
echo "notes<<EOF" >> "$GITHUB_OUTPUT"
64+
echo "$NOTES" >> "$GITHUB_OUTPUT"
65+
echo "EOF" >> "$GITHUB_OUTPUT"
66+
- name: Create GitHub Release
67+
env:
68+
GH_TOKEN: ${{ github.token }}
69+
run: |
70+
gh release create "$GITHUB_REF_NAME" \
71+
--title "$GITHUB_REF_NAME" \
72+
--notes "${{ steps.changelog.outputs.notes }}"

0 commit comments

Comments
 (0)