-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·66 lines (56 loc) · 2.87 KB
/
Copy pathdeploy.sh
File metadata and controls
executable file
·66 lines (56 loc) · 2.87 KB
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
#!/usr/bin/env bash
#
# Build all Slidr artifacts, package the interactive Windows installer (NSIS),
# publish them to the nginx web root, and write an authoritative build-info.json
# the landing page reads for its "Last build" stamp.
#
# Usage: ./deploy.sh [--skip-windows]
#
set -euo pipefail
cd "$(dirname "$0")"
WEBROOT="/var/www/slidr"
WIN_TARGET="x86_64-pc-windows-gnu"
VERSION="$(grep -m1 '^version' Cargo.toml | sed -E 's/.*"([^"]+)".*/\1/')"
SKIP_WINDOWS=0
[[ "${1:-}" == "--skip-windows" ]] && SKIP_WINDOWS=1
# Make cargo available in non-interactive shells.
[[ -f "$HOME/.cargo/env" ]] && source "$HOME/.cargo/env"
log() { printf '\033[1;35m▶ %s\033[0m\n' "$*"; }
BUILD_TIME_UTC="$(date -u +'%Y-%m-%d %H:%M UTC')"
BUILD_EPOCH="$(date -u +%s)"
# ── Build ────────────────────────────────────────────────────────────────
log "Building Linux release"
cargo build --release
if [[ "$SKIP_WINDOWS" -eq 0 ]]; then
log "Cross-compiling Windows release ($WIN_TARGET)"
cargo build --release --target "$WIN_TARGET"
log "Packaging interactive installer (NSIS)"
cp "target/$WIN_TARGET/release/slidr.exe" installer/slidr.exe
cp assets/logo.ico installer/logo.ico
( cd installer && makensis -DVERSION="$VERSION" slidr.nsi >/dev/null )
fi
# ── Publish ──────────────────────────────────────────────────────────────
log "Publishing to $WEBROOT"
mkdir -p "$WEBROOT"
install -m644 target/release/slidr "$WEBROOT/Slidr-linux-x86_64"
if [[ "$SKIP_WINDOWS" -eq 0 ]]; then
install -m644 installer/Slidr-windows-setup.exe "$WEBROOT/Slidr-windows-setup.exe"
install -m644 "target/$WIN_TARGET/release/slidr.exe" "$WEBROOT/Slidr-windows-portable.exe"
fi
# ── Build-info ───────────────────────────────────────────────────────────
size_of() { [[ -f "$1" ]] && stat -c%s "$1" || echo 0; }
cat > "$WEBROOT/build-info.json" <<EOF
{
"build_time": "$BUILD_TIME_UTC",
"build_epoch": $BUILD_EPOCH,
"version": "$VERSION",
"artifacts": {
"installer": { "name": "Slidr-windows-setup.exe", "bytes": $(size_of "$WEBROOT/Slidr-windows-setup.exe") },
"portable": { "name": "Slidr-windows-portable.exe", "bytes": $(size_of "$WEBROOT/Slidr-windows-portable.exe") },
"linux": { "name": "Slidr-linux-x86_64", "bytes": $(size_of "$WEBROOT/Slidr-linux-x86_64") }
}
}
EOF
log "Done — build $BUILD_TIME_UTC (v$VERSION)"
ls -lh "$WEBROOT"/{Slidr-windows-setup.exe,Slidr-windows-portable.exe,Slidr-linux-x86_64} 2>/dev/null || true
echo "Reload nginx not required (static files). Page: http://100.118.79.15/"