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