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,24 +1,20 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
#
|
#
|
||||||
# Runs INSIDE the .build/prod container. Builds the Linux single-file binary and
|
# Runs INSIDE the .build/prod container. Clones, patches, builds the binary,
|
||||||
# drops it into .build/prod/out/ (mounted back to the host for the release step).
|
# smoke-tests it, and drops it in .build/prod/out/ for the release step.
|
||||||
#
|
#
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
cd /source
|
cd /source
|
||||||
|
|
||||||
# The repo is bind-mounted from the host (owned by a different uid), so git
|
# The repo is bind-mounted from the host (different uid), so mark it safe:
|
||||||
# refuses to operate on it until we mark it safe:
|
|
||||||
git config --global --add safe.directory '*'
|
git config --global --add safe.directory '*'
|
||||||
|
|
||||||
OUT_DIR="/source/.build/prod/out"
|
OUT_DIR="/source/.build/prod/out"
|
||||||
mkdir -p "$OUT_DIR"
|
mkdir -p "$OUT_DIR"
|
||||||
|
|
||||||
# Reuse the platform-agnostic build (apply patches → build UI → embed → bun compile):
|
bash scripts/build.sh
|
||||||
OUT_NAME=httptoolkit bash scripts/build.sh
|
|
||||||
|
|
||||||
# Smoke-test the Linux binary before we consider it releasable:
|
|
||||||
bash scripts/smoke.sh dist/httptoolkit
|
bash scripts/smoke.sh dist/httptoolkit
|
||||||
|
|
||||||
cp -v dist/httptoolkit "$OUT_DIR/httptoolkit-linux-x64"
|
cp -v dist/httptoolkit "$OUT_DIR/httptoolkit"
|
||||||
echo "==> Artifacts:"
|
echo "==> Artifacts:"
|
||||||
ls -lh "$OUT_DIR"
|
ls -lh "$OUT_DIR"
|
||||||
|
|||||||
@@ -14,17 +14,14 @@ jobs:
|
|||||||
runs-on: docker-compose
|
runs-on: docker-compose
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout (with submodules)
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
submodules: recursive
|
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Build Linux binary (docker)
|
- name: Build Linux binary (docker)
|
||||||
working-directory: .build/prod
|
working-directory: .build/prod
|
||||||
run: |
|
run: docker compose run --build --rm prod
|
||||||
docker compose build
|
|
||||||
docker compose run --rm prod
|
|
||||||
|
|
||||||
- name: Create Gitea release & upload assets
|
- name: Create Gitea release & upload assets
|
||||||
env:
|
env:
|
||||||
|
|||||||
+3
-4
@@ -2,10 +2,9 @@
|
|||||||
/dist/
|
/dist/
|
||||||
/out/
|
/out/
|
||||||
|
|
||||||
# Build artifacts staged inside the server submodule by scripts/build.sh
|
# Upstream sources are cloned fresh at build time, not tracked here
|
||||||
# (the submodule has its own .gitignore too; these are just in case)
|
/httptoolkit-ui/
|
||||||
/httptoolkit-server/ui.tar.gz
|
/httptoolkit-server/
|
||||||
/httptoolkit-server/ui/
|
|
||||||
|
|
||||||
# Local tooling / editor
|
# Local tooling / editor
|
||||||
/.claude/
|
/.claude/
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
[submodule "httptoolkit-ui"]
|
|
||||||
path = httptoolkit-ui
|
|
||||||
url = https://github.com/httptoolkit/httptoolkit-ui.git
|
|
||||||
[submodule "httptoolkit-server"]
|
|
||||||
path = httptoolkit-server
|
|
||||||
url = https://github.com/httptoolkit/httptoolkit-server.git
|
|
||||||
Submodule httptoolkit-server deleted from b9f2810c5a
Submodule httptoolkit-ui deleted from 237690ce48
@@ -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
|
#!/usr/bin/env bash
|
||||||
#
|
#
|
||||||
# Build the self-hosted single-file HTTP Toolkit binary.
|
# Clone upstream, patch, and build the single-file binary -> dist/httptoolkit
|
||||||
#
|
# Requires: node (>=22), npm, bun, tar, git.
|
||||||
# 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
|
set -euo pipefail
|
||||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||||
cd "$ROOT"
|
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_DOWNLOAD=true
|
||||||
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
|
export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
|
||||||
|
|
||||||
EXT=""
|
echo "==> Cloning upstream sources"
|
||||||
case "${BUN_TARGET}" in *windows*) EXT=".exe";; esac
|
rm -rf httptoolkit-ui httptoolkit-server
|
||||||
if [ -z "$BUN_TARGET" ] && [ "${OS:-}" = "Windows_NT" ]; then EXT=".exe"; fi
|
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"
|
echo "==> Applying patches + overlay"
|
||||||
bash scripts/apply.sh
|
bash scripts/patch.sh
|
||||||
|
|
||||||
echo "==> 2/5 Build UI -> httptoolkit-ui/dist"
|
echo "==> Building UI"
|
||||||
( cd httptoolkit-ui && npm ci && npm run build )
|
( 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 \
|
( cd httptoolkit-server \
|
||||||
&& npm ci \
|
&& npm ci \
|
||||||
&& npm install --no-save tar@^7 \
|
&& npm install --no-save tar@^7 \
|
||||||
&& tar -czf ui.tar.gz -C ../httptoolkit-ui/dist . \
|
&& tar -czf ui.tar.gz -C ../httptoolkit-ui/dist . \
|
||||||
&& rm -rf ui && cp -r ../httptoolkit-ui/dist ui )
|
&& 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
|
mkdir -p dist
|
||||||
COMPILE=(build ./htk-entry.ts --compile --outfile "$ROOT/dist/${OUT_NAME}${EXT}")
|
( cd httptoolkit-server && bun build ./htk-entry.ts --compile --outfile "$ROOT/dist/httptoolkit" )
|
||||||
if [ -n "$BUN_TARGET" ]; then COMPILE+=(--target "$BUN_TARGET"); fi
|
|
||||||
( cd httptoolkit-server && bun "${COMPILE[@]}" )
|
|
||||||
|
|
||||||
echo "==> 5/5 Done -> dist/${OUT_NAME}${EXT}"
|
echo "==> Done: dist/httptoolkit"
|
||||||
ls -lh "dist/${OUT_NAME}${EXT}"
|
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