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 : release
2+
3+ on :
4+ push :
5+ tags :
6+ - " v*"
7+ workflow_dispatch :
8+ inputs :
9+ tag :
10+ description : " Existing tag to release, for example v1.4.0"
11+ required : true
12+ type : string
13+
14+ permissions :
15+ contents : write
16+
17+ jobs :
18+ github-release :
19+ runs-on : ubuntu-latest
20+ env :
21+ RELEASE_TAG : ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}
22+ steps :
23+ - name : Checkout repo
24+ uses : actions/checkout@v4
25+ with :
26+ fetch-depth : 0
27+
28+ - name : Extract release notes
29+ run : |
30+ TAG="${RELEASE_TAG}"
31+ git rev-parse "$TAG" >/dev/null
32+ awk -v tag="$TAG" '
33+ index($0, "## [" tag "]") == 1 { found = 1; next }
34+ found && /^## \[/ { exit }
35+ found { print }
36+ ' changelog.md > release_notes.md
37+
38+ if [ ! -s release_notes.md ]; then
39+ echo "Release $TAG" > release_notes.md
40+ fi
41+
42+ - name : Create or update GitHub release
43+ env :
44+ GH_TOKEN : ${{ github.token }}
45+ run : |
46+ TAG="${RELEASE_TAG}"
47+ if gh release view "$TAG" >/dev/null 2>&1; then
48+ gh release edit "$TAG" --title "$TAG" --notes-file release_notes.md
49+ else
50+ gh release create "$TAG" --title "$TAG" --notes-file release_notes.md
51+ fi
You can’t perform that action at this time.
0 commit comments