|
1 | 1 | 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) }}" |
2 | 5 | on: |
3 | 6 | release: |
4 | 7 | 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 |
5 | 18 | jobs: |
6 | 19 | 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' }} |
7 | 23 | runs-on: ubuntu-latest |
8 | 24 | steps: |
9 | 25 | - uses: actions-ecosystem/action-regex-match@v2 |
@@ -183,3 +199,42 @@ jobs: |
183 | 199 | else |
184 | 200 | echo "Skipping: $NEW_TAG is not newer than current latest $CURRENT_LATEST" |
185 | 201 | 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