blob: fbcd5884da87687de75f2a0e0aba3bc09e6c7933 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
#!/usr/bin/env bash
# Build the release artifacts and publish them under web/bin with the names the
# download page expects:
#
# zagan-bet-client-<version>-<platform>-<arch>[.exe]
# zagan-bet-server-<version>-<platform>-<arch>[.exe]
# zagan-bet-gui-<version>-<platform>-<arch>[.exe]
#
# Cargo always writes target/<triple>/<profile>/<bin>, so the rename happens
# here after each build. The version comes from Cargo.toml.
#
# The GUI uses the workspace's `gui-release` profile (small, stripped, LTO).
# The installers are stable site files (web/install.sh and web/install.ps1):
# they ask web/latest.php for the newest build, so they are not regenerated
# here. The public git repository is the GPL source for these binaries, so
# publish from a clean tree (or set ALLOW_DIRTY=1 for a preview).
#
# 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}
if [ "${ALLOW_DIRTY:-0}" != "1" ] && [ -n "$(git status --porcelain)" ]; then
echo "the working tree is dirty; commit the release first (or ALLOW_DIRTY=1)" >&2
exit 1
fi
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_gui() {
local triple=$1 platform=$2 arch=$3
local ext=""
if [ "$platform" = windows ]; then
ext=".exe"
fi
local artifact="zagan-bet-gui-$VERSION-$platform-$arch$ext"
local source="target/$triple/gui-release/zagan-bet-gui$ext"
echo "==> $artifact"
cargo build -p zagan-bet-gui --profile gui-release --quiet --target "$triple"
mkdir -p "$DEST/gui"
install -m 0755 "$source" "$DEST/gui/$artifact"
echo " $DEST/gui/$artifact ($(du -h "$DEST/gui/$artifact" | cut -f1))"
}
rm web/bin/client/*
rm web/bin/gui/*
rm web/bin/server/*
publish_gui x86_64-unknown-linux-gnu linux x86_64
publish_gui x86_64-pc-windows-gnu windows x86_64
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."
|