#!/usr/bin/env bash # Build the release artifacts and publish them under web/bin with the names the # download page expects: # # zagan-bet-client---[.exe] # zagan-bet-server--- # # Cargo always writes target//release/, so the rename happens here # after each build. The version comes from Cargo.toml. # # Usage: # ./scripts/publish.sh # DEST=/srv/www/bin ./scripts/publish.sh set -euo pipefail ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) cd "$ROOT" VERSION=$(awk -F'"' '/^version = / { print $2; exit }' Cargo.toml) if [ -z "${VERSION:-}" ]; then echo "could not read the version from Cargo.toml" >&2 exit 1 fi DEST=${DEST:-web/bin} publish() { local triple=$1 kind=$2 platform=$3 arch=$4 local ext="" if [ "$platform" = windows ]; then ext=".exe" fi local artifact="zagan-bet-$kind-$VERSION-$platform-$arch$ext" local source="target/$triple/release/$kind$ext" echo "==> $artifact" if [ "$kind" = client ]; then # rustls-only: never link the server's OpenSSL. cargo build --release --quiet --bin client --no-default-features --target "$triple" else cargo build --release --quiet --bin server --target "$triple" fi mkdir -p "$DEST/$kind" install -m 0755 "$source" "$DEST/$kind/$artifact" echo " $DEST/$kind/$artifact ($(du -h "$DEST/$kind/$artifact" | cut -f1))" } publish x86_64-unknown-linux-gnu client linux x86_64 publish i686-unknown-linux-gnu client linux i686 publish x86_64-pc-windows-gnu client windows x86_64 publish x86_64-unknown-linux-gnu server linux x86_64 publish x86_64-pc-windows-gnu server windows x86_64 echo echo "published $VERSION to $DEST" echo "prune old versions from $DEST by hand; the page lists every file it finds."