mirror of
https://github.com/yibaiba/hideck.git
synced 2026-12-05 16:02:17 +00:00
Assemble source-integrated VoHive
This commit is contained in:
commit
de689a554d
984 files changed
+255607
No files matched your search
@@ -0,0 +1,181 @@
|
||||
name: Build Release Binaries
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: 'Version string used when manually triggered'
|
||||
required: false
|
||||
default: 'dev'
|
||||
enable_upx:
|
||||
description: 'Enable UPX compression (true/false)'
|
||||
required: false
|
||||
default: 'false'
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
concurrency:
|
||||
group: binary-release-${{ github.ref }}
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
frontend:
|
||||
name: Build frontend assets
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
cache-dependency-path: web/package-lock.json
|
||||
|
||||
- name: Build frontend assets
|
||||
shell: bash
|
||||
run: |
|
||||
npm ci --prefix web
|
||||
npm run build --prefix web
|
||||
|
||||
- name: Upload frontend dist
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: web-dist
|
||||
path: web/dist
|
||||
if-no-files-found: error
|
||||
retention-days: 1
|
||||
|
||||
build:
|
||||
name: Build ${{ matrix.artifact_arch }}
|
||||
runs-on: ubuntu-latest
|
||||
needs: frontend
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- goarch: amd64
|
||||
goarm: ''
|
||||
artifact_arch: amd64
|
||||
- goarch: arm64
|
||||
goarm: ''
|
||||
artifact_arch: arm64
|
||||
- goarch: arm
|
||||
goarm: '7'
|
||||
artifact_arch: armv7
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: go.mod
|
||||
cache: true
|
||||
|
||||
- name: Prepare build vars
|
||||
id: vars
|
||||
shell: bash
|
||||
run: |
|
||||
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
|
||||
VERSION="${GITHUB_REF_NAME}"
|
||||
else
|
||||
VERSION="${{ github.event.inputs.version || 'dev' }}"
|
||||
fi
|
||||
BUILDTIME="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
|
||||
ENABLE_UPX_RAW="${{ github.event.inputs.enable_upx || 'false' }}"
|
||||
case "${ENABLE_UPX_RAW}" in
|
||||
true|1|yes|on) ENABLE_UPX=1 ;;
|
||||
*) ENABLE_UPX=0 ;;
|
||||
esac
|
||||
echo "version=${VERSION}" >> "${GITHUB_OUTPUT}"
|
||||
echo "buildtime=${BUILDTIME}" >> "${GITHUB_OUTPUT}"
|
||||
echo "enable_upx=${ENABLE_UPX}" >> "${GITHUB_OUTPUT}"
|
||||
|
||||
- name: Download frontend dist
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: web-dist
|
||||
path: web/dist
|
||||
|
||||
- name: Sync frontend dist for embed
|
||||
shell: bash
|
||||
run: |
|
||||
rm -rf internal/web/dist
|
||||
mkdir -p internal/web
|
||||
cp -R web/dist internal/web/dist
|
||||
|
||||
- name: Build binary
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p dist
|
||||
GOWORK=off CGO_ENABLED=0 GOOS=linux GOARCH=${{ matrix.goarch }} GOARM=${{ matrix.goarm }} \
|
||||
go build -trimpath -buildvcs=false -tags "with_utls nomsgpack" \
|
||||
-ldflags "-s -w -X 'github.com/iniwex5/vohive/internal/global.Version=${{ steps.vars.outputs.version }}' -X 'github.com/iniwex5/vohive/internal/global.BuildTime=${{ steps.vars.outputs.buildtime }}'" \
|
||||
-o dist/vo-hive ./cmd/vohive
|
||||
|
||||
- name: Install UPX
|
||||
if: ${{ steps.vars.outputs.enable_upx == '1' }}
|
||||
shell: bash
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y upx-ucl || sudo apt-get install -y upx
|
||||
|
||||
- name: Compress with UPX
|
||||
if: ${{ steps.vars.outputs.enable_upx == '1' }}
|
||||
shell: bash
|
||||
run: |
|
||||
upx --best --lzma dist/vo-hive || upx -9 dist/vo-hive
|
||||
|
||||
- name: Package artifact
|
||||
shell: bash
|
||||
run: |
|
||||
OUT="vohive_${{ steps.vars.outputs.version }}_linux_${{ matrix.artifact_arch }}"
|
||||
mkdir -p out
|
||||
cp dist/vo-hive "out/${OUT}"
|
||||
sha256sum "out/${OUT}" > "out/${OUT}.sha256"
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: binaries-${{ matrix.artifact_arch }}
|
||||
path: out/*
|
||||
retention-days: 3
|
||||
|
||||
release:
|
||||
name: Publish release assets
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/v')
|
||||
steps:
|
||||
- name: Prepare release vars
|
||||
id: release_vars
|
||||
shell: bash
|
||||
run: |
|
||||
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
|
||||
RELEASE_VERSION="${GITHUB_REF_NAME}"
|
||||
else
|
||||
RELEASE_VERSION="${{ github.event.inputs.version || 'dev' }}"
|
||||
fi
|
||||
echo "release_version=${RELEASE_VERSION}" >> "${GITHUB_OUTPUT}"
|
||||
|
||||
- name: Download all artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: binaries-*
|
||||
merge-multiple: true
|
||||
path: dist
|
||||
|
||||
- name: Publish to this GitHub Release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: ${{ steps.release_vars.outputs.release_version }}
|
||||
files: dist/*
|
||||
fail_on_unmatched_files: true
|
||||
overwrite_files: true
|
||||
@@ -0,0 +1,74 @@
|
||||
name: docker-build
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
platforms:
|
||||
description: build platforms
|
||||
required: false
|
||||
default: linux/amd64,linux/arm64
|
||||
push:
|
||||
description: push image
|
||||
required: false
|
||||
default: "false"
|
||||
enable_upx:
|
||||
description: enable UPX compression (true/false)
|
||||
required: false
|
||||
default: "false"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: docker/setup-qemu-action@v3
|
||||
if: ${{ contains(inputs.platforms, 'arm') || contains(inputs.platforms, 'ppc') || contains(inputs.platforms, 's390') || contains(inputs.platforms, 'riscv') }}
|
||||
with:
|
||||
platforms: all
|
||||
|
||||
- uses: docker/setup-buildx-action@v3
|
||||
|
||||
- uses: docker/login-action@v3
|
||||
if: ${{ inputs.push == 'true' }}
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Prepare build args
|
||||
id: vars
|
||||
shell: bash
|
||||
run: |
|
||||
VERSION="dev-${GITHUB_SHA::7}"
|
||||
BUILDTIME="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
|
||||
REVISION="${GITHUB_SHA}"
|
||||
ENABLE_UPX_RAW="${{ inputs.enable_upx }}"
|
||||
case "${ENABLE_UPX_RAW}" in
|
||||
false|0|no|off) ENABLE_UPX=0 ;;
|
||||
*) ENABLE_UPX=1 ;;
|
||||
esac
|
||||
echo "version=${VERSION}" >> "${GITHUB_OUTPUT}"
|
||||
echo "buildtime=${BUILDTIME}" >> "${GITHUB_OUTPUT}"
|
||||
echo "revision=${REVISION}" >> "${GITHUB_OUTPUT}"
|
||||
echo "enable_upx=${ENABLE_UPX}" >> "${GITHUB_OUTPUT}"
|
||||
|
||||
- uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
file: Dockerfile.github
|
||||
platforms: ${{ inputs.platforms }}
|
||||
push: ${{ inputs.push == 'true' }}
|
||||
tags: ghcr.io/${{ github.repository }}/vohive:dev
|
||||
provenance: false
|
||||
sbom: false
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
build-args: |
|
||||
VERSION=${{ steps.vars.outputs.version }}
|
||||
BUILDTIME=${{ steps.vars.outputs.buildtime }}
|
||||
REVISION=${{ steps.vars.outputs.revision }}
|
||||
ENABLE_UPX=${{ steps.vars.outputs.enable_upx }}
|
||||
@@ -0,0 +1,88 @@
|
||||
name: Build and Push Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
enable_upx:
|
||||
description: enable UPX compression (true/false)
|
||||
required: false
|
||||
default: "false"
|
||||
|
||||
env:
|
||||
DOCKER_IMAGE: skyhotspur/vohive
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to DockerHub
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Extract metadata (tags, labels)
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: ${{ env.DOCKER_IMAGE }}
|
||||
tags: |
|
||||
# 语义化精确版本标签 (例如 v1.0.0 会被转换为 1.0.0)
|
||||
type=semver,pattern={{version}},enable=${{ startsWith(github.ref, 'refs/tags/v') }}
|
||||
# 手动触发时只推 sha 标签,避免覆盖 latest
|
||||
type=sha,prefix=sha-,format=short,enable=${{ github.event_name == 'workflow_dispatch' }}
|
||||
|
||||
- name: Prepare build args
|
||||
id: vars
|
||||
shell: bash
|
||||
run: |
|
||||
if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then
|
||||
VERSION="${GITHUB_REF_NAME}"
|
||||
else
|
||||
VERSION="sha-${GITHUB_SHA::7}"
|
||||
fi
|
||||
BUILDTIME="$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
|
||||
REVISION="${GITHUB_SHA}"
|
||||
if [[ "${GITHUB_EVENT_NAME}" == "workflow_dispatch" ]]; then
|
||||
ENABLE_UPX_RAW="${{ github.event.inputs.enable_upx }}"
|
||||
else
|
||||
ENABLE_UPX_RAW="false"
|
||||
fi
|
||||
case "${ENABLE_UPX_RAW}" in
|
||||
false|0|no|off) ENABLE_UPX=0 ;;
|
||||
*) ENABLE_UPX=1 ;;
|
||||
esac
|
||||
echo "version=${VERSION}" >> "${GITHUB_OUTPUT}"
|
||||
echo "buildtime=${BUILDTIME}" >> "${GITHUB_OUTPUT}"
|
||||
echo "revision=${REVISION}" >> "${GITHUB_OUTPUT}"
|
||||
echo "enable_upx=${ENABLE_UPX}" >> "${GITHUB_OUTPUT}"
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile.github
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: ${{ github.event_name != 'pull_request' }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
build-args: |
|
||||
VERSION=${{ steps.vars.outputs.version }}
|
||||
BUILDTIME=${{ steps.vars.outputs.buildtime }}
|
||||
REVISION=${{ steps.vars.outputs.revision }}
|
||||
ENABLE_UPX=${{ steps.vars.outputs.enable_upx }}
|
||||
@@ -0,0 +1,40 @@
|
||||
name: Web CI
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- 'web/**'
|
||||
- '.github/workflows/web-ci.yml'
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- 'web/**'
|
||||
- '.github/workflows/web-ci.yml'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
web-check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
cache-dependency-path: web/package-lock.json
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci --prefix web
|
||||
|
||||
- name: Lint
|
||||
run: npm run lint --prefix web
|
||||
|
||||
- name: Typecheck
|
||||
run: npm run typecheck --prefix web
|
||||
|
||||
- name: Build
|
||||
run: npm run build --prefix web
|
||||
Reference in new issue
Block a user