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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ Notable changes to Preceptor are recorded here. The format follows [Keep a Chang

## [Unreleased]

## [0.0.2] - 2026-11-29

### Changed

- Simplified the npm installation command in the README.
- Updated the release, licensing and development guides for ongoing maintenance, removing first-publication instructions.
- Release preflight and staging now use the version in the checked-out package manifest, with regression checks for version and archive mismatches.

## [0.0.1] - 2026-11-29

### Added
Expand Down
2 changes: 1 addition & 1 deletion docs/releasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Preceptor is published as [`@0xbuff/preceptor`](https://www.npmjs.com/package/@0

## Prepare a release

Update the package version and move the relevant Unreleased changelog entries into a dated section for that version. Keep release scripts and their fixtures in step with the version. Review contributor rights, license notices and the changes since the previous release.
Update the package version and move the relevant Unreleased changelog entries into a dated section for that version. The release scripts read the version from the checked-out package manifest. Review contributor rights, license notices and the changes since the previous release.

Use the documented Node.js and pnpm toolchain on a clean checkout:

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@0xbuff/preceptor",
"version": "0.0.1",
"version": "0.0.2",
"description": "Portable instructional engine for guided learning and practice",
"private": false,
"license": "Apache-2.0",
Expand Down
39 changes: 25 additions & 14 deletions scripts/release-preflight.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,17 @@ archive_files() {
dist/index.d.ts dist/index.js package.json
}

root="$(cd "$(dirname "$0")/.." && pwd)"
version="$(jq -er '.version | strings' "$root/package.json")" || fail package-version
[[ "$version" =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]] || fail package-version
archive="0xbuff-preceptor-$version.tgz"

approval
case "$1" in
filename)
[[ "$#" == 1 ]] || fail arguments
printf '%s\n' "$archive"
;;
approval)
[[ "$#" == 1 ]] || fail arguments
;;
Expand All @@ -46,37 +55,39 @@ case "$1" in
[[ "$3" =~ ^[1-9][0-9]*$ ]] || fail run-attempt
[[ "$4" == "preceptor-candidate-ubuntu-latest-$GITHUB_SHA-$3" ]] || fail artifact-name
cd "$2"
[[ -f 0xbuff-preceptor-0.0.1.tgz && ! -L 0xbuff-preceptor-0.0.1.tgz && -f evidence.json && ! -L evidence.json ]] || fail artifact-files
[[ -f "$archive" && ! -L "$archive" && -f evidence.json && ! -L evidence.json ]] || fail artifact-files
[[ "$(find . -mindepth 1 -maxdepth 1 | wc -l)" -eq 2 ]] || fail artifact-files
[[ "$(sha256sum 0xbuff-preceptor-0.0.1.tgz | cut -d ' ' -f 1)" == "$APPROVED_DIGEST" ]] || fail archive-digest
integrity="sha512-$(openssl dgst -sha512 -binary 0xbuff-preceptor-0.0.1.tgz | openssl base64 -A)"
jq -e --arg digest "$APPROVED_DIGEST" --argjson size "$(wc -c < 0xbuff-preceptor-0.0.1.tgz)" \
--arg commit "$GITHUB_SHA" --arg integrity "$integrity" '
.name == "@0xbuff/preceptor" and .version == "0.0.1" and
[[ "$(sha256sum "$archive" | cut -d ' ' -f 1)" == "$APPROVED_DIGEST" ]] || fail archive-digest
integrity="sha512-$(openssl dgst -sha512 -binary "$archive" | openssl base64 -A)"
jq -e --arg digest "$APPROVED_DIGEST" --argjson size "$(wc -c < "$archive")" \
--arg commit "$GITHUB_SHA" --arg integrity "$integrity" --arg version "$version" --arg archive "$archive" '
.name == "@0xbuff/preceptor" and .version == $version and
.commit == $commit and .platform == "linux" and
.filename == "0xbuff-preceptor-0.0.1.tgz" and .integrity == $integrity and
.filename == $archive and .integrity == $integrity and
.sha256 == $digest and .bytes == $size and
(.files | sort) == [
"CHANGELOG.md", "COPYRIGHT.md", "LICENSE", "README.md",
"dist/index.d.ts", "dist/index.js", "package.json"
]
' evidence.json >/dev/null || fail archive-manifest
expected="$(archive_files | sed 's|^|package/|')"
actual="$(tar -tzf 0xbuff-preceptor-0.0.1.tgz | LC_ALL=C sort)"
actual="$(tar -tzf "$archive" | LC_ALL=C sort)"
[[ "$actual" == "$expected" ]] || fail archive-contents
# Require regular files only; no symlink, hardlink or directory entries.
tar -tvzf 0xbuff-preceptor-0.0.1.tgz | awk 'substr($0,1,1) != "-" { bad=1 } END { exit bad }' || fail archive-types
tar -xOzf 0xbuff-preceptor-0.0.1.tgz package/package.json | jq -e '
.name == "@0xbuff/preceptor" and .version == "0.0.1" and
tar -tvzf "$archive" | awk 'substr($0,1,1) != "-" { bad=1 } END { exit bad }' || fail archive-types
tar -xOzf "$archive" package/package.json | jq -e --arg version "$version" '
.name == "@0xbuff/preceptor" and .version == $version and
.private == false and .license == "Apache-2.0" and .type == "module" and
.publishConfig.access == "public" and
.publishConfig.registry == "https://registry.npmjs.org/" and
([.dependencies, .optionalDependencies, .peerDependencies,
.bundledDependencies, .bundleDependencies] | all(. == null or length == 0))
' >/dev/null || fail package-metadata
notes="$(tar -xOzf 0xbuff-preceptor-0.0.1.tgz package/CHANGELOG.md)"
heading="$(grep -E '^## \[0\.0\.1\] - [0-9]{4}-[0-9]{2}-[0-9]{2}$' <<< "$notes")" || fail dated-notes
release_date="$(cut -d ' ' -f 4 <<< "$heading")"
notes="$(tar -xOzf "$archive" package/CHANGELOG.md)"
heading="$(awk -v version="$version" 'index($0, "## [" version "]") == 1' <<< "$notes")"
prefix="## [$version] - "
[[ "$heading" == "$prefix"* ]] || fail dated-notes
release_date="${heading#"$prefix"}"
[[ "$release_date" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]] || fail dated-notes
[[ "$(date -u -d "$release_date" +%F)" == "$release_date" ]] || fail dated-notes
printf '%s\n' "Release preflight passed"
Expand Down
8 changes: 4 additions & 4 deletions scripts/stage-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -euo pipefail
root="$(cd "$(dirname "$0")/.." && pwd)"
preflight="$root/scripts/release-preflight.sh"

