Skip to content

Commit f60a087

Browse files
committed
Automate package publishing via CI/CD
1 parent a98b1c5 commit f60a087

File tree

4 files changed

+78
-1
lines changed

4 files changed

+78
-1
lines changed

.github/workflows/prerelease.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Prerelease packages are published to the 'dev' tag on npm on every update to main
2+
name: Publish prerelease package
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
9+
permissions:
10+
id-token: write
11+
12+
jobs:
13+
prerelease:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- uses: actions/setup-node@v4
21+
with:
22+
node-version: 24
23+
registry-url: 'https://registry.npmjs.org/'
24+
25+
- name: Install dependencies
26+
run: npm ci
27+
28+
- name: Bump prerelease version based on latest stable version tag
29+
id: latest
30+
run: |
31+
LATEST_TAG=$(git tag --list "v*.*.*" --sort=-v:refname | grep -v '-' | head -n1)
32+
npm version "$${LATEST_TAG#v}" --no-git-tag-version
33+
npm version prerelease --preid="dev.${{ github.sha::7 }}" --no-git-tag-version
34+
echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
35+
36+
- name: Publish prerelease to npm (with 'dev' tag)
37+
env:
38+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
39+
run: npm publish --tag dev --access public

.github/workflows/release.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Stable packages are published to the npm registry by pushing a tag matching the pattern 'v*.*.*'
2+
name: Publish stable release package
3+
4+
on:
5+
push:
6+
tags:
7+
- 'v*.*.*'
8+
9+
permissions:
10+
id-token: write
11+
12+
jobs:
13+
release:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- uses: actions/setup-node@v4
21+
with:
22+
node-version: 24
23+
registry-url: 'https://registry.npmjs.org/'
24+
25+
- name: Install dependencies
26+
run: npm ci
27+
28+
- name: Set version from tag
29+
run: |
30+
# Strip prefix from current tag to get version number
31+
VERSION=${GITHUB_REF#refs/tags/v}
32+
npm version "$VERSION" --no-git-tag-version
33+
echo "Setting version to $VERSION"
34+
35+
- name: Publish stable version to npm
36+
env:
37+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
38+
run: npm publish --access public

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "volview",
3-
"version": "4.4.0",
3+
"version": "0.0.0",
44
"type": "module",
55
"scripts": {
66
"dev": "cross-env VITE_SHOW_SAMPLE_DATA=true vite",

0 commit comments

Comments
 (0)