Skip to content

Commit 56ce22a

Browse files
authored
Merge pull request #11 from instructa/codex/non-destructive-release-0.2.1
Support verified non-destructive Switchloom releases
2 parents 38913e4 + 16b3b57 commit 56ce22a

1 file changed

Lines changed: 42 additions & 4 deletions

File tree

scripts/release.sh

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#
66
# Usage: scripts/release.sh <x.y.z[-alpha.N|-beta.N|-rc.N]> "release summary"
77
# Dry run: RELEASE_DRY_RUN=1 scripts/release.sh <current-version> "summary"
8+
# Non-destructive local mode (requires a green RC matrix for the same tree):
9+
# SWITCHLOOM_RC_RUN_ID=<run> SWITCHLOOM_RELEASE_REUSE_DEPS=1 scripts/release.sh ...
810
set -eu
911

1012
cd "$(dirname "$0")/.."
@@ -44,6 +46,27 @@ if ! grep -q "^## \[$version\]" CHANGELOG.md; then
4446
exit 1
4547
fi
4648

49+
rc_run_id="${SWITCHLOOM_RC_RUN_ID:-}"
50+
reuse_deps="${SWITCHLOOM_RELEASE_REUSE_DEPS:-0}"
51+
if [ "$reuse_deps" = "1" ] && [ -z "$rc_run_id" ]; then
52+
echo "SWITCHLOOM_RELEASE_REUSE_DEPS=1 requires SWITCHLOOM_RC_RUN_ID" >&2
53+
exit 1
54+
fi
55+
if [ -n "$rc_run_id" ]; then
56+
rc_line="$(gh run view "$rc_run_id" --json conclusion,headSha --jq '.conclusion + " " + .headSha')"
57+
rc_conclusion="${rc_line%% *}"
58+
rc_sha="${rc_line#* }"
59+
if [ "$rc_conclusion" != "success" ]; then
60+
echo "release candidate run $rc_run_id is not successful: $rc_conclusion" >&2
61+
exit 1
62+
fi
63+
if [ "$(git rev-parse "$rc_sha^{tree}")" != "$(git rev-parse 'HEAD^{tree}')" ]; then
64+
echo "release candidate run $rc_run_id does not match the current source tree" >&2
65+
exit 1
66+
fi
67+
echo "verified release candidate run $rc_run_id for source tree $rc_sha"
68+
fi
69+
4770
current_version="$(sed -n 's/^version = "\([^"]*\)"/\1/p' Cargo.toml | head -n 1)"
4871
if [ "${RELEASE_DRY_RUN:-0}" = "1" ] && [ "$version" != "$current_version" ]; then
4972
echo "dry runs require the current manifest version ($current_version)" >&2
@@ -72,12 +95,27 @@ node scripts/regenerate-preset-catalog.mjs
7295
cargo fmt --all -- --check
7396
cargo clippy --workspace --all-targets --all-features -- -D warnings
7497
cargo test --workspace --all-targets --all-features
75-
pnpm install --frozen-lockfile
76-
pnpm site:check
77-
pnpm pack:check
98+
if [ "$reuse_deps" = "1" ]; then
99+
test -x node_modules/.bin/vitest
100+
test -x node_modules/.bin/astro
101+
./node_modules/.bin/vitest run
102+
node --test website/alchemy-runtime.test.mjs website/cloudflare-launcher.test.mjs
103+
./node_modules/.bin/astro check
104+
./node_modules/.bin/astro build
105+
node scripts/build-site.mjs
106+
bash scripts/npm-pack-check.sh
107+
else
108+
pnpm install --frozen-lockfile
109+
pnpm site:check
110+
pnpm pack:check
111+
fi
78112
cargo package --locked --allow-dirty --no-verify
79113
scripts/secleak-check.sh
80-
scripts/build-release.sh
114+
if [ -n "$rc_run_id" ]; then
115+
echo "release archives already verified by release candidate run $rc_run_id"
116+
else
117+
scripts/build-release.sh
118+
fi
81119
SWITCHLOOM_NATIVE_BIN="$(pwd)/target/release/model-routing" node npm/bin/model-routing.js --version
82120

83121
if [ "${RELEASE_DRY_RUN:-0}" = "1" ]; then

0 commit comments

Comments
 (0)