Files
2026-06-25 15:28:46 +03:00

51 lines
1.5 KiB
Bash

#!/usr/bin/env bash
#
# make-package.sh - build an OTA update package for ButtonTask.
#
# Produces dist/buttontask-<version>.tar.gz containing:
# ButtonTask (the compiled binary)
# webconfig/ (the web configurator + scripts)
# manifest.json ({"version": ..., "created": ...})
# and prints the package's sha256 (paste it into the web UI for integrity).
#
# Usage:
# make-package.sh <version> [build-dir] [out-dir]
# Example:
# ./webconfig/scripts/make-package.sh 2.1 build dist
set -euo pipefail
VERSION="${1:?usage: make-package.sh <version> [build-dir] [out-dir]}"
BUILD_DIR="${2:-build}"
OUT_DIR="${3:-dist}"
# Resolve repo root (two levels up from this script).
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
BIN="$REPO_ROOT/$BUILD_DIR/ButtonTask"
[ -x "$BIN" ] || { echo "binary not found: $BIN (build first)"; exit 1; }
STAGE="$(mktemp -d)"
trap 'rm -rf "$STAGE"' EXIT
cp "$BIN" "$STAGE/ButtonTask"
cp -r "$REPO_ROOT/webconfig" "$STAGE/webconfig"
# Drop dev artefacts from the packaged webconfig.
rm -rf "$STAGE/webconfig/__pycache__" "$STAGE/webconfig/.webconfig.secret"
cat > "$STAGE/manifest.json" <<EOF
{
"version": "$VERSION",
"created": "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
}
EOF
mkdir -p "$REPO_ROOT/$OUT_DIR"
PKG="$REPO_ROOT/$OUT_DIR/buttontask-$VERSION.tar.gz"
tar -czf "$PKG" -C "$STAGE" .
echo "package: $PKG"
if command -v sha256sum >/dev/null 2>&1; then
echo "sha256: $(sha256sum "$PKG" | awk '{print $1}')"
fi