Skip to content

Commit 80ee22f

Browse files
committed
ci: switch release flow to PR-based tagging
1 parent 9f8be84 commit 80ee22f

3 files changed

Lines changed: 64 additions & 13 deletions

File tree

.github/workflows/release-tag.yml

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Release Tag
1+
name: Release PR
22

33
on:
44
workflow_dispatch:
@@ -15,13 +15,15 @@ on:
1515

1616
permissions:
1717
contents: write
18+
pull-requests: write
1819

1920
jobs:
2021
release:
2122
runs-on: ubuntu-latest
2223
steps:
2324
- name: Ensure main branch
2425
run: test "${{ github.ref_name }}" = "main"
26+
2527
- name: Checkout
2628
uses: actions/checkout@v4
2729
with:
@@ -53,14 +55,31 @@ jobs:
5355
git config user.name "github-actions[bot]"
5456
git config user.email "github-actions[bot]@users.noreply.github.com"
5557
56-
- name: Bump version and create tag
58+
- name: Bump version
5759
id: bump
5860
run: |
59-
NEW_VERSION=$(npm version ${{ github.event.inputs.bump }} -m "chore(release): %s [skip ci]")
60-
echo "version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
61+
npm version ${{ github.event.inputs.bump }} --no-git-tag-version
62+
VERSION="v$(node -p \"require('./package.json').version\")"
63+
BRANCH="release/${VERSION}"
64+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
65+
echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"
66+
67+
- name: Commit version bump
68+
run: |
69+
git checkout -b "${{ steps.bump.outputs.branch }}"
70+
git add package.json
71+
git commit -m "chore(release): ${{ steps.bump.outputs.version }} [skip ci]"
6172
62-
- name: Push release commit and tag
63-
run: git push origin HEAD:${{ github.ref_name }} --follow-tags
73+
- name: Push release branch
74+
run: git push -u origin "${{ steps.bump.outputs.branch }}"
6475

65-
- name: Release summary
66-
run: echo "Created and pushed ${{ steps.bump.outputs.version }}"
76+
- name: Create release pull request
77+
env:
78+
GH_TOKEN: ${{ github.token }}
79+
run: |
80+
gh pr create \
81+
--base main \
82+
--head "${{ steps.bump.outputs.branch }}" \
83+
--title "chore(release): ${{ steps.bump.outputs.version }}" \
84+
--body "Automated release bump for ${{ steps.bump.outputs.version }}.\n\n- Verification passed (lint, typecheck, build, test)\n- Merge this PR to create and publish tag automatically" \
85+
--assignee "${{ github.actor }}"

.github/workflows/tag-release.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Tag Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
tag:
13+
runs-on: ubuntu-latest
14+
if: startsWith(github.event.head_commit.message, 'chore(release): v')
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- name: Create and push tag
22+
run: |
23+
VERSION="v$(node -p \"require('./package.json').version\")"
24+
if git ls-remote --tags origin | grep -q "refs/tags/${VERSION}$"; then
25+
echo "Tag ${VERSION} already exists; skipping"
26+
exit 0
27+
fi
28+
git config user.name "github-actions[bot]"
29+
git config user.email "github-actions[bot]@users.noreply.github.com"
30+
git tag "${VERSION}" -m "Release ${VERSION}"
31+
git push origin "${VERSION}"

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,18 +241,19 @@ Publishing is automated and **only happens on `v*` tags**.
241241
- `CI` workflow runs on every PR and push to `main`:
242242
- lint → typecheck → build → test
243243

244-
### Create a release (auto bump + auto tag)
244+
### Create a release (auto bump + PR + auto tag)
245245

246-
1. Open GitHub Actions → `Release Tag`.
246+
1. Open GitHub Actions → `Release PR`.
247247
2. Click **Run workflow** on `main`.
248248
3. Select bump type: `patch` | `minor` | `major`.
249+
4. Merge the generated release PR.
249250

250-
`Release Tag` will:
251+
`Release PR` will:
251252
- run lint → typecheck → build → test
252253
- bump `package.json` version
253-
- create and push `vX.Y.Z` tag
254+
- open a release PR assigned to the workflow runner
254255

255-
Pushing that tag triggers `Publish to npm`, which runs checks again and publishes.
256+
After merge, `Tag Release` creates and pushes `vX.Y.Z`, which triggers `Publish to npm`.
256257

257258
## Contributing
258259

0 commit comments

Comments
 (0)