Pump to 2.1.0 (#1547) #12
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: NPM Publish | |
| on: | |
| push: | |
| tags: | |
| # Match release tags (e.g. 1.9.0, 2.0.0) and prerelease tags | |
| # (e.g. 2.0.0-beta.0, 1.9.0-alpha.0, 2.0.0-rc.1). | |
| - '[0-9]+.[0-9]+.[0-9]+' | |
| - '[0-9]+.[0-9]+.[0-9]+-*' | |
| workflow_dispatch: | |
| inputs: | |
| dry_run: | |
| description: 'Perform a dry run (skip actual publish)' | |
| required: true | |
| type: boolean | |
| default: true | |
| # Ensure only one publish runs at a time | |
| concurrency: | |
| group: npm-publish | |
| cancel-in-progress: false | |
| permissions: | |
| contents: read | |
| jobs: | |
| prebuild-x64: | |
| if: github.repository == 'RobotWebTools/rclnodejs' | |
| uses: ./.github/workflows/prebuild-linux-x64.yml | |
| prebuild-arm64: | |
| if: github.repository == 'RobotWebTools/rclnodejs' | |
| uses: ./.github/workflows/prebuild-linux-arm64.yml | |
| publish: | |
| needs: [prebuild-x64, prebuild-arm64] | |
| runs-on: ubuntu-latest | |
| environment: npm-publish | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24.x | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Download x64 prebuilds | |
| uses: actions/download-artifact@v7 | |
| with: | |
| pattern: prebuilt-linux-x64-* | |
| path: prebuilds/linux-x64 | |
| merge-multiple: true | |
| - name: Download arm64 prebuilds | |
| uses: actions/download-artifact@v7 | |
| with: | |
| pattern: prebuilt-linux-arm64-* | |
| path: prebuilds/linux-arm64 | |
| merge-multiple: true | |
| - name: List prebuilds | |
| run: | | |
| echo "=== x64 prebuilds ===" | |
| ls -la prebuilds/linux-x64/ | |
| echo "=== arm64 prebuilds ===" | |
| ls -la prebuilds/linux-arm64/ | |
| - name: Install dependencies | |
| # --ignore-scripts skips install/postinstall (native build + message | |
| # generation need a sourced ROS env, which this job doesn't have) while | |
| # still installing devDependencies such as tsup needed for build:dist. | |
| run: npm install --ignore-scripts | |
| - name: Build dist (ESM/CJS bundles) | |
| # npm-pack.sh packs with --ignore-scripts, so the prepack hook that | |
| # normally runs build:dist is skipped. dist/ is git-ignored and absent | |
| # on a fresh checkout, so build it explicitly before packing — the | |
| # published package's main/module/exports all point at ./dist/*. | |
| run: npm run build:dist | |
| - name: Pack | |
| run: ./scripts/npm-pack.sh | |
| - name: Determine dist-tag | |
| id: dist_tag | |
| run: | | |
| TAG=$(node -p " | |
| const v = require('./package.json').version; | |
| const pre = v.split('-')[1]; | |
| !pre ? 'latest' : (pre.split('.')[0].replace(/[0-9]+$/, '') || 'next') | |
| ") | |
| if [[ -z "$TAG" ]]; then | |
| echo "::error::Failed to determine dist-tag" | |
| exit 1 | |
| fi | |
| echo "tag=$TAG" >> "$GITHUB_OUTPUT" | |
| echo "Resolved dist-tag: $TAG" | |
| - name: Publish | |
| run: | | |
| TAG="${{ steps.dist_tag.outputs.tag }}" | |
| if [[ -z "$TAG" ]]; then | |
| echo "::error::dist-tag is empty, aborting publish" | |
| exit 1 | |
| fi | |
| if [[ "${{ inputs.dry_run }}" == "true" ]]; then | |
| echo "=== DRY RUN ===" | |
| npm publish --provenance --access public --tag "$TAG" --dry-run ./pack/rclnodejs-*.tgz | |
| else | |
| npm publish --provenance --access public --tag "$TAG" ./pack/rclnodejs-*.tgz | |
| fi |