feat: add origin Docker image and release workflow from official hapi repo

Build from tiann/hapi main branch, tag as origin.

via HAPI

Co-Authored-By: HAPI <[email protected]>
This commit is contained in:
i
2026-05-22 14:45:48 +08:00
co-authored by HAPI
parent 2a44d333f2
commit f23b40f554
4 changed files with 196 additions and 0 deletions
+48
View File
@@ -0,0 +1,48 @@
name: Build and Push Origin Docker Image to GHCR
on:
push:
branches: [main]
tags: ["v*"]
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=origin
- uses: docker/build-push-action@v6
with:
context: ./origin
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
@@ -0,0 +1,76 @@
name: Release Origin Binaries
on:
workflow_dispatch:
inputs:
commit:
description: 'Commit SHA to build (leave empty for latest main branch)'
required: false
tag:
description: 'Release tag (leave empty for auto-generated)'
required: false
permissions:
contents: write
jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout hapi main branch
uses: actions/checkout@v4
with:
repository: tiann/hapi
ref: ${{ github.event.inputs.commit || 'main' }}
path: hapi-src
- name: Get version info
id: info
working-directory: hapi-src
run: |
SHORT_SHA=$(git rev-parse --short HEAD)
VERSION=$(jq -r '.version' cli/package.json)
INPUT_TAG="${{ github.event.inputs.tag }}"
if [ -n "$INPUT_TAG" ]; then
TAG="$INPUT_TAG"
else
TAG="origin-${SHORT_SHA}"
fi
echo "short_sha=$SHORT_SHA" >> "$GITHUB_OUTPUT"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
echo "Building version $VERSION @ $SHORT_SHA, release tag=$TAG"
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: 1.3.14
- name: Build all platform binaries
working-directory: hapi-src
run: |
bun install
bun run build:single-exe:all
- name: Prepare release artifacts
run: |
mkdir -p release
cp hapi-src/cli/dist-exe/bun-linux-x64-baseline/hapi release/hapi-linux-x64
cp hapi-src/cli/dist-exe/bun-linux-arm64/hapi release/hapi-linux-arm64
cp hapi-src/cli/dist-exe/bun-darwin-x64/hapi release/hapi-darwin-x64
cp hapi-src/cli/dist-exe/bun-darwin-arm64/hapi release/hapi-darwin-arm64
cp hapi-src/cli/dist-exe/bun-windows-x64/hapi.exe release/hapi-windows-x64.exe
ls -la release/
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.event.inputs.tag || format('origin-{0}', steps.info.outputs.short_sha) }}
name: Origin Build ${{ steps.info.outputs.version }} (${{ steps.info.outputs.short_sha }})
body: |
Origin-built hapi binaries from [tiann/hapi](https://github.com/tiann/hapi) `main` branch.
- Version: ${{ steps.info.outputs.version }}
- Commit: `${{ steps.info.outputs.short_sha }}`
files: release/*
fail_on_unmatched_files: true
+46
View File
@@ -0,0 +1,46 @@
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
RUN chmod +x /usr/local/bin/hapi
RUN mkdir -p /root/.hapi
EXPOSE 3006
ENV HAPI_LISTEN_HOST=0.0.0.0
ENV HAPI_LISTEN_PORT=3006
ENTRYPOINT ["hapi"]
CMD ["hub"]
+26
View File
@@ -0,0 +1,26 @@
#!/bin/bash
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ARCH=$(uname -m)
case "$ARCH" in
x86_64)
HAPI_ARCH="amd64"
;;
aarch64|arm64)
HAPI_ARCH="arm64"
;;
*)
echo "Unsupported architecture: $ARCH"
exit 1
;;
esac
docker build \
--build-arg "TARGETARCH=${HAPI_ARCH}" \
-t "hapi:origin" \
-f "$SCRIPT_DIR/Dockerfile" \
"$SCRIPT_DIR/"
echo "Built hapi:origin for ${HAPI_ARCH}"