#!/usr/bin/env bash # Builds the client for every target from this checkout and puts the # builds on a host, for its knotless-serve to hand out at /install.sh. # # deploy/release.sh # KNOTLESS_HOST=root@host deploy/release.sh # # or with it in deploy/local.env (see local.env.example). The version is # the workspace's, in Cargo.toml, and becomes the latest. # # Built here, on a Mac: both macOS targets natively and Linux, static, # with cargo-zigbuild (`brew install zig`, `cargo install cargo-zigbuild`). # Optional: KNOTLESS_DATA (/var/lib/knotless), the server's state on the # host, whose releases/ the builds go in. set -euo pipefail cd "$(dirname "$0")/.." [ -f deploy/local.env ] && { set -a; . deploy/local.env; set +a; } DEST="${1:-${KNOTLESS_HOST:-}}" [ -n "$DEST" ] || { sed -n '4,5p' "$0" >&2; exit 2; } DATA="${KNOTLESS_DATA:-/var/lib/knotless}" CARGO="rustup run stable cargo" # rustup's rustc, which has the other targets, rather than whichever is # first on the PATH (Homebrew's has only this machine's). RUSTC="$(rustup which --toolchain stable rustc)" export RUSTC VERSION="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)" OUT="target/release-$VERSION" SSH="ssh -o StrictHostKeyChecking=accept-new $DEST" CARGO="$CARGO" deploy/build-client.sh "$OUT" (cd "$OUT" && for f in *.tar.gz; do shasum -a 256 "$f" > "$f.sha256"; done) echo "→ putting $VERSION on $DEST" $SSH "mkdir -p '$DATA/releases/$VERSION'" scp -q -o StrictHostKeyChecking=accept-new "$OUT"/*.tar.gz "$OUT"/*.sha256 "$DEST:$DATA/releases/$VERSION/" # Latest last, and moved into place, so no install sees a version half there. $SSH " set -e echo '$VERSION' > '$DATA/releases/.latest' mv '$DATA/releases/.latest' '$DATA/releases/latest' chown -R 1000:1000 '$DATA/releases' " echo "→ done: $VERSION is the latest"