File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Create Release
2+
3+ on :
4+ push :
5+ tags :
6+ - ' v*' # Trigger on version tags like v0.1.0, v1.0.0, etc.
7+
8+ permissions :
9+ contents : write
10+
11+ jobs :
12+ create-release :
13+ runs-on : ubuntu-latest
14+ steps :
15+ - name : Checkout code
16+ uses : actions/checkout@v4
17+
18+ - name : Extract version from tag
19+ id : get_version
20+ run : echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
21+
22+ - name : Extract changelog for this version
23+ id : changelog
24+ run : |
25+ if [ -f CHANGELOG.md ]; then
26+ # Extract the section for this version from CHANGELOG.md
27+ VERSION="${{ github.ref_name }}"
28+ # Escape dots in version for regex
29+ VERSION_ESCAPED=$(echo "$VERSION" | sed 's/\./\\./g')
30+ # Use awk to extract content: start at version header, stop at next ## header
31+ CHANGES=$(awk "BEGIN{p=0} /^## \[$VERSION_ESCAPED\]/{p=1;next} /^## \[/{p=0} p" CHANGELOG.md | sed '/^$/d')
32+
33+ if [ -z "$CHANGES" ]; then
34+ echo "CHANGELOG_CONTENT=No changelog entry found for this version." >> $GITHUB_OUTPUT
35+ else
36+ # Escape newlines for GitHub output
37+ echo "CHANGELOG_CONTENT<<EOF" >> $GITHUB_OUTPUT
38+ echo "$CHANGES" >> $GITHUB_OUTPUT
39+ echo "EOF" >> $GITHUB_OUTPUT
40+ fi
41+ else
42+ echo "CHANGELOG_CONTENT=CHANGELOG.md not found." >> $GITHUB_OUTPUT
43+ fi
44+
45+ - name : Create Release
46+ uses : softprops/action-gh-release@v1
47+ with :
48+ name : Release ${{ github.ref_name }}
49+ body : |
50+ ## Changes
51+
52+ ${{ steps.changelog.outputs.CHANGELOG_CONTENT }}
53+
54+ draft : true
55+ prerelease : false
56+ generate_release_notes : false
You can’t perform that action at this time.
0 commit comments