Build self-hosted HTTP Toolkit / build (linux-x64, ubuntu-latest, true) (push) Canceled after 0s
Build self-hosted HTTP Toolkit / build (macos-arm64, macos-latest, true) (push) Canceled after 0s
Build self-hosted HTTP Toolkit / build (windows-x64, windows-latest, false) (push) Canceled after 0s
Build self-hosted HTTP Toolkit / release (push) Canceled after 0s
49 lines
1.6 KiB
Bash
Executable File
49 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# Build the self-hosted single-file HTTP Toolkit binary.
|
|
#
|
|
# Requires: node (>=22), npm, bun, tar. Runs per-OS in CI (native modules can't
|
|
# be cross-compiled), so this builds for the *host* platform.
|
|
#
|
|
# Env:
|
|
# OUT_NAME output binary basename (default: httptoolkit)
|
|
# BUN_TARGET optional bun --target (default: host); e.g. bun-linux-x64
|
|
#
|
|
set -euo pipefail
|
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
cd "$ROOT"
|
|
|
|
OUT_NAME="${OUT_NAME:-httptoolkit}"
|
|
BUN_TARGET="${BUN_TARGET:-}"
|
|
|
|
# The UI's postinstall pulls Puppeteer's Chromium (only needed for its own
|
|
# integration tests) - skip it, it's large and irrelevant to the build.
|
|
export PUPPETEER_SKIP_DOWNLOAD=true
|
|
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
|
|
|
|
EXT=""
|
|
case "${BUN_TARGET}" in *windows*) EXT=".exe";; esac
|
|
if [ -z "$BUN_TARGET" ] && [ "${OS:-}" = "Windows_NT" ]; then EXT=".exe"; fi
|
|
|
|
echo "==> 1/5 Apply patches + overlay"
|
|
bash scripts/apply.sh
|
|
|
|
echo "==> 2/5 Build UI -> httptoolkit-ui/dist"
|
|
( cd httptoolkit-ui && npm ci && npm run build )
|
|
|
|
echo "==> 3/5 Install server deps (+ tar for the entry) & embed the UI"
|
|
( cd httptoolkit-server \
|
|
&& npm ci \
|
|
&& npm install --no-save tar@^7 \
|
|
&& tar -czf ui.tar.gz -C ../httptoolkit-ui/dist . \
|
|
&& rm -rf ui && cp -r ../httptoolkit-ui/dist ui )
|
|
|
|
echo "==> 4/5 Compile single-file binary with Bun"
|
|
mkdir -p dist
|
|
COMPILE=(build ./htk-entry.ts --compile --outfile "$ROOT/dist/${OUT_NAME}${EXT}")
|
|
if [ -n "$BUN_TARGET" ]; then COMPILE+=(--target "$BUN_TARGET"); fi
|
|
( cd httptoolkit-server && bun "${COMPILE[@]}" )
|
|
|
|
echo "==> 5/5 Done -> dist/${OUT_NAME}${EXT}"
|
|
ls -lh "dist/${OUT_NAME}${EXT}"
|