Skip to content

Commit 9d6f9e8

Browse files
committed
chore(ci): add NPM auto-publish workflow
1 parent a98b1c5 commit 9d6f9e8

4 files changed

Lines changed: 107 additions & 2 deletions

File tree

.github/workflows/bump-version.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Bump Version Tag
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
jobs:
8+
bump-version:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
steps:
13+
- uses: actions/checkout@v5
14+
with:
15+
fetch-depth: 0
16+
17+
- uses: actions/setup-node@v6
18+
with:
19+
node-version: '24'
20+
21+
- name: Get latest version tag
22+
id: get_version
23+
run: |
24+
git fetch --tags
25+
LATEST_TAG=$(git tag -l "v*" | sort -V | tail -n 1)
26+
if [ -z "$LATEST_TAG" ]; then
27+
echo "latest=v0.0.0" >> $GITHUB_OUTPUT
28+
else
29+
echo "latest=$LATEST_TAG" >> $GITHUB_OUTPUT
30+
fi
31+
32+
- name: Bump patch version
33+
id: bump_version
34+
run: |
35+
LATEST_VERSION="${{ steps.get_version.outputs.latest }}"
36+
VERSION_NUMBER="${LATEST_VERSION#v}"
37+
38+
echo "$VERSION_NUMBER" > VERSION_TEMP
39+
npm version --no-git-tag-version $VERSION_NUMBER
40+
npm version --no-git-tag-version patch
41+
42+
NEW_VERSION=$(node -p "require('./package.json').version")
43+
echo "new_version=v$NEW_VERSION" >> $GITHUB_OUTPUT
44+
45+
- name: Create and push tag
46+
run: |
47+
git config user.name "github-actions[bot]"
48+
git config user.email "github-actions[bot]@users.noreply.github.com"
49+
git tag ${{ steps.bump_version.outputs.new_version }}
50+
git push origin ${{ steps.bump_version.outputs.new_version }}

.github/workflows/publish-npm.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Publish to NPM
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v[0-9]+.[0-9]+.[0-9]+'
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
id-token: write
14+
steps:
15+
- uses: actions/checkout@v5
16+
17+
- uses: actions/setup-node@v6
18+
with:
19+
node-version: '24'
20+
registry-url: 'https://registry.npmjs.org'
21+
22+
- name: Extract version from tag
23+
id: get_version
24+
run: |
25+
VERSION="${GITHUB_REF#refs/tags/v}"
26+
echo "version=$VERSION" >> $GITHUB_OUTPUT
27+
28+
- name: Update package.json version
29+
run: npm version --no-git-tag-version ${{ steps.get_version.outputs.version }}
30+
31+
- run: npm ci
32+
- run: npm run postinstall
33+
34+
- name: Build with remote save enabled
35+
run: VITE_REMOTE_SERVER_URL= VITE_ENABLE_REMOTE_SAVE=true npm run build
36+
37+
- run: npm publish --provenance --access public

CONTRIBUTING.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
Before you begin, make sure your environment matches the following versions:
66

7-
- **Node.js**: >= 18.20.0 (20.x LTS recommended)
7+
- **Node.js**: >= 18.20.0 (20.x LTS recommended)
88
- **npm**: >= 9.x (npm 10+ works with Node 20)
99

1010
Check your versions:
@@ -22,7 +22,6 @@ For reproducible installs, use:
2222
npm ci
2323
```
2424

25-
2625
---
2726

2827
## Dependencies
@@ -97,6 +96,24 @@ npm run test:e2e:dev -- -- --spec ./tests/specs/remote-manifest.e2e.ts
9796

9897
---
9998

99+
## NPM Publishing
100+
101+
Merging to `main` automatically publishes to NPM:
102+
103+
1. Merge creates a patch version tag (v4.4.1, v4.4.2, etc.)
104+
2. Tag triggers automatic NPM publish
105+
106+
For minor/major releases, manually create a tag:
107+
108+
```bash
109+
git tag v4.5.0 # or v5.0.0
110+
git push origin v4.5.0
111+
```
112+
113+
To update https://volview.kitware.app/, merge to the `stable` branch.
114+
115+
---
116+
100117
## Developing with VTK.js
101118

102119
Follow these steps to develop against a custom development branch of VTK.js:

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "volview",
33
"version": "4.4.0",
44
"type": "module",
5+
"files": ["dist", "src"],
56
"scripts": {
67
"dev": "cross-env VITE_SHOW_SAMPLE_DATA=true vite",
78
"preview": "vite preview",

0 commit comments

Comments
 (0)