diff options
Diffstat (limited to 'scripts/publish.sh')
| -rwxr-xr-x | scripts/publish.sh | 66 |
1 files changed, 62 insertions, 4 deletions
diff --git a/scripts/publish.sh b/scripts/publish.sh index 8240859..3a04631 100755 --- a/scripts/publish.sh +++ b/scripts/publish.sh | |||
| @@ -3,14 +3,22 @@ | |||
| 3 | # download page expects: | 3 | # download page expects: |
| 4 | # | 4 | # |
| 5 | # zagan-bet-client-<version>-<platform>-<arch>[.exe] | 5 | # zagan-bet-client-<version>-<platform>-<arch>[.exe] |
| 6 | # zagan-bet-server-<version>-<platform>-<arch> | 6 | # zagan-bet-server-<version>-<platform>-<arch>[.exe] |
| 7 | # zagan-bet-gui-<version>-<platform>-<arch>[.exe] | ||
| 8 | # zagan-bet-gui-<version>-<platform>-<arch>-install.sh | ||
| 9 | # zagan-bet-gui-<version>-<platform>-<arch>-install.ps1 | ||
| 7 | # | 10 | # |
| 8 | # Cargo always writes target/<triple>/release/<bin>, so the rename happens here | 11 | # Cargo always writes target/<triple>/<profile>/<bin>, so the rename happens |
| 9 | # after each build. The version comes from Cargo.toml. | 12 | # here after each build. The version comes from Cargo.toml. |
| 13 | # | ||
| 14 | # The GUI uses the workspace's `gui-release` profile (small, stripped, LTO). | ||
| 15 | # The public git repository is the GPL source for these binaries, so publish | ||
| 16 | # from a clean tree (or set ALLOW_DIRTY=1 for a preview). | ||
| 10 | # | 17 | # |
| 11 | # Usage: | 18 | # Usage: |
| 12 | # ./scripts/publish.sh | 19 | # ./scripts/publish.sh |
| 13 | # DEST=/srv/www/bin ./scripts/publish.sh | 20 | # DEST=/srv/www/bin ./scripts/publish.sh |
| 21 | # URL_BASE=https://staging.example/ ./scripts/publish.sh | ||
| 14 | set -euo pipefail | 22 | set -euo pipefail |
| 15 | 23 | ||
| 16 | ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) | 24 | ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) |
| @@ -23,6 +31,21 @@ if [ -z "${VERSION:-}" ]; then | |||
| 23 | fi | 31 | fi |
| 24 | 32 | ||
| 25 | DEST=${DEST:-web/bin} | 33 | DEST=${DEST:-web/bin} |
| 34 | URL_BASE=${URL_BASE:-https://zagan.2137697.xyz} | ||
| 35 | |||
| 36 | if [ "${ALLOW_DIRTY:-0}" != "1" ] && [ -n "$(git status --porcelain)" ]; then | ||
| 37 | echo "the working tree is dirty; commit the release first (or ALLOW_DIRTY=1)" >&2 | ||
| 38 | exit 1 | ||
| 39 | fi | ||
| 40 | |||
| 41 | command -v python3 >/dev/null || { | ||
| 42 | echo "python3 is required to render the installers" >&2 | ||
| 43 | exit 1 | ||
| 44 | } | ||
| 45 | |||
| 46 | hash_of() { | ||
| 47 | sha256sum "$1" | awk '{print $1}' | ||
| 48 | } | ||
| 26 | 49 | ||
| 27 | publish() { | 50 | publish() { |
| 28 | local triple=$1 kind=$2 platform=$3 arch=$4 | 51 | local triple=$1 kind=$2 platform=$3 arch=$4 |
| @@ -47,11 +70,46 @@ publish() { | |||
| 47 | echo " $DEST/$kind/$artifact ($(du -h "$DEST/$kind/$artifact" | cut -f1))" | 70 | echo " $DEST/$kind/$artifact ($(du -h "$DEST/$kind/$artifact" | cut -f1))" |
| 48 | } | 71 | } |
| 49 | 72 | ||
| 73 | publish_gui() { | ||
| 74 | local triple=$1 platform=$2 arch=$3 | ||
| 75 | local ext="" | ||
| 76 | if [ "$platform" = windows ]; then | ||
| 77 | ext=".exe" | ||
| 78 | fi | ||
| 79 | |||
| 80 | local artifact="zagan-bet-gui-$VERSION-$platform-$arch$ext" | ||
| 81 | local source="target/$triple/gui-release/zagan-bet-gui$ext" | ||
| 82 | |||
| 83 | echo "==> $artifact" | ||
| 84 | cargo build -p zagan-bet-gui --profile gui-release --quiet --target "$triple" | ||
| 85 | |||
| 86 | mkdir -p "$DEST/gui" | ||
| 87 | install -m 0755 "$source" "$DEST/gui/$artifact" | ||
| 88 | local sha | ||
| 89 | sha=$(hash_of "$DEST/gui/$artifact") | ||
| 90 | echo " $DEST/gui/$artifact ($(du -h "$DEST/gui/$artifact" | cut -f1))" | ||
| 91 | |||
| 92 | if [ "$platform" = linux ]; then | ||
| 93 | python3 scripts/render-installer.py \ | ||
| 94 | scripts/installers/linux.sh.in \ | ||
| 95 | "$DEST/gui/zagan-bet-gui-$VERSION-linux-$arch-install.sh" \ | ||
| 96 | "$VERSION" "$artifact" "$sha" "$URL_BASE/bin/gui/$artifact" | ||
| 97 | elif [ "$platform" = windows ]; then | ||
| 98 | python3 scripts/render-installer.py \ | ||
| 99 | scripts/installers/windows.ps1.in \ | ||
| 100 | "$DEST/gui/zagan-bet-gui-$VERSION-windows-$arch-install.ps1" \ | ||
| 101 | "$VERSION" "$artifact" "$sha" "$URL_BASE/bin/gui/$artifact" | ||
| 102 | fi | ||
| 103 | } | ||
| 104 | |||
| 105 | publish_gui x86_64-unknown-linux-gnu linux x86_64 | ||
| 106 | publish_gui x86_64-pc-windows-gnu windows x86_64 | ||
| 107 | |||
| 50 | publish x86_64-unknown-linux-gnu client linux x86_64 | 108 | publish x86_64-unknown-linux-gnu client linux x86_64 |
| 51 | publish i686-unknown-linux-gnu client linux i686 | 109 | publish i686-unknown-linux-gnu client linux i686 |
| 52 | publish x86_64-pc-windows-gnu client windows x86_64 | 110 | publish x86_64-pc-windows-gnu client windows x86_64 |
| 53 | publish x86_64-unknown-linux-gnu server linux x86_64 | 111 | publish x86_64-unknown-linux-gnu server linux x86_64 |
| 54 | publish x86_64-pc-windows-gnu server windows x86_64 | 112 | publish x86_64-pc-windows-gnu server windows x86_64 |
| 55 | 113 | ||
| 56 | echo | 114 | echo |
| 57 | echo "published $VERSION to $DEST" | 115 | echo "published $VERSION to $DEST" |
