|
5 | 5 | # |
6 | 6 | # Usage: scripts/release.sh <x.y.z[-alpha.N|-beta.N|-rc.N]> "release summary" |
7 | 7 | # 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 ... |
8 | 10 | set -eu |
9 | 11 |
|
10 | 12 | cd "$(dirname "$0")/.." |
@@ -44,6 +46,27 @@ if ! grep -q "^## \[$version\]" CHANGELOG.md; then |
44 | 46 | exit 1 |
45 | 47 | fi |
46 | 48 |
|
| 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 | + |
47 | 70 | current_version="$(sed -n 's/^version = "\([^"]*\)"/\1/p' Cargo.toml | head -n 1)" |
48 | 71 | if [ "${RELEASE_DRY_RUN:-0}" = "1" ] && [ "$version" != "$current_version" ]; then |
49 | 72 | echo "dry runs require the current manifest version ($current_version)" >&2 |
@@ -72,12 +95,27 @@ node scripts/regenerate-preset-catalog.mjs |
72 | 95 | cargo fmt --all -- --check |
73 | 96 | cargo clippy --workspace --all-targets --all-features -- -D warnings |
74 | 97 | 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 |
78 | 112 | cargo package --locked --allow-dirty --no-verify |
79 | 113 | 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 |
81 | 119 | SWITCHLOOM_NATIVE_BIN="$(pwd)/target/release/model-routing" node npm/bin/model-routing.js --version |
82 | 120 |
|
83 | 121 | if [ "${RELEASE_DRY_RUN:-0}" = "1" ]; then |
|
0 commit comments