Skip to content

Publish NPM Package

Publish NPM Package #1

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 releases
workflow_dispatch:
# For latest releases
release:
types: [published]
permissions:
id-token: write # Required for OIDC
packages: write
contents: read
jobs:
set-staging-version:
# Only run for manual dispatch on main branch
if: ${{ github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' }}
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-staging-version
run: |
CURRENT_VERSION=$(npm pkg get version | tr -d '"')
NIGHTLY_VERSION="${CURRENT_VERSION}-nightly-${GITHUB_SHA::7}"
echo "VERSION=${NIGHTLY_VERSION}" >> $GITHUB_OUTPUT
outputs:
VERSION: ${{ steps.set-staging-version.outputs.VERSION }}
publish-npm-staging:
# Only run for manual dispatch on main branch
if: ${{ github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' }}
uses: ./.github/workflows/reusable-sdk-npm.yml
needs: set-staging-version
with:
tag: ${{ github.event.inputs.tag }}
version: ${{ needs.set-staging-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'