Skip to content

Commit 560b272

Browse files
committed
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 <version>` then `git push --tags` Closes #719
1 parent 182fabe commit 560b272

1 file changed

Lines changed: 53 additions & 8 deletions

File tree

.github/workflows/release.yml

Lines changed: 53 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,63 @@ 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: Build
28+
run: vp run build
29+
30+
- name: Verify version matches tag
31+
run: |
32+
TAG_VERSION="${GITHUB_REF_NAME#v}"
33+
PKG_VERSION=$(node -p "require('./package.json').version")
34+
if [ "$TAG_VERSION" != "$PKG_VERSION" ]; then
35+
echo "::error::Tag version ($TAG_VERSION) does not match package.json version ($PKG_VERSION)"
36+
exit 1
37+
fi
38+
39+
- name: Determine npm dist-tag
40+
id: dist-tag
41+
run: |
42+
TAG_VERSION="${GITHUB_REF_NAME#v}"
43+
if echo "$TAG_VERSION" | grep -qE '-(alpha|beta|rc|next|dev)'; then
44+
# Extract pre-release identifier (e.g., "beta" from "5.0.0-beta.0")
45+
PRE_TAG=$(echo "$TAG_VERSION" | sed -E 's/.*-([a-zA-Z]+).*/\1/')
46+
echo "tag=$PRE_TAG" >> "$GITHUB_OUTPUT"
47+
else
48+
echo "tag=latest" >> "$GITHUB_OUTPUT"
49+
fi
50+
51+
- name: Setup Node.js for npm publish
52+
uses: actions/setup-node@v6
53+
with:
54+
node-version: '22'
55+
registry-url: 'https://registry.npmjs.org'
56+
57+
- name: Publish to npm
58+
run: npm publish --access public --tag ${{ steps.dist-tag.outputs.tag }}
59+
60+
- name: Create GitHub Release
61+
uses: softprops/action-gh-release@v2
62+
with:
63+
generate_release_notes: true
64+
prerelease: ${{ steps.dist-tag.outputs.tag != 'latest' }}

0 commit comments

Comments
 (0)