Skip to content

Commit 155e292

Browse files
ci: add npm publish workflow for SDK
1 parent 33559bb commit 155e292

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
27+
- name: Set publish version
28+
id: set-publish-version
29+
if: github.event.inputs.tag == 'nightly'
30+
run: |
31+
if [ "${{ github.event.inputs.tag }}" == "nightly" ]; then
32+
CURRENT_VERSION=$(npm pkg get version | tr -d '"')
33+
NIGHTLY_VERSION="${CURRENT_VERSION}-nightly-${GITHUB_SHA::7}"
34+
echo "VERSION=${NIGHTLY_VERSION}" >> $GITHUB_OUTPUT
35+
else
36+
echo "VERSION=$(npm pkg get version | tr -d '"')" >> $GITHUB_OUTPUT
37+
fi
38+
outputs:
39+
VERSION: ${{ steps.set-publish-version.outputs.VERSION }}
40+
41+
publish-npm:
42+
# Run only on main branch
43+
if: github.ref == 'refs/heads/main'
44+
uses: ./.github/workflows/reusable-npm.yml
45+
needs: set-publish-version
46+
with:
47+
tag: ${{ github.event.inputs.tag }}
48+
version: ${{ needs.set-publish-version.outputs.VERSION }}
49+
secrets:
50+
npm-token: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)