acquire-inputs.sh
bash
sha256:bd1eb24434d281fe65142038c1bf217493421f5a86880c22dff7e6037d2d4700
feat(companion): add production macOS distribution path
Human
minor
⚠ breaking
25 days ago
| 1 | #!/bin/bash |
| 2 | set -euo pipefail |
| 3 | |
| 4 | repo_root="$(cd "$(dirname "$0")/../../.." && pwd)" |
| 5 | lock_file="$repo_root/release/macos/release-lock.json" |
| 6 | output_dir="$repo_root/build/release-inputs" |
| 7 | |
| 8 | while [[ $# -gt 0 ]]; do |
| 9 | case "$1" in |
| 10 | --lock) lock_file="$2"; shift 2 ;; |
| 11 | --output) output_dir="$2"; shift 2 ;; |
| 12 | *) echo "unknown argument: $1" >&2; exit 2 ;; |
| 13 | esac |
| 14 | done |
| 15 | |
| 16 | lock_file="$(cd "$(dirname "$lock_file")" && pwd)/$(basename "$lock_file")" |
| 17 | if [[ "$output_dir" != /* ]]; then output_dir="$PWD/$output_dir"; fi |
| 18 | |
| 19 | for command in curl node shasum tar; do |
| 20 | command -v "$command" >/dev/null || { echo "missing command: $command" >&2; exit 1; } |
| 21 | done |
| 22 | |
| 23 | mkdir -p "$output_dir/downloads" "$output_dir/model" |
| 24 | |
| 25 | node_url="$(node -e 'const j=require(process.argv[1]); process.stdout.write(j.node.url)' "$lock_file")" |
| 26 | node_sha="$(node -e 'const j=require(process.argv[1]); process.stdout.write(j.node.sha256)' "$lock_file")" |
| 27 | node_archive="$(node -e 'const j=require(process.argv[1]); process.stdout.write(j.node.archive)' "$lock_file")" |
| 28 | node_download="$output_dir/downloads/$node_archive" |
| 29 | |
| 30 | curl --fail --location --proto '=https' --tlsv1.2 --output "$node_download.part" "$node_url" |
| 31 | actual_node_sha="$(shasum -a 256 "$node_download.part" | awk '{print $1}')" |
| 32 | [[ "$actual_node_sha" == "$node_sha" ]] || { echo "Node runtime digest mismatch" >&2; exit 1; } |
| 33 | mv "$node_download.part" "$node_download" |
| 34 | mkdir -p "$output_dir/node" |
| 35 | tar -xzf "$node_download" --strip-components=1 -C "$output_dir/node" |
| 36 | [[ "$($output_dir/node/bin/node --version)" == "v24.21.0" ]] || { |
| 37 | echo "Node runtime version mismatch" >&2; exit 1; |
| 38 | } |
| 39 | [[ "$($output_dir/node/bin/npm --version)" == "11.19.0" ]] || { |
| 40 | echo "bundled npm version mismatch" >&2; exit 1; |
| 41 | } |
| 42 | |
| 43 | model_list="$output_dir/model-downloads.tsv" |
| 44 | node - "$lock_file" > "$model_list" <<'NODE' |
| 45 | const lock = require(process.argv[2]); |
| 46 | for (const file of lock.model.files) { |
| 47 | process.stdout.write([file.path, file.url, file.sha256, file.bytes].join('\t') + '\n'); |
| 48 | } |
| 49 | NODE |
| 50 | |
| 51 | while IFS=$'\t' read -r relative_path url expected_sha expected_bytes; do |
| 52 | destination="$output_dir/model/$relative_path" |
| 53 | mkdir -p "$(dirname "$destination")" |
| 54 | curl --fail --location --proto '=https' --tlsv1.2 --output "$destination.part" "$url" |
| 55 | actual_sha="$(shasum -a 256 "$destination.part" | awk '{print $1}')" |
| 56 | actual_bytes="$(stat -f '%z' "$destination.part")" |
| 57 | [[ "$actual_sha" == "$expected_sha" ]] || { echo "model digest mismatch: $relative_path" >&2; exit 1; } |
| 58 | [[ "$actual_bytes" == "$expected_bytes" ]] || { echo "model size mismatch: $relative_path" >&2; exit 1; } |
| 59 | mv "$destination.part" "$destination" |
| 60 | done < "$model_list" |
| 61 | |
| 62 | cp "$lock_file" "$output_dir/release-lock.json" |
| 63 | shasum -a 256 "$lock_file" > "$output_dir/release-lock.sha256" |
| 64 | echo "Verified release inputs: $output_dir" |
File History
1 commit
sha256:bd1eb24434d281fe65142038c1bf217493421f5a86880c22dff7e6037d2d4700
feat(companion): add production macOS distribution path
Human
minor
⚠
25 days ago