From 5be6452b7208d32b7765c45b06189cdce7baa551 Mon Sep 17 00:00:00 2001 From: "Andrew (shixish)" Date: Fri, 27 Nov 2026 11:50:44 -1000 Subject: [PATCH] ci(release): add move-next dispatch to repoint npm next dist-tag Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release.yml | 71 +++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 47948db..d1c3ab0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,6 +3,8 @@ name: Release # Publishes @diffbot/typescript to npm (with provenance) and creates the matching # GitHub Release. Triggered by pushing a version tag (e.g. v0.6.0); also runnable # manually, which runs every gate plus `npm publish --dry-run` and publishes nothing. +# A dispatch with action "move-next" instead only re-points the npm `next` dist-tag +# at an already-published version (see the move-next job). # # npm auth: trusted publishing (OIDC) only. No token is passed to npm, so a # misconfigured trusted publisher fails the publish instead of silently using a token. @@ -17,6 +19,22 @@ on: push: tags: ["v*"] workflow_dispatch: + inputs: + action: + description: >- + dry-run: run the release gates and a publish dry run (publishes nothing). + move-next: ONLY point the npm `next` dist-tag at an already-published + version; no build, no publish, no GitHub Release. + type: choice + options: [dry-run, move-next] + default: dry-run + version: + description: >- + move-next only: the already-published version `next` should point at + (e.g. 1.2.3 or 1.2.4-rc.0). Empty = the current `latest`. + type: string + required: false + default: "" permissions: contents: read @@ -30,6 +48,8 @@ concurrency: jobs: verify: name: Verify version + # A move-next dispatch runs only the move-next job below. + if: github.event_name != 'workflow_dispatch' || inputs.action != 'move-next' runs-on: ubuntu-latest timeout-minutes: 5 outputs: @@ -247,3 +267,54 @@ jobs: --verify-tag \ --notes-file "${RUNNER_TEMP}/notes.md" \ "${prerelease[@]}" + + # Manual only (action: move-next). Points `next` at a version that is already + # on npm, e.g. after a final release whose "Point next at final release" step + # warned, or to repair a `next` that fell behind `latest`. It never builds, + # publishes or touches GitHub Releases. It lives in release.yml because the + # package's npm trusted publisher is bound to this workflow file; `npm + # dist-tag` over OIDC needs npm >= 11.21.0 / 12.2.0 and "Allow npm dist-tag" + # enabled on that trusted publisher. + move-next: + name: Move npm next dist-tag + if: github.event_name == 'workflow_dispatch' && inputs.action == 'move-next' + runs-on: ubuntu-latest + timeout-minutes: 5 + permissions: + contents: read + id-token: write # npm trusted publishing (OIDC) for `npm dist-tag` + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - uses: actions/setup-node@v4 + with: + node-version: 22 + registry-url: https://registry.npmjs.org + - name: Update npm + run: | + npm install -g npm@latest + npm --version + - name: Point next at an existing version + env: + INPUT_VERSION: ${{ inputs.version }} + run: | + set -euo pipefail + name=$(node -p 'require("./package.json").name') + echo "Before: $(npm view "$name" dist-tags --json | tr -d '\n ')" + version="${INPUT_VERSION}" + if [ -z "$version" ]; then + version=$(npm view "$name" dist-tags.latest) + echo "No version given; using the current latest: ${version}" + fi + if ! printf '%s' "$version" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$'; then + echo "::error::'${version}' is not a version like 1.2.3 or 1.2.3-rc.0." + exit 1 + fi + if ! npm view "${name}@${version}" version >/dev/null 2>&1; then + echo "::error::${name}@${version} is not on npm; move-next only retags published versions." + exit 1 + fi + # Trusted publishing (OIDC) only; no token is exported. + npm dist-tag add "${name}@${version}" next + echo "After: $(npm view "$name" dist-tags --json | tr -d '\n ')"