Skip to content

Commit 8926c33

Browse files
authored
fix(release): harden published artifact verification (#90)
The v0.5.1 run published the workflow-validated tarball with provenance, but npm view transiently reported a different dist.integrity for longer than the retry budget, so the release job was skipped even though the published bytes were later proven byte-identical. The gate accepted only two packument facts: an integrity string match and a truthy attestation URL that was never fetched. It now verifies the published bytes directly when metadata conflicts, checks npm's ECDSA registry signature, and validates the Sigstore bundle and DSSE subject digest under a policy pinning this repository, the release workflow, the version tag and the builder identity. append-release-proof.mjs repeated the same weak check without retries, so both gates now share one verifier. Releases are created as drafts before publication and promoted only after verification, so a propagation incident leaves a recoverable draft rather than no release at all. Adds coverage for the exhaustion path, the byte-verification fallback in both its accepting and still-fatal forms, the retry taxonomy, and append-release-proof.
1 parent 6af7f93 commit 8926c33

11 files changed

Lines changed: 1672 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: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Retry a contended file-lock acquisition when Windows denies access to a lock file whose directory entry is still being torn down, including when the native binding performs the exclusive create. Both the exclusive create and the holder's snapshot read reported that transient `EPERM` as a hard failure, so concurrent `acquireFileLock()` calls failed intermittently on Windows even though the very next attempt would have succeeded. Retries stay bounded, so a genuine permission denial still surfaces as `EPERM` rather than a lock timeout; thanks @Yigtwxx for the fix.
88
- Apply `replaceFileAtomic()` and `replaceFileAtomicSync()` modes through pinned temp-file descriptors before rename, and through pinned copy-fallback descriptors, so a post-rename symlink swap cannot redirect `chmod` to an unrelated file while exact modes remain independent of umask; thanks @yetval for reporting this (#86).
99
- Bound fallback Windows owner and ACL command execution to 10 seconds per process and report owner-query failures as unverified instead of returning a partial permission classification; thanks @Yigtwxx for the diagnosis.
10+
- 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 (#81).
1011
- Report the documented `remove()` failure codes instead of collapsing every failure to `path-alias`. A missing target now throws `not-found`, a non-empty directory throws `not-empty`, and any other filesystem failure throws `not-removable`, while directory identity drift keeps reporting `path-mismatch`; thanks @Yigtwxx for the fix.
1112

1213
### Compatibility
@@ -19,6 +20,10 @@
1920

2021
- 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).
2122

23+
### Docs and Tooling
24+
25+
- 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).
26+
2227
## 0.5.1 - 2026-08-01
2328

2429
### 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)