{{ message }}
Repository navigation
Commit a891cb6
ci(SDK-1375): harden npm publish/unpublish release workflows (#2898)
* ci(SDK-1375): harden npm publish/unpublish release workflows
- Publish no longer runs package lifecycle scripts, since only the
registry call itself needs the token.
- Stable releases drop the manual trigger; only the automated,
CI-gated path can publish.
- RC/unpublish workflow_dispatch inputs move into env vars with
allowlist validation before use, instead of being interpolated
into shell scripts.
- Release jobs always install and build fresh instead of restoring
node_modules/dist from cache.
- publish-rc/unpublish/unpublish-rc gain a dry_run option so they
can be exercised end-to-end without touching the registry.
- Adds a shared input validator with its own test, run in CI.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* docs(SDK-1375): update release docs for the removed manual publish trigger
Publish to NPM no longer accepts workflow_dispatch, so the manual
"re-run from Actions UI" escape hatch in CONTRIBUTING.md no longer
exists. Points readers to Publish RC to NPM for on-demand builds and
to re-running CI as the recovery path for a missed auto-publish.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(SDK-1375): label dry-run output as dry-run
Dispatching publish-rc/unpublish-rc with dry_run: true still printed
"Published"/"Successfully unpublished", which reads as confirmation
that the registry was actually mutated. Found by running the real
dry-run dispatches on this branch — 0.56.7-rc.1 correctly never
appeared on the registry and 0.54.1-rc.1 correctly stayed published,
but the messaging didn't reflect that.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* ci(SDK-1375): isolate NPM_TOKEN from the SDK build and pin remaining release refs
Splits publish.yaml and publish-rc.yaml into a secret-less build job
(new reusable build-sdk.yaml: checkout, npm ci, i18n:generate, vite
build, upload dist artifact) and a thin publish job that only
downloads the artifact, tags/bumps version, and runs npm
publish/version with NPM_TOKEN. No devDependency or build-tool code
now ever executes in the same runner as the token.
publish-rc.yaml's validate job resolves its branch/commit input to a
concrete commit SHA before fanning out to build and publish — those
run as separate jobs minutes apart, so re-resolving a mutable branch
name independently in each could otherwise build dist/ from one
commit and publish package.json/CHANGELOG.md from a later one if the
branch moved in between.
Also: pins publish.yaml's checkout to the triggering workflow_run's
head_sha instead of main's tip; adds a validate-release-workflows.sh
CI guard against actions/cache creeping into these jobs, untrusted
input/event values bypassing env:, or a workflow dropping its
validator call; documents the no-cache/--ignore-scripts/env-only
rules inline; and tightens the rc-number input pattern to reject
leading zeros.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(SDK-1375): close three detection gaps in validate-release-workflows.sh
Code review found the new guard script could be bypassed three ways:
single-line `run: <cmd>` steps (and the dash-attached `- run:` step
form) were invisible to the injection check since it only scanned
block-scalar `run: |`/`run: >` bodies; the regex required a non-dot
character between the `${{` delimiter and `inputs.`, missing the
common no-space form `${{inputs.x}}`; and the "validator still
called" check was a bare substring grep satisfied by the filename
appearing in a comment, not a real invocation.
Reproduced all three against a scratch copy of the workflows before
and after to confirm the fix actually closes them, and re-verified
the real workflow files still pass clean.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* fix(SDK-1375): make husky's prepare script tolerant of a missing binary
The publish job in publish.yaml/publish-rc.yaml deliberately never
runs npm ci, so devDependencies aren't installed there. npm publish's
--ignore-scripts does not suppress the "prepare" lifecycle script (a
long-standing npm bug fixed in npm 11, confirmed against CI's pinned
npm 10.9.8 — see npm/cli#7211), so every real RC/stable publish was
failing with "sh: husky: command not found", caught by re-running the
dry-run verification against the restructured workflows.
Considered moving the hook to postinstall instead, but postinstall
(unlike prepare) also fires when the package is installed as a
dependency by a consumer — confirmed empirically — which would break
every integrator's npm install since husky is a devDependency never
present in their tree. "prepare": "husky || true" keeps the hook
exempt from running for consumers while making the script itself
survive CI's missing-devDependencies case. Upgrading the publish job
to npm 11+ would fix this at the root but is being tracked separately
as a wider dependency decision.
Also renames validate-release-workflows.sh to
validate-release-workflows.test.sh to signal it's a test script, not
something invoked from a release workflow directly.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* refactor(SDK-1375): trim duplicated comment blocks in release workflows
Each hardening-rationale comment (no-cache, no-npm-ci, env-only input
handling) was repeated near-verbatim across 3-4 workflow files, and
publish-rc.yaml explained the ref-pinning fix twice in the same file
(once at the job outputs, once at the step that does it). Trims each
to the one non-obvious fact plus a pointer to
validate-release-workflows.test.sh, which already states the full
mechanism once.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>1 parent 7da6137 commit a891cb6
11 files changed
Lines changed: 487 additions & 132 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |

0 commit comments