22name : Publish NPM Package
33
44on :
5- # For staging releases
5+ # For staging/nightly releases
66 workflow_dispatch :
7+ inputs :
8+ tag :
9+ description : ' NPM tag to publish (latest or nightly)'
10+ required : true
11+ type : choice
12+ options :
13+ - latest
14+ - nightly
15+ default : nightly
716 # For latest releases
817 release :
918 types : [published]
@@ -14,32 +23,38 @@ permissions:
1423 contents : read
1524
1625jobs :
17- set-staging -version :
18- # Only run for manual dispatch on main branch
19- if : ${{ github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' }}
26+ set-publish -version :
27+ # Run for manual dispatch on any branch (allows nightly releases from any branch)
28+ if : ${{ github.event_name == 'workflow_dispatch' }}
2029 runs-on : ubuntu-latest
2130 steps :
2231 - name : Checkout code
2332 uses : actions/checkout@v4
2433 - name : Set up Node.js
2534 uses : actions/setup-node@v4
2635 - name : Set publish version
27- id : set-staging -version
36+ id : set-publish -version
2837 run : |
2938 CURRENT_VERSION=$(npm pkg get version | tr -d '"')
30- NIGHTLY_VERSION="${CURRENT_VERSION}-nightly-${GITHUB_SHA::7}"
31- echo "VERSION=${NIGHTLY_VERSION}" >> $GITHUB_OUTPUT
39+ TAG="${{ github.event.inputs.tag || 'nightly' }}"
40+ # For nightly tag, append commit SHA to version
41+ if [ "$TAG" == "nightly" ]; then
42+ NIGHTLY_VERSION="${CURRENT_VERSION}-nightly-${GITHUB_SHA::7}"
43+ echo "VERSION=${NIGHTLY_VERSION}" >> $GITHUB_OUTPUT
44+ else
45+ echo "VERSION=${CURRENT_VERSION}" >> $GITHUB_OUTPUT
46+ fi
3247 outputs :
33- VERSION : ${{ steps.set-staging -version.outputs.VERSION }}
48+ VERSION : ${{ steps.set-publish -version.outputs.VERSION }}
3449
3550 publish-npm-staging :
36- # Only run for manual dispatch on main branch
37- if : ${{ github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' }}
51+ # Run for manual dispatch on any branch (allows nightly releases from any branch)
52+ if : ${{ github.event_name == 'workflow_dispatch' }}
3853 uses : ./.github/workflows/reusable-sdk-npm.yml
39- needs : set-staging -version
54+ needs : set-publish -version
4055 with :
4156 tag : ${{ github.event.inputs.tag }}
42- version : ${{ needs.set-staging -version.outputs.VERSION }}
57+ version : ${{ needs.set-publish -version.outputs.VERSION }}
4358
4459 publish-npm-latest :
4560 # # Only run for release published with tag "web3telegram-v*"
0 commit comments