Skip to content

Commit 1777381

Browse files
ci: add npm publish workflow for SDK (#205)
* ci: add npm publish workflow for SDK * ci: specify node 20 for npm publish workflow * ci: refactor version output to support nightly and latest tags
1 parent 33559bb commit 1777381

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: publish-npm-sdk
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: 'npm publish tag (e.g., latest, nightly)'
8+
required: true
9+
type: choice
10+
options:
11+
- latest
12+
- nightly
13+
default: nightly
14+
15+
jobs:
16+
set-publish-version:
17+
# Run only on main branch
18+
if: github.ref == 'refs/heads/main'
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Set up Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: '20'
28+
29+
- name: Set publish version
30+
id: set-publish-version
31+
run: |
32+
CURRENT_VERSION=$(npm pkg get version | tr -d '"')
33+
if [ "${{ github.event.inputs.tag }}" == "nightly" ]; then
34+
NIGHTLY_VERSION="${CURRENT_VERSION}-nightly-${GITHUB_SHA}"
35+
echo "VERSION=${NIGHTLY_VERSION}" >> $GITHUB_OUTPUT
36+
else
37+
echo "VERSION=${CURRENT_VERSION}" >> $GITHUB_OUTPUT
38+
fi
39+
outputs:
40+
VERSION: ${{ steps.set-publish-version.outputs.VERSION }}
41+
42+
publish-npm:
43+
# Run only on main branch
44+
if: github.ref == 'refs/heads/main'
45+
uses: ./.github/workflows/reusable-npm.yml
46+
needs: set-publish-version
47+
with:
48+
tag: ${{ github.event.inputs.tag }}
49+
version: ${{ needs.set-publish-version.outputs.VERSION }}
50+
secrets:
51+
npm-token: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)