Skip to content

Commit f8504d2

Browse files
committed
ci: add GitHub Actions workflow to publish CLI to npm on cli-v* tags
1 parent dc79b5c commit f8504d2

1 file changed

Lines changed: 64 additions & 0 deletions

File tree

.github/workflows/publish-cli.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Publish CLI to npm
2+
3+
on:
4+
push:
5+
tags:
6+
- 'cli-v*'
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
id-token: write
12+
13+
jobs:
14+
publish:
15+
runs-on: ubuntu-latest
16+
defaults:
17+
run:
18+
working-directory: cli
19+
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Setup Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: 22
28+
registry-url: https://registry.npmjs.org
29+
30+
- name: Install dependencies
31+
run: npm ci
32+
33+
- name: Build
34+
run: npm run build
35+
36+
- name: Verify binary
37+
run: |
38+
head -1 dist/index.js | grep -q "#!/usr/bin/env node"
39+
node dist/index.js --version
40+
41+
- name: Publish to npm
42+
run: npm publish --access public --provenance
43+
env:
44+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
45+
46+
- name: Create GitHub Release
47+
if: startsWith(github.ref, 'refs/tags/')
48+
env:
49+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
run: |
51+
VERSION="${GITHUB_REF#refs/tags/cli-v}"
52+
gh release create "$GITHUB_REF_NAME" \
53+
--title "shader-cli v${VERSION}" \
54+
--notes "## Install
55+
56+
\`\`\`bash
57+
npm i -g @resciencelab/shader-cli@${VERSION}
58+
\`\`\`
59+
60+
Or use without install:
61+
\`\`\`bash
62+
npx @resciencelab/shader-cli@${VERSION}
63+
\`\`\`" \
64+
--repo "$GITHUB_REPOSITORY"

0 commit comments

Comments
 (0)