refactor: unify build/release workflows into a single parameterized workflow

Replace 4 separate workflows (docker-build-self, docker-build-origin,
release-self-binaries, release-origin-binaries) with one build-and-release.yml
that accepts repository, ref, docker_tag, and release_tag as inputs.

- origin/Dockerfile: now copies pre-built binary like self/Dockerfile
- origin/build.sh: clones tiann/hapi@main and builds before docker build

via HAPI

Co-Authored-By: HAPI <[email protected]>
This commit is contained in:
i
2026-05-22 17:52:44 +08:00
co-authored by HAPI
parent f23b40f554
commit acd51fae08
7 changed files with 158 additions and 308 deletions
+2 -29
View File
@@ -1,38 +1,11 @@
FROM oven/bun:1.3.14-slim AS builder
RUN apt-get update && apt-get install -y --no-install-recommends git ca-certificates unzip \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /build
RUN git clone --depth 1 --branch main https://github.com/tiann/hapi.git .
RUN bun install
RUN bun run download:tunwg
RUN bun run build:web
RUN cd hub && bun run generate:embedded-web-assets
ARG TARGETARCH
RUN case "$TARGETARCH" in \
amd64) \
cd /build/cli && bun run build:exe:allinone --target bun-linux-x64-baseline && \
cp dist-exe/bun-linux-x64-baseline/hapi /tmp/hapi \
;; \
arm64) \
cd /build/cli && bun run build:exe:allinone --target bun-linux-arm64 && \
cp dist-exe/bun-linux-arm64/hapi /tmp/hapi \
;; \
*) \
echo "Unsupported architecture: $TARGETARCH" && exit 1 \
;; \
esac
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /tmp/hapi /usr/local/bin/hapi
ARG TARGETARCH
COPY hapi-${TARGETARCH} /usr/local/bin/hapi
RUN chmod +x /usr/local/bin/hapi
RUN mkdir -p /root/.hapi
+22
View File
@@ -7,9 +7,11 @@ ARCH=$(uname -m)
case "$ARCH" in
x86_64)
HAPI_ARCH="amd64"
BINARY_DIR="bun-linux-x64-baseline"
;;
aarch64|arm64)
HAPI_ARCH="arm64"
BINARY_DIR="bun-linux-arm64"
;;
*)
echo "Unsupported architecture: $ARCH"
@@ -17,10 +19,30 @@ case "$ARCH" in
;;
esac
BUILD_DIR=$(mktemp -d)
trap 'rm -rf "$BUILD_DIR"' EXIT
echo "Cloning tiann/hapi@main into $BUILD_DIR ..."
git clone --depth 1 --branch main https://github.com/tiann/hapi.git "$BUILD_DIR"
cd "$BUILD_DIR"
bun install
bun run build:single-exe
BINARY_PATH="$BUILD_DIR/cli/dist-exe/$BINARY_DIR/hapi"
if [ ! -f "$BINARY_PATH" ]; then
echo "Binary not found: $BINARY_PATH"
exit 1
fi
cp "$BINARY_PATH" "$SCRIPT_DIR/hapi-${HAPI_ARCH}"
docker build \
--build-arg "TARGETARCH=${HAPI_ARCH}" \
-t "hapi:origin" \
-f "$SCRIPT_DIR/Dockerfile" \
"$SCRIPT_DIR/"
rm -f "$SCRIPT_DIR/hapi-${HAPI_ARCH}"
echo "Built hapi:origin for ${HAPI_ARCH}"