From 2fe76b0db5e528c47bb2730d40aad0556af9cf88 Mon Sep 17 00:00:00 2001 From: salmonik Date: Fri, 30 Oct 2026 00:17:06 +0100 Subject: add publish script that names release artifacts from Cargo.toml and the target triple --- scripts/publish.sh | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ web/README.md | 25 ++++++++++++------------ 2 files changed, 70 insertions(+), 12 deletions(-) create mode 100755 scripts/publish.sh diff --git a/scripts/publish.sh b/scripts/publish.sh new file mode 100755 index 0000000..d8cc77a --- /dev/null +++ b/scripts/publish.sh @@ -0,0 +1,57 @@ +#!/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 [ "$kind" = client ] && [ "$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 + +echo +echo "published $VERSION to $DEST" +echo "prune old versions from $DEST by hand; the page lists every file it finds." diff --git a/web/README.md b/web/README.md index 5434e28..5de180d 100644 --- a/web/README.md +++ b/web/README.md @@ -31,23 +31,24 @@ zagan-bet-server--- ## Publishing a build -From the repository root, with the version taken from `Cargo.toml`: +From the repository root: ```sh -V=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1) +./scripts/publish.sh +``` -cargo build --release --target x86_64-unknown-linux-gnu -cargo build --release --bin client --no-default-features --target i686-unknown-linux-gnu -cargo build --release --bin client --target x86_64-pc-windows-gnu +It reads the version from `Cargo.toml`, builds all four artifacts and installs +them under `web/bin` with the names above. Override the destination with +`DEST=/srv/www/bin ./scripts/publish.sh`. -cp "target/x86_64-unknown-linux-gnu/release/server" "web/bin/server/zagan-bet-server-$V-linux-x86_64" -cp "target/x86_64-unknown-linux-gnu/release/client" "web/bin/client/zagan-bet-client-$V-linux-x86_64" -cp "target/i686-unknown-linux-gnu/release/client" "web/bin/client/zagan-bet-client-$V-linux-i686" -cp "target/x86_64-pc-windows-gnu/release/client.exe" "web/bin/client/zagan-bet-client-$V-windows-x86_64.exe" -``` +Builds are per target triple, so these must be installed: +`x86_64-unknown-linux-gnu`, `i686-unknown-linux-gnu` and +`x86_64-pc-windows-gnu`, plus the mingw linker for the Windows build. Client +builds always pass `--no-default-features`, which drops the server's OpenSSL +dependency; the client is rustls-only. -`--no-default-features` drops the server's OpenSSL dependency, which is what -the 32-bit client build would otherwise fail on. +Cargo itself cannot produce these names: it always writes +`target//release/`. The script renames after each build. ## Preview locally -- cgit v1.2.3