Update Node.js to 24.21 #1961
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 packages to npm | |
| on: | |
| pull_request: | |
| types: [closed] | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| id-token: write | |
| concurrency: | |
| group: publish-libraries | |
| cancel-in-progress: false | |
| jobs: | |
| publish: | |
| if: github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'publish-to-npm')) | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd | |
| with: | |
| persist-credentials: false | |
| fetch-depth: 0 | |
| # Pin to the exact merge commit to avoid publishing code from a newer main head | |
| # if other PRs merge between trigger and job start | |
| ref: ${{ github.event.pull_request.merge_commit_sha }} | |
| - name: Retarget release tags to squash merge commit | |
| if: github.event_name == 'pull_request' | |
| env: | |
| MERGE_SHA: ${{ github.event.pull_request.merge_commit_sha }} | |
| PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} | |
| run: | | |
| set -euo pipefail | |
| echo "π§ Retargeting release tags from PR head to merge commit" | |
| echo "PR_HEAD_SHA=$PR_HEAD_SHA" | |
| echo "MERGE_SHA=$MERGE_SHA" | |
| git fetch --force --tags origin | |
| # Tags are created on the PR branch commit. After squash-merge, that commit is no longer on main, | |
| # so we force-move those tags to the squash merge commit. | |
| ALL_POINTS_AT="$(git tag --points-at "$PR_HEAD_SHA" || true)" | |
| if [ -z "$ALL_POINTS_AT" ]; then | |
| echo "β No git tags found pointing at PR head commit ($PR_HEAD_SHA)." | |
| echo "This likely means the release workflow didn't create/push tags for this PR. Aborting publish." | |
| exit 1 | |
| fi | |
| # Only retarget tags matching the expected {lib}@{version} shape. | |
| TAGS_TO_MOVE="$(printf '%s\n' "$ALL_POINTS_AT" | grep -E '^[A-Za-z0-9._-]+@[0-9]+\.[0-9]+\.[0-9]+([+-][0-9A-Za-z.-]+)?$' || true)" | |
| if [ -z "$TAGS_TO_MOVE" ]; then | |
| echo "β Tags pointing at PR head exist, but none match the {lib}@{version} pattern. Aborting publish." | |
| echo "Tags found:" | |
| printf '%s\n' "$ALL_POINTS_AT" | |
| exit 1 | |
| fi | |
| echo "π Tags to retarget:" | |
| printf '%s\n' "$TAGS_TO_MOVE" | |
| while IFS= read -r tag; do | |
| [ -n "$tag" ] || continue | |
| old_sha="$(git rev-parse "$tag^{commit}")" | |
| git tag -f "$tag" "$MERGE_SHA" | |
| new_sha="$(git rev-parse "$tag^{commit}")" | |
| echo "π $tag: $old_sha -> $new_sha" | |
| # Force-push the updated tag ref. | |
| git push origin -f "refs/tags/$tag" | |
| done <<< "$TAGS_TO_MOVE" | |
| - name: Add repository Yarn wrapper to PATH | |
| run: echo "$GITHUB_WORKSPACE/bin" >> "$GITHUB_PATH" | |
| - name: Setup Node.js | |
| uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f | |
| with: | |
| node-version-file: '.nvmrc' | |
| cache: 'yarn' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Configure git | |
| run: | | |
| git config user.name "otto-the-bot" | |
| git config user.email "8736538+otto-the-bot@users.noreply.github.com" | |
| - name: Install dependencies | |
| run: ./bin/yarn --immutable | |
| - name: Build libraries | |
| run: ./bin/yarn nx run-many -t build --projects=tag:type:lib | |
| - name: Publish to npm | |
| run: | | |
| echo "π¦ Publishing release to npm..." | |
| ./bin/yarn nx release publish --verbose | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NPM_CONFIG_PROVENANCE: true |