feat: ESLint, shell completions, Docker, nfpm packaging, CI/CD
- ESLint with typescript-eslint + prettier (eslint.config.js)
- Shell completions for bash and fish (scripts/generate-completions.ts)
- Multi-stage Dockerfile for bastion (fedora:43 + dnsmasq + node)
- nfpm.yaml for RPM/DEB packaging with bun-compiled binary
- Build scripts: build-rpm.sh, build-bastion.sh, publish-rpm/deb.sh
- Gitea Actions CI/CD: lint, typecheck, test, build, publish
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-17 21:51:01 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
|
|
|
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
|
|
|
|
|
cd "$PROJECT_ROOT"
|
|
|
|
|
|
|
|
|
|
# Load .env if present
|
|
|
|
|
if [ -f .env ]; then
|
|
|
|
|
set -a; source .env; set +a
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Ensure tools are on PATH
|
|
|
|
|
export PATH="$HOME/.npm-global/bin:$HOME/.bun/bin:$HOME/.local/bin:$PATH"
|
|
|
|
|
|
2026-03-17 22:02:52 +00:00
|
|
|
# ── Argument parsing ───────────────────────────────────────────────
|
|
|
|
|
BUILD_ALL=false
|
|
|
|
|
TARGET_ARCH=""
|
|
|
|
|
SKIP_TESTS=false
|
|
|
|
|
|
|
|
|
|
usage() {
|
|
|
|
|
cat <<EOF
|
|
|
|
|
Usage: $(basename "$0") [OPTIONS]
|
|
|
|
|
|
|
|
|
|
Build lab binary and produce RPM/DEB packages.
|
|
|
|
|
|
|
|
|
|
Options:
|
|
|
|
|
--arch ARCH Target architecture: x86_64 or arm64 (default: host arch)
|
|
|
|
|
--all Build for both x86_64 and arm64
|
|
|
|
|
--skip-tests Skip unit tests (useful in CI where tests ran separately)
|
|
|
|
|
-h, --help Show this help message
|
|
|
|
|
EOF
|
|
|
|
|
exit 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
|
|
|
case "$1" in
|
|
|
|
|
--arch)
|
|
|
|
|
TARGET_ARCH="$2"
|
|
|
|
|
shift 2
|
|
|
|
|
;;
|
|
|
|
|
--all)
|
|
|
|
|
BUILD_ALL=true
|
|
|
|
|
shift
|
|
|
|
|
;;
|
|
|
|
|
--skip-tests)
|
|
|
|
|
SKIP_TESTS=true
|
|
|
|
|
shift
|
|
|
|
|
;;
|
|
|
|
|
-h|--help)
|
|
|
|
|
usage
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
echo "Unknown option: $1"
|
|
|
|
|
usage
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
# ── Resolve host architecture ─────────────────────────────────────
|
|
|
|
|
detect_host_arch() {
|
|
|
|
|
local machine
|
|
|
|
|
machine="$(uname -m)"
|
|
|
|
|
case "$machine" in
|
|
|
|
|
x86_64) echo "x86_64" ;;
|
|
|
|
|
aarch64) echo "arm64" ;;
|
|
|
|
|
arm64) echo "arm64" ;;
|
|
|
|
|
*) echo "$machine" ;;
|
|
|
|
|
esac
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# ── Architecture mapping helpers ──────────────────────────────────
|
|
|
|
|
# Maps our canonical arch names to the values each tool expects.
|
|
|
|
|
bun_target_for() {
|
|
|
|
|
case "$1" in
|
|
|
|
|
x86_64) echo "bun-linux-x64" ;;
|
|
|
|
|
arm64) echo "bun-linux-arm64" ;;
|
|
|
|
|
esac
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nfpm_arch_for() {
|
|
|
|
|
case "$1" in
|
|
|
|
|
x86_64) echo "amd64" ;;
|
|
|
|
|
arm64) echo "arm64" ;;
|
|
|
|
|
esac
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rpm_arch_for() {
|
|
|
|
|
case "$1" in
|
|
|
|
|
x86_64) echo "x86_64" ;;
|
|
|
|
|
arm64) echo "aarch64" ;;
|
|
|
|
|
esac
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
deb_arch_for() {
|
|
|
|
|
case "$1" in
|
|
|
|
|
x86_64) echo "amd64" ;;
|
|
|
|
|
arm64) echo "arm64" ;;
|
|
|
|
|
esac
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# ── Build one architecture ────────────────────────────────────────
|
|
|
|
|
build_arch() {
|
|
|
|
|
local arch="$1"
|
|
|
|
|
local bun_target nfpm_arch binary_name
|
|
|
|
|
|
|
|
|
|
bun_target="$(bun_target_for "$arch")"
|
|
|
|
|
nfpm_arch="$(nfpm_arch_for "$arch")"
|
|
|
|
|
binary_name="dist/lab-${arch}"
|
|
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
|
echo "==> Bundling standalone binary for ${arch}..."
|
|
|
|
|
bun build src/cli/src/index.ts --compile --target="${bun_target}" --outfile "${binary_name}"
|
|
|
|
|
|
|
|
|
|
echo "==> Packaging RPM (${arch})..."
|
|
|
|
|
# Create a temporary nfpm config with the correct arch and binary path
|
|
|
|
|
local tmpconfig
|
|
|
|
|
tmpconfig="$(mktemp /tmp/nfpm-XXXXXX.yaml)"
|
|
|
|
|
sed -e "s|^arch:.*|arch: ${nfpm_arch}|" \
|
|
|
|
|
-e "s|src: ./dist/lab$|src: ./${binary_name}|" \
|
|
|
|
|
nfpm.yaml > "$tmpconfig"
|
|
|
|
|
|
|
|
|
|
nfpm pkg --config "$tmpconfig" --packager rpm --target dist/
|
|
|
|
|
rm -f "$tmpconfig"
|
|
|
|
|
|
|
|
|
|
local rpm_arch
|
|
|
|
|
rpm_arch="$(rpm_arch_for "$arch")"
|
|
|
|
|
RPM_FILE=$(ls dist/lab-*.${rpm_arch}.rpm 2>/dev/null | head -1)
|
|
|
|
|
echo "==> Built: $RPM_FILE"
|
|
|
|
|
echo " Size: $(du -h "$RPM_FILE" | cut -f1)"
|
|
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
|
echo "==> Packaging DEB (${arch})..."
|
|
|
|
|
local deb_arch
|
|
|
|
|
deb_arch="$(deb_arch_for "$arch")"
|
|
|
|
|
|
|
|
|
|
tmpconfig="$(mktemp /tmp/nfpm-XXXXXX.yaml)"
|
|
|
|
|
sed -e "s|^arch:.*|arch: ${nfpm_arch}|" \
|
|
|
|
|
-e "s|src: ./dist/lab$|src: ./${binary_name}|" \
|
|
|
|
|
nfpm.yaml > "$tmpconfig"
|
|
|
|
|
|
|
|
|
|
nfpm pkg --config "$tmpconfig" --packager deb --target dist/
|
|
|
|
|
rm -f "$tmpconfig"
|
|
|
|
|
|
|
|
|
|
DEB_FILE=$(ls dist/lab_*_${deb_arch}.deb 2>/dev/null | head -1)
|
|
|
|
|
echo "==> Built: $DEB_FILE"
|
|
|
|
|
echo " Size: $(du -h "$DEB_FILE" | cut -f1)"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# ── Main ──────────────────────────────────────────────────────────
|
|
|
|
|
|
|
|
|
|
if [ "$SKIP_TESTS" = false ]; then
|
|
|
|
|
echo "==> Running unit tests..."
|
|
|
|
|
pnpm test:run
|
|
|
|
|
echo ""
|
|
|
|
|
fi
|
feat: ESLint, shell completions, Docker, nfpm packaging, CI/CD
- ESLint with typescript-eslint + prettier (eslint.config.js)
- Shell completions for bash and fish (scripts/generate-completions.ts)
- Multi-stage Dockerfile for bastion (fedora:43 + dnsmasq + node)
- nfpm.yaml for RPM/DEB packaging with bun-compiled binary
- Build scripts: build-rpm.sh, build-bastion.sh, publish-rpm/deb.sh
- Gitea Actions CI/CD: lint, typecheck, test, build, publish
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-17 21:51:01 +00:00
|
|
|
|
|
|
|
|
echo "==> Building TypeScript..."
|
|
|
|
|
pnpm build
|
|
|
|
|
|
|
|
|
|
echo "==> Generating shell completions..."
|
|
|
|
|
pnpm completions:generate
|
|
|
|
|
|
|
|
|
|
mkdir -p dist
|
2026-03-17 22:02:52 +00:00
|
|
|
rm -f dist/lab dist/lab-x86_64 dist/lab-arm64 dist/lab-*.rpm dist/lab*.deb
|
feat: ESLint, shell completions, Docker, nfpm packaging, CI/CD
- ESLint with typescript-eslint + prettier (eslint.config.js)
- Shell completions for bash and fish (scripts/generate-completions.ts)
- Multi-stage Dockerfile for bastion (fedora:43 + dnsmasq + node)
- nfpm.yaml for RPM/DEB packaging with bun-compiled binary
- Build scripts: build-rpm.sh, build-bastion.sh, publish-rpm/deb.sh
- Gitea Actions CI/CD: lint, typecheck, test, build, publish
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-17 21:51:01 +00:00
|
|
|
|
2026-03-17 22:02:52 +00:00
|
|
|
if [ "$BUILD_ALL" = true ]; then
|
|
|
|
|
build_arch "x86_64"
|
|
|
|
|
build_arch "arm64"
|
|
|
|
|
elif [ -n "$TARGET_ARCH" ]; then
|
|
|
|
|
build_arch "$TARGET_ARCH"
|
|
|
|
|
else
|
|
|
|
|
# Default to host architecture
|
|
|
|
|
HOST_ARCH="$(detect_host_arch)"
|
|
|
|
|
build_arch "$HOST_ARCH"
|
|
|
|
|
fi
|
feat: ESLint, shell completions, Docker, nfpm packaging, CI/CD
- ESLint with typescript-eslint + prettier (eslint.config.js)
- Shell completions for bash and fish (scripts/generate-completions.ts)
- Multi-stage Dockerfile for bastion (fedora:43 + dnsmasq + node)
- nfpm.yaml for RPM/DEB packaging with bun-compiled binary
- Build scripts: build-rpm.sh, build-bastion.sh, publish-rpm/deb.sh
- Gitea Actions CI/CD: lint, typecheck, test, build, publish
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-17 21:51:01 +00:00
|
|
|
|
|
|
|
|
echo ""
|
2026-03-17 22:02:52 +00:00
|
|
|
echo "==> Build complete. Artifacts in dist/:"
|
|
|
|
|
ls -lh dist/lab* 2>/dev/null || echo " (none)"
|