Skip to content

Publish NPM Package

Publish NPM Package #2

Workflow file for this run

# ⚠️ THIS WORKFLOW IS THE TRUSTED PUBLISHER CONFIGURED ON NPMJS.COM, DO NOT RENAME OR DELETE THIS FILE ⚠️
name: Publish NPM Package
on:
# For staging/nightly releases
workflow_dispatch:
inputs:
tag:
description: 'NPM tag to publish (latest or nightly)'
required: true
type: choice
options:
- latest
- nightly
default: nightly
# For latest releases
release:
types: [published]
permissions:
id-token: write # Required for OIDC
packages: write
contents: read
jobs:
set-publish-version:
# Run for manual dispatch on any branch (allows nightly releases from any branch)
if: ${{ github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
- name: Set publish version
id: set-publish-version
run: |
CURRENT_VERSION=$(npm pkg get version | tr -d '"')
TAG="${{ github.event.inputs.tag || 'nightly' }}"
# For nightly tag, append commit SHA to version
if [ "$TAG" == "nightly" ]; then
NIGHTLY_VERSION="${CURRENT_VERSION}-nightly-${GITHUB_SHA::7}"
echo "VERSION=${NIGHTLY_VERSION}" >> $GITHUB_OUTPUT
else
echo "VERSION=${CURRENT_VERSION}" >> $GITHUB_OUTPUT
fi
outputs:
VERSION: ${{ steps.set-publish-version.outputs.VERSION }}
publish-npm-staging:
# Run for manual dispatch on any branch (allows nightly releases from any branch)
if: ${{ github.event_name == 'workflow_dispatch' }}
uses: ./.github/workflows/reusable-sdk-npm.yml
needs: set-publish-version
with:
tag: ${{ github.event.inputs.tag }}
version: ${{ needs.set-publish-version.outputs.VERSION }}
publish-npm-latest:
# # Only run for release published with tag "web3telegram-v*"
if: ${{ github.event_name == 'release' && startsWith(github.ref_name,'web3telegram-v') }}
uses: ./.github/workflows/reusable-sdk-npm.yml
with:
tag: 'latest'