prepare for release!

This commit was merged in pull request #8.
This commit is contained in:
lda
2026-04-14 06:56:08 +07:00 Unverified
parent c28b62ef67
commit 37c0b67a96
14 changed files with 345 additions and 13 deletions
+19
View File
@@ -44,9 +44,28 @@ This folder has small helpers for build, CI, and router install. Keep it simple;
- `./scripts/dev_push.ps1 -Pass <password> [-HostName <ip>] [-RemotePath </root/.bin/wakey>] [-Restart] [-Quiet]`
- Uploads to `<RemotePath>.tmp` then atomically moves into place; `-Restart` restarts the service; `-Quiet` silences MOTD.
- `package_rootfs.ps1` — Produces `dist/wakey-rootfs-<version>-<target>.tgz` with `/root/.bin/wakey` and `/etc/init.d/*`.
- `update_wakey_cc.sh` — Linux VPS updater for control-plane bundles; extracts into the selected directory (default: current directory) and restarts `wakey-cc.service`.
- `package_wakey_cc_bundle.sh` — Produces `dist/wakey-cc-<version>-<target>.tgz` with `bin/wakey-control-plane`, `ui/dist/*`, updater script, and systemd template.
- `publish.ps1` — Optional version bump + build + tag (and `cargo publish` only if you pass `-Publish`).
- `test_remote.ps1` — Build ARM Linux test binaries locally, upload them to the router, and run them there.
## VPS updater (control-plane)
```sh
chmod +x ./scripts/update_wakey_cc.sh
cd /opt/wakey
WAKEY_CC_VERSION=v0.1.0 WAKEY_CC_TARGET=x86_64-unknown-linux-gnu \
sudo -E ./scripts/update_wakey_cc.sh
```
Expected tarball layout:
- `bin/wakey-control-plane`
- `ui/dist/index.html`
- `ui/dist/assets/*`
- `scripts/update_wakey_cc.sh`
- `deploy/systemd/wakey-cc.service`
## Remote test runner
`test_remote.ps1` is the main way to run Linux/router-specific tests that do not
+87
View File
@@ -0,0 +1,87 @@
#!/usr/bin/env sh
# Package wakey-control-plane bundle (binary + UI dist + updater + systemd template).
# Archive paths are relative so extraction can target any install directory.
#
# Usage:
# ./scripts/package_wakey_cc_bundle.sh --version v0.1.0 --target x86_64-unknown-linux-gnu
#
# Optional:
# --out-dir dist
# --binary target/<target>/release/wakey-control-plane
# --ui-dist ui/dist
set -eu
VERSION=""
TARGET=""
OUT_DIR="dist"
BINARY=""
UI_DIST="ui/dist"
while [ "$#" -gt 0 ]; do
case "$1" in
--version)
VERSION="$2"
shift 2
;;
--target)
TARGET="$2"
shift 2
;;
--out-dir)
OUT_DIR="$2"
shift 2
;;
--binary)
BINARY="$2"
shift 2
;;
--ui-dist)
UI_DIST="$2"
shift 2
;;
*)
echo "unknown arg: $1" >&2
exit 1
;;
esac
done
[ -n "$VERSION" ] || { echo "--version is required" >&2; exit 1; }
[ -n "$TARGET" ] || { echo "--target is required" >&2; exit 1; }
ROOT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
cd "$ROOT_DIR"
if [ -z "$BINARY" ]; then
BINARY="target/$TARGET/release/wakey-control-plane"
fi
[ -f "$BINARY" ] || { echo "missing binary: $BINARY" >&2; exit 1; }
[ -f "$UI_DIST/index.html" ] || { echo "missing UI dist index: $UI_DIST/index.html" >&2; exit 1; }
[ -f "scripts/update_wakey_cc.sh" ] || { echo "missing updater script" >&2; exit 1; }
[ -f "deploy/systemd/wakey-cc.service" ] || { echo "missing systemd template" >&2; exit 1; }
mkdir -p "$OUT_DIR"
STAGING="$OUT_DIR/wakey-cc-stage.$$"
PKG="wakey-cc-$VERSION-$TARGET.tgz"
rm -rf "$STAGING"
mkdir -p "$STAGING/bin" "$STAGING/ui" "$STAGING/scripts" "$STAGING/deploy/systemd"
cp "$BINARY" "$STAGING/bin/wakey-control-plane"
cp -a "$UI_DIST" "$STAGING/ui/dist"
cp "scripts/update_wakey_cc.sh" "$STAGING/scripts/update_wakey_cc.sh"
cp "deploy/systemd/wakey-cc.service" "$STAGING/deploy/systemd/wakey-cc.service"
chmod +x "$STAGING/bin/wakey-control-plane" "$STAGING/scripts/update_wakey_cc.sh"
(
cd "$STAGING"
tar -czf "$ROOT_DIR/$OUT_DIR/$PKG" .
)
rm -rf "$STAGING"
echo "Bundle package: $OUT_DIR/$PKG"
echo "Contains: bin/wakey-control-plane, ui/dist, scripts/update_wakey_cc.sh, deploy/systemd/wakey-cc.service"
+115
View File
@@ -0,0 +1,115 @@
#!/usr/bin/env sh
# Update/install wakey-control-plane bundle on Linux VPS and optionally restart systemd unit.
#
# Expected tarball layout:
# bin/wakey-control-plane
# ui/dist/index.html
# ui/dist/assets/*
#
# Env options:
# WAKEY_CC_TGZ_URL Direct URL to bundle tarball (preferred)
# WAKEY_HOST Release host (default: git.ldlda.com)
# WAKEY_OWNER Repo owner (default: lda)
# WAKEY_REPO Repo name (default: wakey)
# WAKEY_CC_VERSION Tag, e.g. v0.1.0 (required unless WAKEY_CC_TGZ_URL set)
# WAKEY_CC_TARGET Target triple (default from uname: x86_64-unknown-linux-gnu or aarch64-unknown-linux-gnu)
# WAKEY_CC_FILE Asset filename (default: wakey-cc-${WAKEY_CC_VERSION}-${WAKEY_CC_TARGET}.tgz)
# WAKEY_CC_ROOT Install root (default: current directory)
# WAKEY_CC_SERVICE systemd unit name (default: wakey-cc.service)
# WAKEY_CC_NO_RESTART If set, skip systemd restart
# WAKEY_INSECURE If set, disable TLS verification
#
# Requires: tar, systemctl, curl or wget
set -eu
log() { printf '[update_wakey_cc] %s\n' "$*"; }
fail() {
printf '[update_wakey_cc] ERROR: %s\n' "$*" >&2
exit 1
}
fetch() {
# fetch <url> <out>
if command -v curl >/dev/null 2>&1; then
if [ -n "${WAKEY_INSECURE:-}" ]; then
curl -fSL -k -o "$2" "$1"
else
curl -fSL -o "$2" "$1"
fi
return
fi
if command -v wget >/dev/null 2>&1; then
# shellcheck disable=SC2086
wget ${WAKEY_INSECURE:+--no-check-certificate} -O "$2" "$1"
return
fi
fail 'curl or wget is required'
}
default_target() {
arch=$(uname -m)
case "$arch" in
x86_64)
printf '%s' 'x86_64-unknown-linux-gnu'
;;
aarch64|arm64)
printf '%s' 'aarch64-unknown-linux-gnu'
;;
*)
printf '%s' "$arch"
;;
esac
}
main() {
ROOT="${WAKEY_CC_ROOT:-$PWD}"
SERVICE="${WAKEY_CC_SERVICE:-wakey-cc.service}"
TMPDIR="${TMPDIR:-/tmp}"
ARCHIVE="$TMPDIR/wakey-cc.$$.tgz"
STAGING="$TMPDIR/wakey-cc-stage.$$"
URL="${WAKEY_CC_TGZ_URL:-}"
if [ -z "$URL" ]; then
HOST="${WAKEY_HOST:-git.ldlda.com}"
OWNER="${WAKEY_OWNER:-lda}"
REPO="${WAKEY_REPO:-wakey}"
VERSION="${WAKEY_CC_VERSION:-}"
[ -n "$VERSION" ] || fail 'set WAKEY_CC_TGZ_URL or WAKEY_CC_VERSION'
TARGET="${WAKEY_CC_TARGET:-$(default_target)}"
FILE="${WAKEY_CC_FILE:-wakey-cc-${VERSION}-${TARGET}.tgz}"
URL="https://$HOST/$OWNER/$REPO/releases/download/$VERSION/$FILE"
fi
trap 'rm -f "$ARCHIVE"; rm -rf "$STAGING"' EXIT INT TERM
log "fetching $URL"
fetch "$URL" "$ARCHIVE" || fail 'download failed'
rm -rf "$STAGING"
mkdir -p "$STAGING"
tar -xzf "$ARCHIVE" -C "$STAGING" || fail 'extract failed'
[ -f "$STAGING/bin/wakey-control-plane" ] || fail 'bundle missing bin/wakey-control-plane'
[ -f "$STAGING/ui/dist/index.html" ] || fail 'bundle missing ui/dist/index.html'
mkdir -p "$ROOT"
cp -a "$STAGING/." "$ROOT/"
if [ -z "${WAKEY_CC_NO_RESTART:-}" ] && command -v systemctl >/dev/null 2>&1; then
if systemctl list-unit-files "$SERVICE" >/dev/null 2>&1; then
log "restarting $SERVICE"
systemctl daemon-reload
systemctl restart "$SERVICE"
systemctl --no-pager --full status "$SERVICE" | sed -n '1,16p'
else
log "service $SERVICE not installed; skipped restart"
fi
fi
log "done: installed into $ROOT"
}
main "$@"