From 1716a39087cc7b0d5283381a1fd0d2d558742dd0 Mon Sep 17 00:00:00 2001 From: Hisku Date: Wed, 18 Nov 2026 17:37:41 +0000 Subject: [PATCH] ci(ENG-4207): publish an existing release tag to npm on demand When the publish step fails after release-please has cut the release, a re-run skips publishing because the release already exists. A manual run with a tag (e.g. defender-v0.9.6) now checks out that tag, checks package.json matches it, builds and publishes, with the same steps and token as the release job. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/release-please.yml | 44 ++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 975fbff..b7c84cc 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -2,6 +2,13 @@ on: push: branches: - main + # Publish an existing release tag to npm, e.g. when the publish step failed after + # release-please had already cut the release (a re-run then skips publishing). + workflow_dispatch: + inputs: + tag: + description: 'Release tag to publish, e.g. defender-v0.9.6' + required: true name: release-please @@ -11,6 +18,7 @@ permissions: jobs: release-please: + if: github.event_name == 'push' runs-on: ubuntu-latest outputs: released: ${{ steps.release.outputs.paths_released != '[]' }} @@ -62,3 +70,39 @@ jobs: version: ${{ needs.release-please.outputs.version }} secrets: REPO_GH_PAT: ${{ secrets.REPO_GH_PAT }} + + publish-tag: + if: github.event_name == 'workflow_dispatch' + runs-on: ubuntu-latest + env: + TAG: ${{ inputs.tag }} + steps: + - name: Check tag + run: | + [[ "$TAG" =~ ^defender-v[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "Not a release tag: $TAG"; exit 1; } + - name: Checkout Repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: refs/tags/${{ inputs.tag }} + lfs: true + - name: Check version matches tag + run: | + version=$(node -p "require('./package.json').version") + [[ "defender-v$version" == "$TAG" ]] || { echo "package.json is $version, tag is $TAG"; exit 1; } + - name: Setup pnpm + uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 + - name: Setup Node + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version: '22.23.5' + cache: 'pnpm' + registry-url: 'https://registry.npmjs.org' + - name: Build + run: | + pnpm install --frozen-lockfile + pnpm build + - name: Publish + run: | + pnpm publish-release + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}