Skip to content

Commit 9269dbc

Browse files
committed
ci: add GitHub Actions workflow for npm publishing
1 parent 3612e63 commit 9269dbc

1 file changed

Lines changed: 63 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Publish to npm
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
dry-run:
7+
description: 'Run in dry-run mode (no actual publish)'
8+
required: false
9+
default: false
10+
type: boolean
11+
otp:
12+
description: 'npm OTP code (if 2FA is enabled)'
13+
required: false
14+
type: string
15+
16+
permissions:
17+
contents: read
18+
id-token: write
19+
20+
jobs:
21+
publish:
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v6
27+
with:
28+
fetch-depth: 0
29+
30+
- name: Setup Node.js
31+
uses: actions/setup-node@v6
32+
with:
33+
node-version: '24.x'
34+
registry-url: 'https://registry.npmjs.org'
35+
36+
- name: Install dependencies
37+
run: |
38+
npm i -g npm
39+
npm ci
40+
41+
- name: Build packages
42+
run: npm run build
43+
44+
- name: Run tests
45+
run: npm run test
46+
47+
- name: Publish packages (dry-run)
48+
if: ${{ inputs.dry-run == true || inputs.dry-run == 'true' }}
49+
run: npx lerna publish from-package --no-private --yes --no-git-tag-version --no-push
50+
env:
51+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
52+
npm_config_dry_run: true
53+
54+
- name: Publish packages
55+
if: ${{ inputs.dry-run == false || inputs.dry-run == 'false' }}
56+
run: |
57+
if [ -n "${{ inputs.otp }}" ]; then
58+
npx lerna publish from-package --no-private --yes --otp ${{ inputs.otp }}
59+
else
60+
npx lerna publish from-package --no-private --yes
61+
fi
62+
env:
63+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)