-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (65 loc) · 2.68 KB
/
Copy pathrelease.yml
File metadata and controls
78 lines (65 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: Release
on:
push:
tags: ['v*']
workflow_dispatch:
inputs:
dry_run:
description: 'Run the gate and rewrite manifests, publish nothing'
type: boolean
default: true
# No NPM_TOKEN. npm exchanges this OIDC token for a short-lived credential,
# and attaches provenance without being asked - see RELEASING.md for what has
# to be configured on npmjs.com for the exchange to be accepted.
permissions:
contents: read
id-token: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
# Deliberately no `registry-url`. It makes setup-node write
# `_authToken=${NODE_AUTH_TOKEN}` into an .npmrc, and with no token to
# substitute that line becomes an empty credential rather than no
# credential. npm reads it as "auth is already configured", skips the
# OIDC exchange entirely and fails with ENEEDAUTH or a 404 - see
# actions/setup-node#1551. The default registry is npmjs.org anyway.
- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
# Trusted publishing needs npm >= 11.5.1, which is newer than the npm
# bundled with any Node 22.
- name: Use an npm that can do OIDC
run: |
npm install -g npm@latest
npm --version
# Belt and braces: if anything upstream reintroduces an auth line, the
# OIDC exchange is silently skipped and the failure looks like a
# permissions problem rather than a configuration one.
- name: Refuse a stale credential
run: node scripts/check-no-npm-auth.mjs
- run: pnpm install --frozen-lockfile
# The same gate CI runs. A tag is not a reason to publish something that
# does not build.
- run: pnpm build
- run: pnpm typecheck
- run: pnpm lint
- run: pnpm test
# Every `exports` and `bin` target has to exist in the built tree. tsc
# cannot catch a subpath nothing in the repo imports.
- run: pnpm check:exports
- name: Check the tag against the versions
if: startsWith(github.ref, 'refs/tags/v')
run: node scripts/check-version.mjs "${GITHUB_REF_NAME#v}"
# Rewrites `workspace:^` to the real version and publishes in dependency
# order. `pnpm publish` would do both, but cannot speak OIDC; `npm
# publish` speaks OIDC but cannot read pnpm's protocol.
- name: Publish
if: startsWith(github.ref, 'refs/tags/v') && inputs.dry_run != true
run: node scripts/release-publish.mjs "${GITHUB_REF_NAME#v}"
- name: Rehearse
if: inputs.dry_run == true
run: node scripts/release-publish.mjs --dry-run