Files
sized/scripts/release.sh
T
gamertan 9f36122e37
Sized Linux checks / Linux AMD64 / Rust 1.88.0 (pull_request) Successful in 5m2s
Sized Linux checks / Linux AMD64 / Rust 1.88.0 (push) Successful in 4m54s
Keep source and binary archives free of macOS metadata
2026-10-10 13:14:43 -04:00

60 lines
2.5 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# Build a host-target archive only. No tags, uploads, installers or signing.
repo_root=$(cd "$(dirname "$0")/.." && pwd)
cd "$repo_root"
version=$(sed -n 's/^version = "\([^"]*\)"/\1/p' Cargo.toml)
target=$(rustc -vV | sed -n 's/^host: //p')
revision=${SIZED_SOURCE_REVISION:-$(git rev-parse HEAD 2>/dev/null || printf unknown)}
destination="$repo_root/dist/sized-v$version-$target-${revision:0:12}"
if [[ $# == 2 && $1 == --output-dir ]]; then
destination=$2
elif [[ $# != 0 ]]; then
printf 'Usage: %s [--output-dir ABSOLUTE_PATH]\n' "$0" >&2
exit 2
fi
[[ $destination == /* ]] || { printf 'Output directory must be absolute.\n' >&2; exit 2; }
for output in "$destination" "$destination.tar.gz" "$destination.tar.gz.sha256"; do
[[ ! -e $output && ! -L $output ]] || { printf 'Refusing to replace %s\n' "$output" >&2; exit 1; }
done
target_dir=${CARGO_TARGET_DIR:-"$repo_root/target"}
[[ $target_dir == /* ]] || target_dir="$repo_root/$target_dir"
python3 scripts/check-core.py
cargo build --locked --release --target "$target" --target-dir "$target_dir"
binary="$target_dir/$target/release/sized"
mkdir -p "$destination"
install -m 755 "$binary" "$destination/sized"
"$binary" --generate-man-page "$destination"
"$binary" --completions bash > "$destination/sized.bash"
"$binary" --completions zsh > "$destination/_sized"
"$binary" --completions fish > "$destination/sized.fish"
cp LICENSE README.md MANUAL.md CORE-SNAPSHOT.json "$destination/"
cp -R docs "$destination/"
python3 scripts/package-notices.py "$destination" --revision "$revision"
{
printf 'Version: %s\nTarget: %s\nSource revision: %s\n' "$version" "$target" "$revision"
printf 'Source worktree: '
if [[ $(git rev-parse --show-toplevel 2>/dev/null || true) == "$repo_root" ]]; then
if git diff --quiet HEAD --; then printf 'clean tracked files\n'; else printf 'modified tracked files\n'; fi
else
printf 'exported source; verify against supplied revision\n'
fi
rustc --version
cargo --version
printf 'Unsigned host build; not a notarized Mac application.\n'
} > "$destination/BUILD-INFO.txt"
COPYFILE_DISABLE=1 tar --no-xattrs -czf "$destination.tar.gz" -C "$destination" .
(
cd "$(dirname "$destination")"
archive="$(basename "$destination").tar.gz"
if command -v sha256sum >/dev/null 2>&1; then
sha256sum "$archive" > "$archive.sha256"
else
shasum -a 256 "$archive" > "$archive.sha256"
fi
)
printf 'Archive: %s.tar.gz\nChecksum: %s.tar.gz.sha256\n' "$destination" "$destination"