Publish NPM Package #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ⚠️ 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: | |
| # Run for manual dispatch on any branch (nightly releases) | |
| 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-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 | |
| # Set default tag to 'nightly' if not provided | |
| TAG="${{ github.event.inputs.tag }}" | |
| if [ -z "$TAG" ]; then | |
| TAG="nightly" | |
| fi | |
| echo "TAG=${TAG}" >> $GITHUB_OUTPUT | |
| outputs: | |
| VERSION: ${{ steps.set-staging-version.outputs.VERSION }} | |
| TAG: ${{ steps.set-staging-version.outputs.TAG }} | |
| publish-npm-staging: | |
| # Run for manual dispatch on any branch (nightly releases) | |
| if: ${{ github.event_name == 'workflow_dispatch' }} | |
| uses: ./.github/workflows/reusable-npm.yml | |
| needs: set-staging-version | |
| with: | |
| tag: ${{ needs.set-staging-version.outputs.TAG }} | |
| version: ${{ needs.set-staging-version.outputs.VERSION }} | |
| publish-npm-latest: | |
| # # Only run for release published with tag "web3mail-v*" | |
| if: ${{ github.event_name == 'release' && startsWith(github.ref_name,'web3mail-v') }} | |
| uses: ./.github/workflows/reusable-npm.yml | |
| with: | |
| tag: 'latest' |