File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Release to npm
2+
3+ on :
4+ release :
5+ types : [published]
6+
7+ workflow_dispatch :
8+ inputs :
9+ version :
10+ description : " Version to publish (e.g., 0.8.6). If not provided, uses git tag."
11+ required : false
12+ type : string
13+
114jobs :
215 publish :
316 runs-on : ubuntu-latest
417 permissions :
518 contents : read
6- id-token : write # Needed for --provenance signing
19+ id-token : write
720
821 steps :
9- - uses : actions/checkout@v4
10- - uses : actions/setup-node@v4
22+ - name : Checkout code
23+ uses : actions/checkout@v4
24+ with :
25+ submodules : recursive
26+
27+ - name : Setup Node.js
28+ uses : actions/setup-node@v4
1129 with :
1230 node-version : " 22"
1331 registry-url : " https://registry.npmjs.org"
1432
15- - run : npm ci
16- - run : npm run build:release
33+ - name : Set version from tag or input
34+ run : |
35+ if [[ -n "${{ inputs.version }}" ]]; then
36+ INPUT_VERSION="${{ inputs.version }}"
37+ VERSION=${INPUT_VERSION#v}
38+ echo "Using version from workflow input: $VERSION"
39+ elif [[ "$GITHUB_REF" == refs/tags/* ]]; then
40+ TAG_VERSION=${GITHUB_REF#refs/tags/}
41+ VERSION=${TAG_VERSION#v}
42+ echo "Using version from git tag: $VERSION"
43+ else
44+ echo "No version provided and not building from a tag, using default 0.0.0"
45+ VERSION="0.0.0"
46+ fi
47+
48+ echo "Setting version to: $VERSION"
49+ npm --no-git-tag-version version "$VERSION" || exit 1
50+ echo "PACKAGE_VERSION=$VERSION" >> $GITHUB_ENV
51+
52+ - name : Install dependencies
53+ run : npm ci
54+
55+ - name : Build
56+ run : |
57+ echo "Building version: $PACKAGE_VERSION"
58+ npm run codegen
59+ npm run build:release
1760
1861 - name : Publish to NPM
1962 run : npm publish --provenance --access public
You can’t perform that action at this time.
0 commit comments