bash "$preflight" approval
archive="$(bash "$preflight" filename)"
workspace="$(mktemp -d "$RUNNER_TEMP/preceptor-release.XXXXXXXX")"
trap 'rm -rf "$workspace"' EXIT
archive_dir="$workspace/artifact"
Expand All @@ -22,6 +22,6 @@ node --version
npm --version
# Keep both rechecks immediately before the single staging invocation.
[[ "$(gh api "repos/$GITHUB_REPOSITORY/git/ref/heads/main" --jq '.object.sha')" == "$GITHUB_SHA" ]]
[[ -f 0xbuff-preceptor-0.0.1.tgz && ! -L 0xbuff-preceptor-0.0.1.tgz ]]
[[ "$(sha256sum 0xbuff-preceptor-0.0.1.tgz | cut -d ' ' -f 1)" == "$APPROVED_DIGEST" ]]
npm stage publish ./0xbuff-preceptor-0.0.1.tgz --access public --tag latest --ignore-scripts --registry https://registry.npmjs.org/
[[ -f "$archive" && ! -L "$archive" ]]
[[ "$(sha256sum "$archive" | cut -d ' ' -f 1)" == "$APPROVED_DIGEST" ]]
npm stage publish "./$archive" --access public --tag latest --ignore-scripts --registry https://registry.npmjs.org/
40 changes: 23 additions & 17 deletions tests/release-preflight.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ if [[ "$(uname -s)" != Linux ]]; then
fi
root="$(cd "$(dirname "$0")/.." && pwd)"
preflight="$root/scripts/release-preflight.sh"
version="$(jq -er '.version | strings' "$root/package.json")"
archive="0xbuff-preceptor-$version.tgz"
workspace="$(mktemp -d)"
trap 'rm -rf "$workspace"' EXIT

