Publish to npm #16
Workflow file for this run
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
| name: Publish NPM Libraries | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| mode: | |
| description: Release mode | |
| required: true | |
| default: dry-run | |
| type: choice | |
| options: | |
| - dry-run | |
| - publish | |
| permissions: | |
| contents: write | |
| id-token: write | |
| concurrency: | |
| group: publish-libs-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| publish: | |
| name: Version and publish libraries | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Ensure publish runs from main | |
| if: github.event.inputs.mode == 'publish' && github.ref_name != 'main' | |
| run: | | |
| echo "This workflow must be dispatched from the main branch." | |
| exit 1 | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| ssh-key: ${{ secrets.RELEASE_DEPLOY_KEY }} | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: "24" | |
| registry-url: https://registry.npmjs.org | |
| - name: Verify trusted publishing runtime requirements | |
| run: | | |
| node --version | |
| npm --version | |
| node -e "const [major, minor] = process.versions.node.split('.').map(Number); if (major < 22 || (major === 22 && minor < 14)) process.exit(1)" | |
| node -e "const version = require('child_process').execSync('npm --version', { encoding: 'utf8' }).trim().split('.').map(Number); if (version[0] < 11 || (version[0] === 11 && version[1] < 5) || (version[0] === 11 && version[1] === 5 && version[2] < 1)) process.exit(1)" | |
| - name: Install dependencies | |
| run: bun install --frozen-lockfile | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@v1 | |
| with: | |
| toolchain: stable | |
| targets: wasm32-unknown-unknown | |
| - name: Install wasm-pack | |
| uses: jetli/wasm-pack-action@v0.4.0 | |
| with: | |
| version: v0.13.1 | |
| - name: Configure Git author | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| - name: Ensure release plans exist | |
| run: | | |
| shopt -s nullglob | |
| plans=(.nx/version-plans/*.md) | |
| if [ ${#plans[@]} -eq 0 ]; then | |
| echo "No release plans were found in .nx/version-plans." | |
| exit 1 | |
| fi | |
| - name: Create release commit and tags | |
| run: bunx nx release --skip-publish --preid alpha | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Dry-run publish packages to npm | |
| if: github.event.inputs.mode == 'dry-run' | |
| run: npx nx release publish --dry-run | |
| - name: Push release commit and tags | |
| if: github.event.inputs.mode == 'publish' | |
| run: git push origin HEAD:main --follow-tags | |
| - name: Publish packages to npm | |
| if: github.event.inputs.mode == 'publish' | |
| run: npx nx release publish |