Skip to content

Commit b37563f

Browse files
authored
chore(ci): trigger release workflow by git tag push (#721)
## Summary - Replace semantic-release (triggered on master push) with a self-contained tag-triggered release workflow - Supports pre-release dist-tags: `v5.0.0-beta.0` publishes with `--tag beta`, `v5.0.0-alpha.1` with `--tag alpha`, etc. - Adds version-tag mismatch guard to prevent accidental publishes - Creates GitHub Releases automatically (with prerelease flag for non-stable versions) ## Release process after merge ```bash # Stable release npm version patch # or minor/major git push origin master --tags # Pre-release npm version 5.0.0-beta.0 git push origin master --tags ``` ## Note Update the OIDC Trusted Publisher configuration on npmjs.com to point to `release.yml` in this repo. Closes #719 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Release workflow now runs on pushed version tags, builds the project, enforces exact version/tag matching, maps prerelease tags to npm dist-tags, publishes to npm, creates GitHub Releases (marking prereleases), and tightens workflow permissions. * **Documentation** * README updated with release instructions and examples for bumping versions, tagging, and publishing stable and prerelease releases. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 182fabe commit b37563f

2 files changed

Lines changed: 60 additions & 8 deletions

File tree

.github/workflows/release.yml

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,54 @@ name: Release
22

33
on:
44
push:
5-
branches: [master]
5+
tags:
6+
- 'v*'
67

78
permissions:
89
contents: write
9-
deployments: write
10-
issues: write
11-
pull-requests: write
1210
id-token: write
1311

1412
jobs:
1513
release:
16-
name: NPM
17-
uses: node-modules/github-actions/.github/workflows/npm-release.yml@master
18-
secrets:
19-
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
14+
name: Publish to NPM
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v6
19+
20+
- name: Setup Vite+
21+
uses: voidzero-dev/setup-vp@v1
22+
with:
23+
node-version: '22'
24+
cache: true
25+
run-install: true
26+
27+
- name: Verify version matches tag
28+
run: |
29+
TAG_VERSION="${GITHUB_REF_NAME#v}"
30+
PKG_VERSION=$(node -p "require('./package.json').version")
31+
if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
32+
echo "::error::Tag version ($TAG_VERSION) does not match package.json version ($PKG_VERSION)"
33+
exit 1
34+
fi
35+
36+
- name: Determine npm dist-tag
37+
id: dist-tag
38+
run: |
39+
TAG_VERSION="${GITHUB_REF_NAME#v}"
40+
if echo "$TAG_VERSION" | grep -qE '-([a-zA-Z]+)'; then
41+
# Extract pre-release identifier (e.g., "beta" from "5.0.0-beta.0")
42+
PRE_TAG=$(echo "$TAG_VERSION" | sed -E 's/.*-([a-zA-Z]+).*/\1/')
43+
echo "tag=$PRE_TAG" >> "$GITHUB_OUTPUT"
44+
else
45+
echo "tag=latest" >> "$GITHUB_OUTPUT"
46+
fi
47+
48+
- name: Publish to npm
49+
run: npm publish --access public --tag ${{ steps.dist-tag.outputs.tag }}
50+
51+
- name: Create GitHub Release
52+
uses: softprops/action-gh-release@v2
53+
with:
54+
generate_release_notes: true
55+
prerelease: ${{ steps.dist-tag.outputs.tag != 'latest' }}

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,22 @@ Node.js v22.3.0
343343
└─────────┴───────────────────────┴─────────┴────────────────────┴────────────┴─────────────────────────┘
344344
```
345345

346+
## Release
347+
348+
Use `npm version` to bump the version, create a git tag, and push to trigger the release workflow.
349+
350+
```bash
351+
# Stable release
352+
npm version patch # or minor, major
353+
git push origin master --tags
354+
355+
# Pre-release (beta, alpha, rc, etc.)
356+
npm version 5.0.0-beta.0
357+
git push origin master --tags
358+
```
359+
360+
The [release workflow](.github/workflows/release.yml) will automatically publish to npm and create a GitHub Release when a `v*` tag is pushed. Pre-release tags (e.g., `v5.0.0-beta.0`) are published with the corresponding dist-tag (`beta`, `alpha`, `rc`, etc.).
361+
346362
## License
347363

348364
[MIT](LICENSE)

0 commit comments

Comments
 (0)