Something went wrong. Try again.
🎩 Robust alfred alfred.schembri.me
alfred
Something went wrong. Try again.
1.5 kB · 48 lines
at main
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849#!/bin/sh# Build a universal (Apple silicon + Intel) package of one workflow from a# clean checkout of <rev>, so local configuration (prefs.plist) and# uncommitted work can't ship.## scripts/package <name> [rev] -> dist/robust-alfred-<name>.alfredworkflowset -euname=$1rev=${2:-HEAD}root=$(cd "$(dirname "$0")/.." && pwd)bin=robust-alfred-$nameout=$root/dist/$bin.alfredworkflowwork=$(mktemp -d)trap 'git -C "$root" worktree remove --force "$work/src" 2>/dev/null; trash "$work"' EXITgit -C "$root" worktree add --quiet --detach "$work/src" "$rev"# Reuse the repo's build cache; only the sources come from the checkout.export CARGO_TARGET_DIR="$root/target"for target in aarch64-apple-darwin x86_64-apple-darwin; do cargo build --quiet --release --locked \ --manifest-path "$work/src/Cargo.toml" -p "$bin" --target "$target"donepkg=$work/pkgcp -R "$work/src/workflows/$name/workflow" "$pkg"lipo -create -output "$pkg/$bin" \ "$CARGO_TARGET_DIR/aarch64-apple-darwin/release/$bin" \ "$CARGO_TARGET_DIR/x86_64-apple-darwin/release/$bin"if [ -e "$pkg/prefs.plist" ]; then echo "error: prefs.plist would be packaged" >&2 exit 1fiarchs=$(lipo -archs "$pkg/$bin")case "$archs" in*arm64*x86_64* | *x86_64*arm64*) ;;*) echo "error: binary has architectures '$archs', expected arm64 and x86_64" >&2 exit 1 ;;esacmkdir -p "$root/dist"[ ! -e "$out" ] || trash "$out"(cd "$pkg" && zip -qrX "$out" .)echo "$out"