diff options
| author | salmonik <salmonik@tuta.io> | 2026-10-30 00:17:06 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-10-30 00:17:06 +0100 |
| commit | 2fe76b0db5e528c47bb2730d40aad0556af9cf88 (patch) | |
| tree | b7ef0bc39ae42aafb92cccab1608505e9659f2d3 | |
| parent | strip the download page to plain HTML: no CSS, sha256sum-format checksums (diff) | |
| download | zagan-bet-2fe76b0db5e528c47bb2730d40aad0556af9cf88.tar.gz zagan-bet-2fe76b0db5e528c47bb2730d40aad0556af9cf88.zip | |
add publish script that names release artifacts from Cargo.toml and the target triple
| -rwxr-xr-x | scripts/publish.sh | 57 | ||||
| -rw-r--r-- | web/README.md | 25 |
2 files changed, 70 insertions, 12 deletions
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 @@ | |||
| 1 | #!/usr/bin/env bash | ||
| 2 | # Build the release artifacts and publish them under web/bin with the names the | ||
| 3 | # download page expects: | ||
| 4 | # | ||
| 5 | # zagan-bet-client-<version>-<platform>-<arch>[.exe] | ||
| 6 | # zagan-bet-server-<version>-<platform>-<arch> | ||
| 7 | # | ||
| 8 | # Cargo always writes target/<triple>/release/<bin>, so the rename happens here | ||
| 9 | # after each build. The version comes from Cargo.toml. | ||
| 10 | # | ||
| 11 | # Usage: | ||
| 12 | # ./scripts/publish.sh | ||
| 13 | # DEST=/srv/www/bin ./scripts/publish.sh | ||
| 14 | set -euo pipefail | ||
| 15 | |||
| 16 | ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) | ||
| 17 | cd "$ROOT" | ||
| 18 | |||
| 19 | VERSION=$(awk -F'"' '/^version = / { print $2; exit }' Cargo.toml) | ||
| 20 | if [ -z "${VERSION:-}" ]; then | ||
| 21 | echo "could not read the version from Cargo.toml" >&2 | ||
| 22 | exit 1 | ||
| 23 | fi | ||
| 24 | |||
| 25 | DEST=${DEST:-web/bin} | ||
| 26 | |||
| 27 | publish() { | ||
| 28 | local triple=$1 kind=$2 platform=$3 arch=$4 | ||
| 29 | local ext="" | ||
| 30 | if [ "$kind" = client ] && [ "$platform" = windows ]; then | ||
| 31 | ext=".exe" | ||
| 32 | fi | ||
| 33 | |||
| 34 | local artifact="zagan-bet-$kind-$VERSION-$platform-$arch$ext" | ||
| 35 | local source="target/$triple/release/$kind$ext" | ||
| 36 | |||
| 37 | echo "==> $artifact" | ||
| 38 | if [ "$kind" = client ]; then | ||
| 39 | # rustls-only: never link the server's OpenSSL. | ||
| 40 | cargo build --release --quiet --bin client --no-default-features --target "$triple" | ||
| 41 | else | ||
| 42 | cargo build --release --quiet --bin server --target "$triple" | ||
| 43 | fi | ||
| 44 | |||
| 45 | mkdir -p "$DEST/$kind" | ||
| 46 | install -m 0755 "$source" "$DEST/$kind/$artifact" | ||
| 47 | echo " $DEST/$kind/$artifact ($(du -h "$DEST/$kind/$artifact" | cut -f1))" | ||
| 48 | } | ||
| 49 | |||
| 50 | publish x86_64-unknown-linux-gnu client linux x86_64 | ||
| 51 | publish i686-unknown-linux-gnu client linux i686 | ||
| 52 | publish x86_64-pc-windows-gnu client windows x86_64 | ||
| 53 | publish x86_64-unknown-linux-gnu server linux x86_64 | ||
| 54 | |||
| 55 | echo | ||
| 56 | echo "published $VERSION to $DEST" | ||
| 57 | 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-<version>-<platform>-<arch> | |||
| 31 | 31 | ||
| 32 | ## Publishing a build | 32 | ## Publishing a build |
| 33 | 33 | ||
| 34 | From the repository root, with the version taken from `Cargo.toml`: | 34 | From the repository root: |
| 35 | 35 | ||
| 36 | ```sh | 36 | ```sh |
| 37 | V=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1) | 37 | ./scripts/publish.sh |
| 38 | ``` | ||
| 38 | 39 | ||
| 39 | cargo build --release --target x86_64-unknown-linux-gnu | 40 | It reads the version from `Cargo.toml`, builds all four artifacts and installs |
| 40 | cargo build --release --bin client --no-default-features --target i686-unknown-linux-gnu | 41 | them under `web/bin` with the names above. Override the destination with |
| 41 | cargo build --release --bin client --target x86_64-pc-windows-gnu | 42 | `DEST=/srv/www/bin ./scripts/publish.sh`. |
| 42 | 43 | ||
| 43 | cp "target/x86_64-unknown-linux-gnu/release/server" "web/bin/server/zagan-bet-server-$V-linux-x86_64" | 44 | Builds are per target triple, so these must be installed: |
| 44 | cp "target/x86_64-unknown-linux-gnu/release/client" "web/bin/client/zagan-bet-client-$V-linux-x86_64" | 45 | `x86_64-unknown-linux-gnu`, `i686-unknown-linux-gnu` and |
| 45 | cp "target/i686-unknown-linux-gnu/release/client" "web/bin/client/zagan-bet-client-$V-linux-i686" | 46 | `x86_64-pc-windows-gnu`, plus the mingw linker for the Windows build. Client |
| 46 | cp "target/x86_64-pc-windows-gnu/release/client.exe" "web/bin/client/zagan-bet-client-$V-windows-x86_64.exe" | 47 | builds always pass `--no-default-features`, which drops the server's OpenSSL |
| 47 | ``` | 48 | dependency; the client is rustls-only. |
| 48 | 49 | ||
| 49 | `--no-default-features` drops the server's OpenSSL dependency, which is what | 50 | Cargo itself cannot produce these names: it always writes |
| 50 | the 32-bit client build would otherwise fail on. | 51 | `target/<triple>/release/<bin>`. The script renames after each build. |
| 51 | 52 | ||
| 52 | ## Preview locally | 53 | ## Preview locally |
| 53 | 54 | ||