Expand All @@ -19,8 +21,8 @@ cd "$workspace"
for file in CHANGELOG.md COPYRIGHT.md LICENSE README.md dist/index.d.ts dist/index.js package.json; do
printf 'synthetic\n' > "package/$file"
done
printf '# Changelog\n\n## [0.0.1] - 2026-11-29\n' > package/CHANGELOG.md
printf '%s\n' '{"name":"@0xbuff/preceptor","version":"0.0.1","private":false,"license":"Apache-2.0","type":"module","publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"}}' > package/package.json
printf '# Changelog\n\n## [%s] - 2026-11-29\n' "$version" > package/CHANGELOG.md
jq -n --arg version "$version" '{name:"@0xbuff/preceptor",version:$version,private:false,license:"Apache-2.0",type:"module",publishConfig:{access:"public",registry:"https://registry.npmjs.org/"}}' > package/package.json
cp package/package.json metadata-good.json
cp package/CHANGELOG.md notes-good.md

Expand All @@ -32,16 +34,16 @@ jq -n --arg sha "$GITHUB_SHA" --arg repo "$GITHUB_REPOSITORY" '{
}' > run-good.json

pack() {
tar -czf artifact/0xbuff-preceptor-0.0.1.tgz package/CHANGELOG.md package/COPYRIGHT.md \
tar -czf "artifact/$archive" package/CHANGELOG.md package/COPYRIGHT.md \
package/LICENSE package/README.md package/dist/index.d.ts package/dist/index.js \
package/package.json "$@"
export APPROVED_DIGEST
APPROVED_DIGEST="$(sha256sum artifact/0xbuff-preceptor-0.0.1.tgz | cut -d ' ' -f 1)"
local integrity="sha512-$(openssl dgst -sha512 -binary artifact/0xbuff-preceptor-0.0.1.tgz | openssl base64 -A)"
jq -n --arg digest "$APPROVED_DIGEST" --argjson bytes "$(wc -c < artifact/0xbuff-preceptor-0.0.1.tgz)" \
--arg commit "$GITHUB_SHA" --arg integrity "$integrity" '{
name:"@0xbuff/preceptor", version:"0.0.1", sha256:$digest, bytes:$bytes,
commit:$commit, integrity:$integrity, platform:"linux", filename:"0xbuff-preceptor-0.0.1.tgz",
APPROVED_DIGEST="$(sha256sum "artifact/$archive" | cut -d ' ' -f 1)"
local integrity="sha512-$(openssl dgst -sha512 -binary "artifact/$archive" | openssl base64 -A)"
jq -n --arg digest "$APPROVED_DIGEST" --argjson bytes "$(wc -c < "artifact/$archive")" \
--arg commit "$GITHUB_SHA" --arg integrity "$integrity" --arg version "$version" --arg archive "$archive" '{
name:"@0xbuff/preceptor", version:$version, sha256:$digest, bytes:$bytes,
commit:$commit, integrity:$integrity, platform:"linux", filename:$archive,
files: ["CHANGELOG.md","COPYRIGHT.md","LICENSE","README.md","dist/index.d.ts",
"dist/index.js","package.json"]
}' > artifact/evidence.json
Expand All @@ -61,6 +63,7 @@ reject() {
}

pack
[[ "$(bash "$preflight" filename)" == "$archive" ]]
[[ "$(bash "$preflight" run "$GITHUB_SHA" run-good.json)" == 2 ]]
bash "$preflight" archive artifact 2 "$artifact_name"

Expand All @@ -87,13 +90,16 @@ reject archive-digest env APPROVED_DIGEST=11111111111111111111111111111111111111

cp artifact/evidence.json manifest-good.json
for mutation in \
'.bytes+=1' '.sha256="wrong"' '.name="other"' '.version="0.0.0"' \
'.bytes+=1' '.sha256="wrong"' '.name="other"' '.version="0.0.1"' \
'.commit="wrong"' '.filename="wrong.tgz"' '.platform="win32"' '.integrity="wrong"' \
'.files|=.[1:]' '.files += ["extra"]'; do
jq "$mutation" manifest-good.json > artifact/evidence.json
reject archive-manifest bash "$preflight" archive artifact 2 "$artifact_name"
done
cp manifest-good.json artifact/evidence.json
mv "artifact/$archive" artifact/wrong.tgz
reject artifact-files bash "$preflight" archive artifact 2 "$artifact_name"
mv artifact/wrong.tgz "artifact/$archive"
touch artifact/extra
reject artifact-files bash "$preflight" archive artifact 2 "$artifact_name"
rm artifact/extra
Expand All @@ -119,7 +125,7 @@ rm package/README.md
printf 'synthetic\n' > package/README.md

