mirror of
https://github.com/bitbaum/kits.git
synced 2026-12-05 07:27:20 +01:00
* ci(kits): publish to npm from GitLab.com on a release tag npm's trusted publishing (no stored npm token) accepts only GitHub Actions, GitLab.com shared runners and CircleCI cloud. GitHub Actions has been off for the bitbaum org since 2026-11-15 and Gitea's runners are self-hosted, so every release needed an npm sign-in and a security key on the laptop. - .gitlab-ci.yml: on `<folder>-v<version>`, check the version matches, pack with pnpm (workspace ranges written in), publish the tarball with npm. - scripts/release.sh: bump, verify, commit, tag, push to origin and gitlab; no npm login. - scripts/trust-gitlab.sh: once per package, trust the GitLab job. Provenance stays off until package.json `repository` names the project that builds it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci(kits): trust a package at its first GitLab release (npm drops unused trusts after 2 days) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
36 lines
1.4 KiB
Bash
Executable File
36 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Once per package, ever: tell npm that .gitlab-ci.yml in gitlab.com/bitbaum/kits
|
|
# may publish it. One npm sign-in with the security key covers the whole run
|
|
# (tick "do not challenge for 5 minutes" when npm asks). Run it right before
|
|
# the package's first release this way: npm drops a trust that has not
|
|
# published within 2 days.
|
|
#
|
|
# scripts/trust-gitlab.sh <folder> [folder ...]
|
|
#
|
|
# `--all` does every package in packages/. A package that already
|
|
# trusts something is reported and left alone (revoke first to change it:
|
|
# `npm trust list <name>`, `npm trust revoke <name> --id=<id>`).
|
|
set -euo pipefail
|
|
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
cd "$ROOT"
|
|
PROJECT="${GITLAB_PROJECT:-bitbaum/kits}"
|
|
# `npm trust` needs npm >= 11.15, and returned 400 on 11.x for us (2026-10): use 12.
|
|
NPM=(npx -y npm@12)
|
|
|
|
folders=("$@")
|
|
[ ${#folders[@]} -gt 0 ] || { echo "name the package folder(s), or --all" >&2; exit 2; }
|
|
[ "${folders[0]}" = --all ] && folders=($(ls packages))
|
|
|
|
ok=0; failed=()
|
|
for f in "${folders[@]}"; do
|
|
name=$(node -p "require('./packages/$f/package.json').name")
|
|
if "${NPM[@]}" trust gitlab "$name" --file .gitlab-ci.yml --project "$PROJECT" --allow-publish --yes; then
|
|
echo "trusted $name"; ok=$((ok + 1))
|
|
else
|
|
echo "FAILED $name"; failed+=("$name")
|
|
fi
|
|
sleep 2
|
|
done
|
|
echo "trusted $ok, failed ${#failed[@]}${failed:+: ${failed[*]}}"
|
|
[ ${#failed[@]} -eq 0 ]
|