54 lines
1.7 KiB
Bash
Executable File
54 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
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."
|
|
fi
|
|
|
|
# 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
|
|
|
|
# 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"
|