for mutation in \
'.name="other"' '.version="0.0.0"' '.private=true' \
'.name="other"' '.version="0.0.1"' '.private=true' \
'.license="MIT"' '.type="commonjs"' '.dependencies={foo:"1.0.0"}' \
'.publishConfig.access="restricted"' '.publishConfig.registry="https://example.invalid/"'; do
jq "$mutation" metadata-good.json > package/package.json
Expand All @@ -128,7 +134,7 @@ for mutation in \
done
cp metadata-good.json package/package.json

for heading in '## [Unreleased]' '## [0.0.1] - 2026-02-30' '## [0.0.1] - 2026-11-99'; do
for heading in '## [Unreleased]' '## [0.0.1] - 2026-11-29' "## [$version] - 2026-02-30" "## [$version] - 2026-11-99" "$(printf '## [%s] - 2026-11-29\n## [%s] - 2026-11-30' "$version" "$version")"; do
printf '%s\n' "$heading" > package/CHANGELOG.md
pack
reject dated-notes bash "$preflight" archive artifact 2 "$artifact_name"
Expand All @@ -153,7 +159,7 @@ if [[ "$*" == "api repos/0xbuffdev/preceptor/git/ref/heads/main --jq .object.sha
exit 0
fi
if [[ "$CASE" == changed-final ]]; then
printf 'changed after validation\n' >> "$(cat "$TRACE.archive")/0xbuff-preceptor-0.0.1.tgz"
printf 'changed after validation\n' >> "$(cat "$TRACE.archive")/$archive"
fi
else
echo main >> "$TRACE"
Expand All @@ -176,7 +182,7 @@ elif [[ "$#" == 9 && "$1 $2 $3 $4 $5 $6 $7 $8" == \
[[ "$CASE" != failed-download ]] || exit 7
[[ "$9" == "$RUNNER_TEMP"/preceptor-release.*/artifact ]]
mkdir "$9"
cp "$FIXTURE/artifact/0xbuff-preceptor-0.0.1.tgz" "$FIXTURE/artifact/evidence.json" "$9/"
cp "$FIXTURE/artifact/$archive" "$FIXTURE/artifact/evidence.json" "$9/"
printf '%s\n' "$9" > "$TRACE.archive"
if [[ "$CASE" == rejected-archive ]]; then
jq '.bytes+=1' "$FIXTURE/artifact/evidence.json" > "$9/evidence.json"
Expand All @@ -196,9 +202,9 @@ if [[ "$#" == 1 && "$1" == --version ]]; then
fi
# Record any attempt before checking its arguments.
echo stage >> "$TRACE"
[[ "$*" == "stage publish ./0xbuff-preceptor-0.0.1.tgz --access public --tag latest --ignore-scripts --registry https://registry.npmjs.org/" ]]
[[ "$*" == "stage publish ./$archive --access public --tag latest --ignore-scripts --registry https://registry.npmjs.org/" ]]
[[ "$PWD" == "$(cat "$TRACE.archive")" ]]
[[ "$(sha256sum ./0xbuff-preceptor-0.0.1.tgz | cut -d ' ' -f 1)" == "$APPROVED_DIGEST" ]]
[[ "$(sha256sum ./$archive | cut -d ' ' -f 1)" == "$APPROVED_DIGEST" ]]
[[ -z "${NODE_AUTH_TOKEN+x}" && -z "${NPM_TOKEN+x}" ]]
STUB
cat > "$workspace/bin/node" <<'STUB'
Expand All @@ -218,7 +224,7 @@ orchestrate() {
GITHUB_REPOSITORY="$GITHUB_REPOSITORY" GITHUB_REF="$GITHUB_REF" \
GITHUB_SHA="$GITHUB_SHA" RUN_ID="$RUN_ID" APPROVED_RUN_ID="$APPROVED_RUN_ID" \
APPROVED_SHA="$APPROVED_SHA" APPROVED_DIGEST="$APPROVED_DIGEST" \
RUNNER_TEMP="$workspace/runner" FIXTURE="$workspace" TRACE="$trace" CASE="$scenario" \
RUNNER_TEMP="$workspace/runner" FIXTURE="$workspace" TRACE="$trace" CASE="$scenario" archive="$archive" \
NODE_AUTH_TOKEN=synthetic NPM_TOKEN=synthetic \
bash "$root/scripts/stage-release.sh" > "$trace.output" 2>&1 || status=$?
if [[ "$scenario" == approved ]]; then
Expand Down
Loading