Skip to content

Commit d69bb0a

Browse files
authored
Merge pull request #727 from DaleStudy/725-release-pr
λ‹€μ‹œ 릴리즈 PR μ‚¬μš©ν•˜λ„λ‘ Tagging μ›Œν¬ν”Œλ‘œμš° λ³€κ²½
2 parents 8f8a875 + 4509b12 commit d69bb0a

File tree

2 files changed

+63
-22
lines changed

2 files changed

+63
-22
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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
Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,26 @@
11
name: Tagging 🏷️
22

33
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
4+
pull_request:
5+
types: [closed]
6+
branches: [main]
157

168
jobs:
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

0 commit comments

Comments
Β (0)