#!/usr/bin/env bash # Gather what `cargo tauri build` made for one target into release assets: # # bash release/collect.sh # # is target//release/bundle. Each asset is named # wai-quantum-desktop--.: on macOS the disk image (.dmg) # and the app as an update installs it (.app.tar.gz); on Linux the AppImage, # the Debian package (.deb) and the RPM package (.rpm). Beside each one goes its # SHA-256 (.sha256, as `shasum -a 256 -c` reads it) and, when the build # was signed for updates, its update signature (.sig). A kind the bundle # should hold and does not, or holds twice, fails the collection. Windows # collects in PowerShell, in the release workflow. set -euo pipefail if [ $# -ne 4 ]; then echo "usage: bash release/collect.sh " >&2 exit 2 fi B="$1"; VERSION="$2"; TRIPLE="$3"; OUT="$4" NAME="wai-quantum-desktop-$VERSION-$TRIPLE" mkdir -p "$OUT" sha() { ( cd "$OUT" && { command -v sha256sum >/dev/null && sha256sum "$1" || shasum -a 256 "$1"; } > "$1.sha256" ); } # One file in $1 matching the glob $2, copied as $NAME.$3, with its .sig when there is one. one() { local dir="$1" glob="$2" kind="$3" found=() shopt -s nullglob found=("$dir"/$glob) shopt -u nullglob [ "${#found[@]}" -eq 1 ] || { echo "::error::$dir holds ${#found[@]} files matching $glob, not one: ${found[*]:-none}" >&2; exit 1; } cp "${found[0]}" "$OUT/$NAME.$kind" sha "$NAME.$kind" if [ -f "${found[0]}.sig" ]; then cp "${found[0]}.sig" "$OUT/$NAME.$kind.sig" fi echo "collected $OUT/$NAME.$kind ($(cut -d' ' -f1 "$OUT/$NAME.$kind.sha256"))$([ -f "$OUT/$NAME.$kind.sig" ] && echo ', signed for updates')" } case "$TRIPLE" in *-apple-darwin) one "$B/dmg" '*.dmg' dmg # The app itself, as an update installs it: made only when the build is signed for updates. if compgen -G "$B/macos/*.app.tar.gz" > /dev/null; then one "$B/macos" '*.app.tar.gz' app.tar.gz; fi ;; *-linux-gnu) one "$B/appimage" '*.AppImage' AppImage one "$B/deb" '*.deb' deb one "$B/rpm" '*.rpm' rpm ;; *) echo "::error::release/collect.sh does not collect $TRIPLE" >&2; exit 2 ;; esac