Repair release archives and document current Sized distribution
Sized Linux checks / Linux AMD64 / Rust 1.88.0 (push) Successful in 4m52s
Sized Linux checks / Linux AMD64 / Rust 1.88.0 (pull_request) Successful in 4m56s

This commit is contained in:
2026-10-10 03:51:35 -04:00
parent 9fd4e905b0
commit 5f0b11ea2e
9 changed files with 233 additions and 148 deletions
+52 -49
View File
@@ -1,53 +1,56 @@
#!/bin/bash
set -e
#!/usr/bin/env bash
set -euo pipefail
VERSION=$(grep '^version =' Cargo.toml | cut -d '"' -f 2)
DIST_DIR="dist/v$VERSION"
echo "Building release assets for sized v$VERSION..."
# 1. Clean and Prepare
rm -rf "$DIST_DIR"
mkdir -p "$DIST_DIR"
# 2. Build Release Binary
cargo build --release
# 3. Generate Man Page
cargo run --release -- --generate-man-page "$DIST_DIR"
# 4. Generate Completions
cargo run --release -- --completions bash > "$DIST_DIR/sized.bash"
cargo run --release -- --completions zsh > "$DIST_DIR/_sized"
cargo run --release -- --completions fish > "$DIST_DIR/sized.fish"
# 5. Build Debian Package (if cargo-deb is installed)
if command -v cargo-deb &> /dev/null; then
echo "Building Debian package..."
# On macOS, we use --no-strip to avoid 'unrecognized option: --strip-unneeded'
# and --no-build because we already built the release binary.
cargo deb --no-build --no-strip
cp target/debian/*.deb "$DIST_DIR/"
echo "Note: .deb package contains the binary for $(uname -s)-$(uname -m)"
else
echo "Warning: cargo-deb not found. Skipping .deb packaging."
# 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 ]] || { printf 'Refusing to replace %s\n' "$output" >&2; exit 1; }
done
# 6. Build Alpine Package (Placeholder/Hook)
# Note: For real .apk building, one usually uses a docker container or abuild.
# This serves as a reminder for Alpine users.
if [ -f "APKBUILD" ] && command -v abuild &> /dev/null; then
echo "Building Alpine package..."
abuild -r
fi
target_dir=${CARGO_TARGET_DIR:-"$repo_root/target"}
[[ $target_dir == /* ]] || target_dir="$repo_root/$target_dir"
cargo build --locked --release --target "$target"
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 "$destination/"
{
printf 'Version: %s\nTarget: %s\nSource revision: %s\n' "$version" "$target" "$revision"
printf 'Source worktree: '
if git rev-parse --is-inside-work-tree >/dev/null 2>&1; 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"
# 7. Create General Release Tarball
echo "Creating release tarball..."
tar -czf "dist/sized-v$VERSION-$(uname -s)-$(uname -m).tar.gz" -C "$DIST_DIR" .
# 8. Copy Binary
cp target/release/sized "$DIST_DIR/"
echo "Success! Assets are ready in $DIST_DIR"
ls -F "$DIST_DIR"
echo "Tarball: dist/sized-v$VERSION-$(uname -s)-$(uname -m).tar.gz"
tar -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"