Skip to content

Commit 3397ed3

Browse files
authored
ci: add OIDC canary publish to release.yml via workflow_dispatch (#1352)
* ci: publish PR canaries via OIDC by folding them into release.yml npm trusted publishing allows exactly one trusted publisher per package (one repo + one workflow file), and checkly's slot is release.yml — which is why the normal release publishes via OIDC + --provenance. release-canary.yml was a separate workflow using a classic NODE_AUTH_TOKEN. That token was retired when the package moved to OIDC, so a separate workflow could no longer authenticate and the canary has failed on every PR since. Fold the canary job into release.yml so it inherits the trusted publisher: - add a `pull_request: [labeled]` trigger; the release-event jobs now gate on `github.event_name == 'release'` (PR events cascade-skip via needs: validate-tag). - the canary job publishes 0.0.0-pr.<N>.<sha> with id-token + --provenance (no token), tagged `experimental` — or a `canary:<tag>` label's tag, applied at publish time (trusted publishing authenticates `npm publish`, not a separate `npm dist-tag add`). - remove release-canary.yml. * ci: name canary vs release runs distinctly in the Actions list Add a run-name expression so PR-label canary runs render as 'Canary build - PR #<n> (<branch>)' and release-event runs as 'Release <tag>', instead of the default commit-subject run name. * ci: trigger canary via workflow_dispatch instead of a PR label A pull_request:labeled trigger fired release.yml on every label on every PR (jobs skipped, but the release workflow was still invoked). Drop it: the canary is now a manual workflow_dispatch (`gh workflow run release.yml --ref <branch>`, optional `-f tag=`), publishing 0.0.0-canary.<sha> via the same OIDC trusted publisher. release.yml now triggers only on a real release or an explicit dispatch — never on labels. The build-label mechanism / release-canary.yml are gone.
1 parent 1bd577f commit 3397ed3

2 files changed

Lines changed: 55 additions & 62 deletions

File tree

.github/workflows/release-canary.yml

Lines changed: 0 additions & 62 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
11
name: Publish Package to npmjs
2+
# Name each run for its trigger, so manual canary builds are distinguishable
3+
# from real releases in the Actions list.
4+
run-name: "${{ github.event_name == 'workflow_dispatch' && format('Canary build - {0}', github.ref_name) || format('Release {0}', github.event.release.tag_name) }}"
25
on:
36
release:
47
types: [published]
8+
# Manual canary builds: dispatch this workflow on a branch to publish an
9+
# experimental build of that branch. It lives here (not a separate workflow) so
10+
# it authenticates via the npm OIDC trusted publisher — npm allows only ONE
11+
# trusted publisher (repo + workflow file) per package, and that slot is release.yml.
12+
workflow_dispatch:
13+
inputs:
14+
tag:
15+
description: npm dist-tag for the canary build
16+
required: false
17+
default: experimental
518
jobs:
619
validate-tag:
20+
# Release-event path only. A manual dispatch runs the `canary` job below; the
21+
# other release jobs cascade-skip on dispatch via their `needs: validate-tag`.
22+
if: ${{ github.event_name == 'release' }}
723
runs-on: ubuntu-latest
824
steps:
925
- uses: actions-ecosystem/action-regex-match@v2
@@ -183,3 +199,42 @@ jobs:
183199
else
184200
echo "Skipping: $NEW_TAG is not newer than current latest $CURRENT_LATEST"
185201
fi
202+
203+
# Manual canary: dispatch this workflow on a branch to publish an experimental
204+
# build of that branch. Authenticates via the SAME npm OIDC trusted publisher as
205+
# the release jobs above (id-token + --provenance, no token). Trigger with
206+
# `gh workflow run release.yml --ref <branch>` (optionally `-f tag=<dist-tag>`).
207+
# Replaces the old build-label release-canary.yml, whose classic NPM_TOKEN was
208+
# retired when the package moved to OIDC.
209+
canary:
210+
if: ${{ github.event_name == 'workflow_dispatch' }}
211+
runs-on: ubuntu-latest
212+
permissions:
213+
id-token: write
214+
steps:
215+
- uses: actions/checkout@v3
216+
- uses: pnpm/action-setup@v5
217+
with:
218+
version: 10
219+
- uses: actions/setup-node@v4
220+
with:
221+
node-version: '24.x'
222+
cache: "pnpm"
223+
# Ensure that the README is published with the package
224+
- run: rm -f packages/cli/README.md && cp README.md packages/cli
225+
- run: echo "CANARY_VERSION=0.0.0-canary.$(git rev-parse --short HEAD)" >> $GITHUB_ENV
226+
- run: pnpm install --frozen-lockfile
227+
- name: Set version, pack, and publish (OIDC trusted publishing)
228+
run: |
229+
pnpm version ${{ env.CANARY_VERSION }} --no-git-tag-version
230+
pnpm pack
231+
npm publish checkly-*.tgz --provenance --tag '${{ inputs.tag }}'
232+
working-directory: packages/cli
233+
- name: Publish summary
234+
run: |
235+
{
236+
echo "Published \`checkly@${{ env.CANARY_VERSION }}\` (dist-tag: \`${{ inputs.tag }}\`)"
237+
echo '```'
238+
echo "npm install checkly@${{ env.CANARY_VERSION }}"
239+
echo '```'
240+
} >> "$GITHUB_STEP_SUMMARY"

0 commit comments

Comments
 (0)