File tree Expand file tree Collapse file tree 2 files changed +63
-22
lines changed
Expand file tree Collapse file tree 2 files changed +63
-22
lines changed Original file line number Diff line number Diff line change 1+ name : Release PR β¬οΈ
2+
3+ on :
4+ workflow_dispatch :
5+ inputs :
6+ bump :
7+ description : " Version bump type (patch/minor/major)"
8+ required : true
9+ type : choice
10+ default : patch
11+ options :
12+ - patch
13+ - minor
14+ - major
15+
16+ jobs :
17+ release-pr :
18+ runs-on : ubuntu-latest
19+ permissions :
20+ contents : write
21+ pull-requests : write
22+ steps :
23+ - uses : actions/checkout@v6
24+ with :
25+ fetch-depth : 0
26+
27+ - uses : fregante/setup-git-user@v2
28+
29+ - name : Bump version
30+ run : npm version ${{ inputs.bump }} --no-git-tag-version # --no-git-tag-version: skip auto commit and tag, only modify package.json
31+
32+ - name : Create Pull Request
33+ id : create-pr
34+ env :
35+ GH_TOKEN : ${{ github.token }}
36+ run : |
37+ VERSION=$(jq -r '.version' package.json)
38+ BRANCH="release/v${VERSION}"
39+ echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"
40+
41+ LAST_TAG=$(git describe --tags --abbrev=0)
42+ BODY=$(git log ${LAST_TAG}..HEAD --oneline | grep -oE "#[0-9]+" | sort -u | sed 's/^/- /')
43+
44+ git switch -c "$BRANCH" origin/main
45+ git commit -am "release: v${VERSION}"
46+ git push origin "$BRANCH"
47+
48+ gh pr create --title "release: v${VERSION}" --body "$BODY"
49+
50+ - name : Cleanup on failure
51+ if : failure()
52+ run : git push origin --delete "${{ steps.create-pr.outputs.branch }}" || true
Original file line number Diff line number Diff line change 11name : Tagging π·οΈ
22
33on :
4- workflow_dispatch :
5- inputs :
6- bump :
7- description : " Version bump type (patch/minor/major)"
8- required : true
9- type : choice
10- default : patch
11- options :
12- - patch
13- - minor
14- - major
4+ pull_request :
5+ types : [closed]
6+ branches : [main]
157
168jobs :
179 create-tag :
10+ if : github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/')
1811 runs-on : ubuntu-latest
1912 permissions :
2013 contents : write
2114 steps :
2215 - uses : actions/checkout@v6
2316
24- - uses : fregante/setup-git-user@v2
25-
26- - name : Bump version
27- run : npm version ${{ inputs.bump }}
28-
29- - name : Push changes
30- run : git push --follow-tags
31-
32- - name : Draft release
17+ - name : Create tag and release
3318 env :
3419 GH_TOKEN : ${{ github.token }}
3520 run : |
36- NEW_VERSION="v$(jq -r '.version' package.json)"
37- gh release create $NEW_VERSION --draft --generate-notes
21+ VERSION="v$(jq -r '.version' package.json)"
22+
23+ git tag "$VERSION"
24+ git push origin "$VERSION"
25+
26+ gh release create "$VERSION" --draft --generate-notes
You canβt perform that action at this time.
0 commit comments