Skip to content

Commit c137b8b

Browse files
committed
Cache binary with specific name.
1 parent 66c21d4 commit c137b8b

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

update.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,23 @@ ok "Repository updated"
3939
log "Building application"
4040
swift build -c release -v 2>&1 | grep -E "Compiling|Linking|Build complete|error:" || true
4141
BIN_PATH=$(swift build -c release --show-bin-path)
42+
43+
# Determine cached binary name (matches install-swift-app naming)
44+
PLATFORM=$(dpkg --print-architecture)
45+
OS_ID=$(. /etc/os-release && echo "${ID}${VERSION_ID}" | tr -d '.')
46+
SWIFT_VERSION=$(swift --version 2>&1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)
47+
APP_VERSION=$(grep -oE 'version = "[0-9]+\.[0-9]+\.[0-9]+"' "$INSTALL_DIR/Sources/App/info.swift" 2>/dev/null | grep -oE '"[^"]*"' | tr -d '"')
48+
APP_VERSION="${APP_VERSION:-unknown}"
49+
BIN_NAME="App-${OS_ID}-${PLATFORM}-swift-${SWIFT_VERSION}-${APP_VERSION}"
50+
4251
log "Stopping service"
4352
# Delay so client could read the "Stopping service" message before the service is stopped and the connection is lost
4453
sleep 2
4554
systemctl stop "$APP_NAME"
46-
cp "$BIN_PATH/App" "$INSTALL_DIR/App"
47-
chown $APP_USER:$APP_USER "$INSTALL_DIR/App"
55+
cp "$BIN_PATH/App" "$INSTALL_DIR/$BIN_NAME"
56+
cp "$INSTALL_DIR/$BIN_NAME" "$INSTALL_DIR/App"
57+
chown $APP_USER:$APP_USER "$INSTALL_DIR/$BIN_NAME" "$INSTALL_DIR/App"
58+
ok "Binary cached as $BIN_NAME"
4859
setcap 'cap_net_bind_service=+ep' "$INSTALL_DIR/App" # Allow binding to port 443 without root
4960
ok "Binary updated"
5061

0 commit comments

Comments
 (0)