Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ on:
permissions:
contents: write
id-token: write
attestations: write
artifact-metadata: write

jobs:
build:
Expand Down Expand Up @@ -106,6 +108,34 @@ jobs:
npm publish --access public --provenance
fi

# Register each published package on the org's Linked Artifacts page
# (https://github.com/orgs/boshold/artifacts) via the Artifact Metadata API.
# Best-effort: a failure here must never break a release.
- name: Register npm storage records
continue-on-error: true
env:
GH_TOKEN: ${{ github.token }}
run: |
version=$(node -p "require('./package.json').version")
names=$(node -p "['@bosdev/zaps', ...Object.keys(require('./package.json').optionalDependencies || {})].join('\n')")
echo "$names" | while IFS= read -r name; do
[ -n "$name" ] || continue
integrity=$(npm view "$name@$version" dist.integrity 2>/dev/null || true)
if [ -z "$integrity" ]; then
echo "$name@$version: no integrity on registry — skipping"
continue
fi
digest=$(node -e 'process.stdout.write("sha512:"+Buffer.from(process.argv[1].replace(/^sha512-/,""),"base64").toString("hex"))' "$integrity")
echo "registering storage record for $name@$version ($digest)"
curl -fsSL -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GH_TOKEN" \
-H "X-GitHub-Api-Version: 2026-03-10" \
https://api.github.com/orgs/boshold/artifacts/metadata/storage-record \
-d "{\"name\":\"$name\",\"version\":\"$version\",\"digest\":\"$digest\",\"registry_url\":\"https://registry.npmjs.org\",\"artifact_url\":\"https://www.npmjs.com/package/$name/v/$version\",\"status\":\"active\"}" \
|| echo "storage-record POST failed for $name@$version (non-fatal)"
done

release:
name: Release
runs-on: ubuntu-latest
Expand Down
15 changes: 14 additions & 1 deletion scripts/prepare-npm-platform-packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,23 @@ for (const platform of platforms) {
repository: { type: "git", url: "git+https://github.com/boshold/zaps.git" },
os: [platform.os],
cpu: [platform.cpu],
files: ["zaps"],
files: ["zaps", "README.md"],
publishConfig: { access: "public" },
};
writeFileSync(path.join(dir, "package.json"), `${JSON.stringify(pkg, null, 2)}\n`);

const readme = `# ${platform.name}

Prebuilt native \`zaps\` binary for **${platform.os}/${platform.cpu}**.

You don't install this package directly — it's an \`optionalDependencies\` target of
the main package, selected automatically for your platform.

**Install [\`@bosdev/zaps\`](https://www.npmjs.com/package/@bosdev/zaps) instead.**

Source & docs: https://github.com/boshold/zaps
`;
writeFileSync(path.join(dir, "README.md"), readme);
console.log(`prepared ${platform.name}@${version}`); // eslint-disable-line no-console -- build script output
}

Expand Down