Skip to content

Commit c2f5004

Browse files
committed
fix(release): harden published artifact verification
1 parent 2477f56 commit c2f5004

11 files changed

Lines changed: 1675 additions & 173 deletions

‎.github/workflows/release.yml‎

Lines changed: 81 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,46 @@ jobs:
228228
if-no-files-found: error
229229
retention-days: 7
230230

231+
draft-release:
232+
name: Create draft GitHub Release
233+
if: github.ref_protected
234+
needs: collect
235+
runs-on: ubuntu-latest
236+
timeout-minutes: 10
237+
permissions:
238+
contents: write
239+
steps:
240+
- name: Check out
241+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
242+
with:
243+
fetch-depth: 0
244+
245+
- name: Generate release notes
246+
env:
247+
RELEASE_TAG: ${{ github.ref_name }}
248+
run: |
249+
package_version="${RELEASE_TAG#v}"
250+
node scripts/release-notes.mjs "${package_version}" > release-notes.md
251+
252+
- name: Create draft release
253+
env:
254+
GH_TOKEN: ${{ github.token }}
255+
RELEASE_TAG: ${{ github.ref_name }}
256+
run: |
257+
if gh release view "${RELEASE_TAG}" --json isDraft >/dev/null 2>&1; then
258+
echo "${RELEASE_TAG} already has a GitHub release."
259+
exit 0
260+
fi
261+
gh release create "${RELEASE_TAG}" \
262+
--verify-tag \
263+
--draft \
264+
--title "fs-safe ${RELEASE_TAG#v}" \
265+
--notes-file release-notes.md
266+
231267
publish:
232268
name: Publish @openclaw/fs-safe
233269
if: github.ref_protected
234-
needs: collect
270+
needs: draft-release
235271
runs-on: ubuntu-latest
236272
timeout-minutes: 20
237273
permissions:
@@ -241,11 +277,22 @@ jobs:
241277
- name: Check out
242278
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
243279

280+
- name: Set up pnpm
281+
uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
282+
with:
283+
version: ${{ env.PNPM_VERSION }}
284+
run_install: false
285+
244286
- name: Set up Node
245287
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
246288
with:
247289
node-version: ${{ env.NODE_VERSION }}
248290
registry-url: https://registry.npmjs.org
291+
cache: pnpm
292+
cache-dependency-path: pnpm-lock.yaml
293+
294+
- name: Install dependencies
295+
run: pnpm install --frozen-lockfile
249296

250297
- name: Update npm
251298
run: npm install --global npm@${{ env.NPM_VERSION }}
@@ -260,11 +307,11 @@ jobs:
260307
run: node scripts/publish-or-verify.mjs --package "@openclaw/fs-safe" --artifacts release-artifacts
261308

262309
release:
263-
name: Publish GitHub Release
310+
name: Verify and promote GitHub Release
264311
if: github.ref_protected
265312
needs: publish
266313
runs-on: ubuntu-latest
267-
timeout-minutes: 10
314+
timeout-minutes: 20
268315
permissions:
269316
contents: write
270317
steps:
@@ -273,10 +320,21 @@ jobs:
273320
with:
274321
fetch-depth: 0
275322

323+
- name: Set up pnpm
324+
uses: pnpm/action-setup@0ebf47130e4866e96fce0953f49152a61190b271 # v6.0.9
325+
with:
326+
version: ${{ env.PNPM_VERSION }}
327+
run_install: false
328+
276329
- name: Set up Node
277330
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
278331
with:
279332
node-version: ${{ env.NODE_VERSION }}
333+
cache: pnpm
334+
cache-dependency-path: pnpm-lock.yaml
335+
336+
- name: Install dependencies
337+
run: pnpm install --frozen-lockfile
280338

281339
- name: Download release package
282340
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
@@ -292,16 +350,29 @@ jobs:
292350
node scripts/release-notes.mjs "${package_version}" > release-notes.md
293351
node scripts/append-release-proof.mjs release-notes.md release-artifacts/manifest.json "${GITHUB_REPOSITORY}" "${GITHUB_RUN_ID}"
294352
295-
- name: Publish release
353+
- name: Upload release proof
354+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
355+
with:
356+
name: release-proof-${{ github.run_id }}-${{ github.run_attempt }}
357+
path: release-notes.md
358+
if-no-files-found: error
359+
retention-days: 90
360+
361+
- name: Promote draft release
296362
env:
297363
GH_TOKEN: ${{ github.token }}
298364
RELEASE_TAG: ${{ github.ref_name }}
299365
run: |
300-
if gh release view "${RELEASE_TAG}" >/dev/null 2>&1; then
301-
echo "${RELEASE_TAG} already has a GitHub release."
366+
release_state="$(gh release view "${RELEASE_TAG}" --json isDraft)"
367+
if [ "$(printf '%s' "${release_state}" | jq -r '.isDraft')" != "true" ]; then
368+
echo "${RELEASE_TAG} is already public."
302369
exit 0
303370
fi
304-
gh release create "${RELEASE_TAG}" \
305-
--verify-tag \
306-
--title "fs-safe ${RELEASE_TAG#v}" \
307-
--notes-file release-notes.md
371+
gh release edit "${RELEASE_TAG}" \
372+
--notes-file release-notes.md \
373+
--draft=false
374+
published_state="$(gh release view "${RELEASE_TAG}" --json isDraft)"
375+
if [ "$(printf '%s' "${published_state}" | jq -r '.isDraft')" != "false" ]; then
376+
echo "${RELEASE_TAG} did not become public." >&2
377+
exit 1
378+
fi

‎CHANGELOG.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,18 @@
22

33
## Unreleased
44

5+
### Security and Correctness
6+
7+
- Verify published npm bytes directly when registry integrity metadata conflicts, and cryptographically verify the registry signature plus Sigstore provenance against the package digest and the trusted fs-safe release workflow.
8+
59
### Features
610

711
- Suffix Windows reserved basenames with `_` in `sanitizeUntrustedFileName()` while preserving case and extensions on every platform, including dollar names and superscript COM/LPT variants; thanks @SebTardif (#67).
812

13+
### Docs and Tooling
14+
15+
- Create GitHub Releases as drafts before npm publication, then attach immutable verification proof and promote them only after the published package passes the shared registry verifier, avoiding stranded releases during registry propagation incidents (#81).
16+
917
## 0.5.1 - 2026-08-01
1018

1119
### Security and Correctness

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@
151151
"@napi-rs/cli": "3.8.1",
152152
"@types/node": "^26.1.2",
153153
"@vitest/coverage-v8": "4.1.10",
154+
"sigstore": "5.0.0",
154155
"typescript": "^7.0.2",
155156
"vite": "8.2.0",
156157
"vitest": "^4.1.10"

0 commit comments

Comments
 (0)