From 560b272fb5f10bacaa82791916f598d954d9615e Mon Sep 17 00:00:00 2001 From: MK Date: Sun, 29 Mar 2026 18:26:37 +0800 Subject: [PATCH 1/5] feat: trigger release workflow by git tag push Replace semantic-release on master push with a self-contained tag-triggered workflow. Supports pre-release dist-tags (beta, alpha, rc, next, dev) and creates GitHub Releases automatically. Release process: `npm version ` then `git push --tags` Closes #719 --- .github/workflows/release.yml | 61 ++++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6365e80a..37fd6527 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,18 +2,63 @@ name: Release on: push: - branches: [master] + tags: + - 'v*' permissions: contents: write - deployments: write - issues: write - pull-requests: write id-token: write jobs: release: - name: NPM - uses: node-modules/github-actions/.github/workflows/npm-release.yml@master - secrets: - GIT_TOKEN: ${{ secrets.GIT_TOKEN }} + name: Publish to NPM + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v6 + + - name: Setup Vite+ + uses: voidzero-dev/setup-vp@v1 + with: + node-version: '22' + cache: true + run-install: true + + - name: Build + run: vp run build + + - name: Verify version matches tag + run: | + TAG_VERSION="${GITHUB_REF_NAME#v}" + PKG_VERSION=$(node -p "require('./package.json').version") + if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then + echo "::error::Tag version ($TAG_VERSION) does not match package.json version ($PKG_VERSION)" + exit 1 + fi + + - name: Determine npm dist-tag + id: dist-tag + run: | + TAG_VERSION="${GITHUB_REF_NAME#v}" + if echo "$TAG_VERSION" | grep -qE '-(alpha|beta|rc|next|dev)'; then + # Extract pre-release identifier (e.g., "beta" from "5.0.0-beta.0") + PRE_TAG=$(echo "$TAG_VERSION" | sed -E 's/.*-([a-zA-Z]+).*/\1/') + echo "tag=$PRE_TAG" >> "$GITHUB_OUTPUT" + else + echo "tag=latest" >> "$GITHUB_OUTPUT" + fi + + - name: Setup Node.js for npm publish + uses: actions/setup-node@v6 + with: + node-version: '22' + registry-url: 'https://registry.npmjs.org' + + - name: Publish to npm + run: npm publish --access public --tag ${{ steps.dist-tag.outputs.tag }} + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + generate_release_notes: true + prerelease: ${{ steps.dist-tag.outputs.tag != 'latest' }} From 921997e1cbaf7f3bda1a7bb1dac462e79263a432 Mon Sep 17 00:00:00 2001 From: MK Date: Sun, 29 Mar 2026 19:16:01 +0800 Subject: [PATCH 2/5] docs: add release instructions to README --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 77f49a0b..3147212a 100644 --- a/README.md +++ b/README.md @@ -343,6 +343,22 @@ Node.js v22.3.0 └─────────┴───────────────────────┴─────────┴────────────────────┴────────────┴─────────────────────────┘ ``` +## Release + +Use `npm version` to bump the version, create a git tag, and push to trigger the release workflow. + +```bash +# Stable release +npm version patch # or minor, major +git push origin master --tags + +# Pre-release (beta, alpha, rc, etc.) +npm version 5.0.0-beta.0 +git push origin master --tags +``` + +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.). + ## License [MIT](LICENSE) From 5ce15d6b1cfebf72a98d8ef1e985a605f4949522 Mon Sep 17 00:00:00 2001 From: MK Date: Sun, 29 Mar 2026 19:18:24 +0800 Subject: [PATCH 3/5] refactor: remove redundant actions/setup-node step --- .github/workflows/release.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 37fd6527..a1d1eb60 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -48,12 +48,6 @@ jobs: echo "tag=latest" >> "$GITHUB_OUTPUT" fi - - name: Setup Node.js for npm publish - uses: actions/setup-node@v6 - with: - node-version: '22' - registry-url: 'https://registry.npmjs.org' - - name: Publish to npm run: npm publish --access public --tag ${{ steps.dist-tag.outputs.tag }} From 58e709e86df36e04756dc2bb7ee80e09e75fbe3a Mon Sep 17 00:00:00 2001 From: MK Date: Sun, 29 Mar 2026 19:22:20 +0800 Subject: [PATCH 4/5] fix: detect any prerelease identifier instead of allowlist Any version with a hyphenated pre-release suffix (e.g., preview, canary) is now correctly published with its dist-tag and marked as prerelease. --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a1d1eb60..64efa160 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -40,7 +40,7 @@ jobs: id: dist-tag run: | TAG_VERSION="${GITHUB_REF_NAME#v}" - if echo "$TAG_VERSION" | grep -qE '-(alpha|beta|rc|next|dev)'; then + if echo "$TAG_VERSION" | grep -qE '-([a-zA-Z]+)'; then # Extract pre-release identifier (e.g., "beta" from "5.0.0-beta.0") PRE_TAG=$(echo "$TAG_VERSION" | sed -E 's/.*-([a-zA-Z]+).*/\1/') echo "tag=$PRE_TAG" >> "$GITHUB_OUTPUT" From e39e7d28ed4b159985f26f3a968ceea54611ca4e Mon Sep 17 00:00:00 2001 From: MK Date: Sun, 29 Mar 2026 19:48:58 +0800 Subject: [PATCH 5/5] refactor: remove explicit build step, rely on prepublishOnly --- .github/workflows/release.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 64efa160..ea7e228a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,9 +24,6 @@ jobs: cache: true run-install: true - - name: Build - run: vp run build - - name: Verify version matches tag run: | TAG_VERSION="${GITHUB_REF_NAME#v}"