Clone upstream at build time; drop submodules; single httptoolkit binary
Build & Release binary / build (push) Failing after 17m21s
Build & Release binary / build (push) Failing after 17m21s
This commit is contained in:
@@ -1,44 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Apply our patches + overlay onto the pristine upstream submodules.
|
||||
#
|
||||
# Fails loudly if a patch no longer applies (i.e. upstream moved after a
|
||||
# submodule bump), so you know exactly which patch to refresh. Idempotent:
|
||||
# it resets each submodule's tracked files to the pinned commit first.
|
||||
#
|
||||
set -euo pipefail
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
cd "$ROOT"
|
||||
|
||||
echo "==> Ensuring submodules are initialised & at pinned commits"
|
||||
git submodule update --init --recursive
|
||||
|
||||
apply_patches() {
|
||||
local name="$1" dir="$2"
|
||||
if [ ! -d "patches/$name" ]; then return; fi
|
||||
|
||||
echo "==> [$name] resetting to pinned commit"
|
||||
git -C "$dir" checkout -- . 2>/dev/null || true
|
||||
git -C "$dir" clean -fd -e node_modules 2>/dev/null || true
|
||||
|
||||
echo "==> [$name] applying patches"
|
||||
local applied=0
|
||||
for patch in patches/"$name"/*.patch; do
|
||||
[ -e "$patch" ] || continue
|
||||
echo " - $(basename "$patch")"
|
||||
# --3way lets git fall back to a merge if context shifted slightly.
|
||||
git -C "$dir" apply --3way "$ROOT/$patch"
|
||||
applied=$((applied + 1))
|
||||
done
|
||||
echo "==> [$name] $applied patch(es) applied"
|
||||
}
|
||||
|
||||
apply_patches ui httptoolkit-ui
|
||||
apply_patches server httptoolkit-server
|
||||
|
||||
echo "==> Copying overlay files into httptoolkit-server"
|
||||
cp -v overlay/server/htk-entry.ts httptoolkit-server/htk-entry.ts
|
||||
cp -v overlay/server/src/htk-app.ts httptoolkit-server/src/htk-app.ts
|
||||
cp -v overlay/server/src/commands/app.ts httptoolkit-server/src/commands/app.ts
|
||||
|
||||
echo "==> apply.sh complete."
|
||||
+14
-26
@@ -1,48 +1,36 @@
|
||||
#!/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
|
||||
# Clone upstream, patch, and build the single-file binary -> dist/httptoolkit
|
||||
# Requires: node (>=22), npm, bun, tar, git.
|
||||
#
|
||||
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 "==> Cloning upstream sources"
|
||||
rm -rf httptoolkit-ui httptoolkit-server
|
||||
git clone --depth 1 https://github.com/httptoolkit/httptoolkit-ui.git
|
||||
git clone --depth 1 https://github.com/httptoolkit/httptoolkit-server.git
|
||||
|
||||
echo "==> 1/5 Apply patches + overlay"
|
||||
bash scripts/apply.sh
|
||||
echo "==> Applying patches + overlay"
|
||||
bash scripts/patch.sh
|
||||
|
||||
echo "==> 2/5 Build UI -> httptoolkit-ui/dist"
|
||||
echo "==> Building UI"
|
||||
( cd httptoolkit-ui && npm ci && npm run build )
|
||||
|
||||
echo "==> 3/5 Install server deps (+ tar for the entry) & embed the UI"
|
||||
echo "==> Preparing server + embedding 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"
|
||||
echo "==> Compiling single-file binary -> dist/httptoolkit"
|
||||
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[@]}" )
|
||||
( cd httptoolkit-server && bun build ./htk-entry.ts --compile --outfile "$ROOT/dist/httptoolkit" )
|
||||
|
||||
echo "==> 5/5 Done -> dist/${OUT_NAME}${EXT}"
|
||||
ls -lh "dist/${OUT_NAME}${EXT}"
|
||||
echo "==> Done: dist/httptoolkit"
|
||||
ls -lh dist/httptoolkit
|
||||
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Apply our patches + overlay onto the cloned upstream repos.
|
||||
# Fails loudly if a patch no longer applies (upstream moved).
|
||||
#
|
||||
set -euo pipefail
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
cd "$ROOT"
|
||||
|
||||
apply_patches() {
|
||||
local name="$1" dir="$2"
|
||||
[ -d "patches/$name" ] || return 0
|
||||
echo "==> [$name] applying patches"
|
||||
for patch in patches/"$name"/*.patch; do
|
||||
[ -e "$patch" ] || continue
|
||||
echo " - $(basename "$patch")"
|
||||
git -C "$dir" apply --3way "$ROOT/$patch"
|
||||
done
|
||||
}
|
||||
|
||||
apply_patches ui httptoolkit-ui
|
||||
apply_patches server httptoolkit-server
|
||||
|
||||
echo "==> Copying overlay into httptoolkit-server"
|
||||
cp -v overlay/server/htk-entry.ts httptoolkit-server/htk-entry.ts
|
||||
cp -v overlay/server/src/htk-app.ts httptoolkit-server/src/htk-app.ts
|
||||
cp -v overlay/server/src/commands/app.ts httptoolkit-server/src/commands/app.ts
|
||||
|
||||
echo "==> patch.sh complete."
|
||||
Reference in New Issue
Block a user