Skip to content

Commit 818bb29

Browse files
authored
Improved Publishing Process (#2)
**Pre-release**: If the Git tag matches `v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+` (e.g., `v1.0.0-alpha.1`), the version is taken from the tag, and the package is published as a pre-release. **Stable Release**: If the Git tag matches `v[0-9]+.[0-9]+.[0-9]+` (e.g., `v1.0.0`), the version is taken from `package.json` and published as the latest stable version.
1 parent 0eccd5b commit 818bb29

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

.github/workflows/npm.yaml

+16-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ name: Publish to npm
33
on:
44
push:
55
tags:
6-
- 'v[0-9]+.[0-9]+.[0-9]+*'
6+
- 'v[0-9]+.[0-9]+.[0-9]+'
7+
- 'v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+'
78

89
jobs:
910
build:
@@ -18,6 +19,19 @@ jobs:
1819
with:
1920
node-version: 20.x
2021
cache: 'npm'
22+
registry-url: 'https://registry.npmjs.org/'
23+
24+
- name: Determine pre-release tag
25+
id: release-tag
26+
run: |
27+
TAG_NAME=${GITHUB_REF#refs/tags/}
28+
echo "Detected tag: $TAG_NAME"
29+
if [[ "$TAG_NAME" == *-alpha.* ]]; then
30+
echo "tag=alpha" >> $GITHUB_ENV
31+
npm version --no-git-tag-version $TAG_NAME
32+
else
33+
echo "tag=latest" >> $GITHUB_ENV
34+
fi
2135
2236
- name: Install dependencies
2337
run: npm ci
@@ -29,6 +43,6 @@ jobs:
2943
run: npm run compile
3044

3145
- name: Publish
32-
run: npm publish --access public
46+
run: npm publish --access public --tag ${{ env.tag }}
3347
env:
3448
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)