11name : Release
22
33on :
4- pull_request :
5- types : [closed]
4+ push :
65 branches : ["main", "next"]
6+ workflow_dispatch :
77
88permissions :
99 contents : write
1010 id-token : write
11+ pull-requests : read
1112
1213jobs :
1314 release :
1415 name : Release Amicons
15- if : github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main'
16+ if : github.ref_name == 'main'
1617 runs-on : ubuntu-latest
1718 steps :
1819 - name : Checkout
1920 uses : actions/checkout@v6
21+ - name : Get PR metadata
22+ id : pr
23+ run : |
24+ PR_NUMBER=$(gh api repos/${{ github.repository }}/commits/${{ github.sha }}/pulls --jq '.[0].number' 2>/dev/null || true)
25+ if [ -n "$PR_NUMBER" ]; then
26+ TITLE=$(gh pr view "$PR_NUMBER" --json title --jq '.title')
27+ BODY=$(gh pr view "$PR_NUMBER" --json body --jq '.body')
28+ else
29+ TITLE="${{ github.event.head_commit.message }}"
30+ BODY="Automated release for commit ${{ github.sha }}."
31+ fi
32+
33+ {
34+ echo "title<<EOF"
35+ echo "$TITLE"
36+ echo "EOF"
37+ echo "body<<EOF"
38+ echo "$BODY"
39+ echo "EOF"
40+ } >> "$GITHUB_OUTPUT"
41+ env :
42+ GH_TOKEN : ${{ github.token }}
2043 - name : Get version
2144 id : version
2245 run : echo "version=$(jq -r '.version' amicons/package.json)" >> $GITHUB_OUTPUT
@@ -42,12 +65,12 @@ jobs:
4265
4366 - name : Write release notes
4467 env :
45- BODY : ${{ github.event.pull_request .body }}
68+ BODY : ${{ steps.pr.outputs .body }}
4669 run : echo "$BODY" > release-notes.md
4770 - name : Create GitHub release
4871 run : |
4972 gh release create v${{ steps.version.outputs.version }} \
50- --title "${{ github.event.pull_request .title }}" \
73+ --title "${{ steps.pr.outputs .title }}" \
5174 --notes-file release-notes.md \
5275 "amicons-${{ steps.version.outputs.version }}-icons.zip#Amicons icons v${{ steps.version.outputs.version }}"
5376 env :
@@ -58,11 +81,33 @@ jobs:
5881
5982 prerelease :
6083 name : Prerelease Amicons
61- if : github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'next'
84+ if : github.ref_name == 'next'
6285 runs-on : ubuntu-latest
6386 steps :
6487 - name : Checkout
6588 uses : actions/checkout@v6
89+ - name : Get PR metadata
90+ id : pr
91+ run : |
92+ PR_NUMBER=$(gh api repos/${{ github.repository }}/commits/${{ github.sha }}/pulls --jq '.[0].number' 2>/dev/null || true)
93+ if [ -n "$PR_NUMBER" ]; then
94+ TITLE=$(gh pr view "$PR_NUMBER" --json title --jq '.title')
95+ BODY=$(gh pr view "$PR_NUMBER" --json body --jq '.body')
96+ else
97+ TITLE="${{ github.event.head_commit.message }}"
98+ BODY="Automated prerelease for commit ${{ github.sha }}."
99+ fi
100+
101+ {
102+ echo "title<<EOF"
103+ echo "$TITLE"
104+ echo "EOF"
105+ echo "body<<EOF"
106+ echo "$BODY"
107+ echo "EOF"
108+ } >> "$GITHUB_OUTPUT"
109+ env :
110+ GH_TOKEN : ${{ github.token }}
66111 - name : Get version
67112 id : version
68113 run : echo "version=$(jq -r '.version' amicons/package.json)" >> $GITHUB_OUTPUT
@@ -94,12 +139,12 @@ jobs:
94139
95140 - name : Write release notes
96141 env :
97- BODY : ${{ github.event.pull_request .body }}
142+ BODY : ${{ steps.pr.outputs .body }}
98143 run : echo "$BODY" > release-notes.md
99144 - name : Create GitHub prerelease
100145 run : |
101146 gh release create ${{ steps.meta.outputs.tag }} \
102- --title "${{ github.event.pull_request .title }}" \
147+ --title "${{ steps.pr.outputs .title }}" \
103148 --prerelease \
104149 --notes-file release-notes.md \
105150 "amicons-${{ steps.meta.outputs.label }}-icons.zip#Amicons icons ${{ steps.meta.outputs.label }}"
0 commit comments