Skip to content

Commit ca9c71d

Browse files
committed
Merge branch 'dev' into debug
2 parents fd94a65 + 21aa629 commit ca9c71d

23 files changed

Lines changed: 544 additions & 232 deletions

.github/archived/build.yaml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
name: 构建并推送
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
workflow_dispatch:
8+
inputs:
9+
profile:
10+
description: "构建配置 (release/debug)"
11+
type: choice
12+
options: [ release, debug ]
13+
required: false
14+
default: release
15+
16+
permissions:
17+
contents: read
18+
packages: write
19+
20+
env:
21+
REGISTRY: ghcr.io
22+
HTTP_PROXY: http://127.0.0.1:6152
23+
HTTPS_PROXY: http://127.0.0.1:6152
24+
25+
jobs:
26+
build-and-push:
27+
name: 构建多平台镜像并推送到 GHCR
28+
runs-on: [ self-hosted, macOS, ARM64 ]
29+
30+
steps:
31+
# - name: 登录到 GHCR
32+
# uses: docker/login-action@v3
33+
# with:
34+
# registry: ${{ env.REGISTRY }}
35+
# username: ${{ github.repository_owner }}
36+
# password: ${{ secrets.GITHUB_TOKEN }}
37+
38+
# - name: 检查 base-debug 可用性
39+
# run: |
40+
# docker pull ghcr.io/${{ github.repository_owner }}/convertor/base-debug:2.6.15 || echo "base-debug 镜像不可用,继续构建"
41+
# sleep 600
42+
43+
- name: 检出代码
44+
uses: actions/checkout@v4
45+
46+
- name: 确认 Xcode 命令行工具已安装
47+
run: xcode-select -p || sudo xcode-select --install
48+
49+
- name: 安装 Rust 工具链
50+
uses: dtolnay/rust-toolchain@stable
51+
52+
# 构建 builder 工具用于后续步骤
53+
- name: 构建 builder 工具
54+
run: cargo install --path crates/builder
55+
56+
- name: 设置构建参数
57+
id: vars
58+
run: |
59+
PROFILE="${{ github.event.inputs.profile }}"
60+
if [ "${{ github.event_name }}" = "push" ] && [ "${{ github.ref }}" = "refs/heads/dev" ]; then PROFILE="debug"; fi
61+
if [ -z "$PROFILE" ]; then PROFILE="release"; fi
62+
echo "profile=$PROFILE" >> "$GITHUB_OUTPUT"
63+
64+
- name: 安装 Zig 编译器
65+
uses: mlugg/setup-zig@v2
66+
67+
- name: 安装 cargo-zigbuild
68+
run: command -v cargo-zigbuild || cargo install cargo-zigbuild --locked
69+
70+
- name: 安装 pnpm
71+
uses: pnpm/action-setup@v4
72+
with:
73+
version: latest
74+
75+
- name: 安装 Node.js
76+
uses: actions/setup-node@v4
77+
with:
78+
node-version: lts/*
79+
80+
- name: 安装 Dashboard 依赖
81+
run: pnpm install
82+
working-directory: dashboard
83+
84+
- name: 登录到 GHCR
85+
uses: docker/login-action@v3
86+
with:
87+
registry: ${{ env.REGISTRY }}
88+
username: ${{ github.repository_owner }}
89+
password: ${{ secrets.GITHUB_TOKEN }}
90+
91+
- name: Set up Docker Buildx
92+
uses: docker/setup-buildx-action@v3
93+
with:
94+
driver-opts: network=host
95+
config-inline: |
96+
[registry."ghcr.io"]
97+
[registry."ghcr.io".auth]
98+
username = "${{ github.repository_owner }}"
99+
password = "${{ secrets.GITHUB_TOKEN }}"
100+
101+
- name: 检查基础镜像可访问性,不存在则构建并推送
102+
run: |
103+
set -e
104+
BASE_IMAGE=$(builder tag base ${{ steps.vars.outputs.profile }} --registry ghcr --user ${{ github.repository_owner }})
105+
echo "🔍 检查基础镜像: $BASE_IMAGE"
106+
107+
if docker buildx imagetools inspect "$BASE_IMAGE" > /dev/null 2>&1; then
108+
echo "✅ 基础镜像已存在,跳过构建"
109+
else
110+
echo "⚠️ 基础镜像不存在,开始构建并推送..."
111+
builder image base \
112+
${{ steps.vars.outputs.profile }} \
113+
--arch amd,arm \
114+
--user ${{ github.repository_owner }} \
115+
--registry ghcr
116+
echo "✅ 基础镜像构建并推送完成"
117+
fi
118+
119+
- name: 使用 conv 构建并推送镜像(多架构)
120+
run: |
121+
# builder image convd 会自动:
122+
# 1. 构建二进制、Dashboard 和 Docker 镜像(多架构)
123+
# 2. 推送到指定的 registry
124+
# 3. 创建多架构 manifest(版本号 + latest 标签)
125+
builder image convd \
126+
${{ steps.vars.outputs.profile }} \
127+
--arch amd,arm \
128+
--dashboard \
129+
--user ${{ github.repository_owner }} \
130+
--registry ghcr
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: 构建共享逻辑
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
profile:
7+
description: "构建模式: release 或 debug"
8+
required: true
9+
type: string
10+
secrets:
11+
HARBOR_SECRET:
12+
required: true
13+
14+
permissions:
15+
contents: read
16+
packages: read
17+
18+
env:
19+
REGISTRY: harbor.internal.bppleman.cn:30443
20+
REGISTRY_USERNAME: robot$harbor-bppleman
21+
REGISTRY_SECRET: ${{ secrets.HARBOR_SECRET }}
22+
HTTP_PROXY: http://127.0.0.1:6152
23+
HTTPS_PROXY: http://127.0.0.1:6152
24+
25+
jobs:
26+
build-and-push:
27+
name: 构建多平台镜像并推送到 Harbor (${{ inputs.profile }})
28+
runs-on: [ self-hosted, macOS, ARM64 ]
29+
30+
steps:
31+
- name: 检出代码
32+
uses: actions/checkout@v4
33+
34+
# 构建 builder 工具用于后续步骤
35+
- name: 构建 builder 工具
36+
run: cargo install --path crates/builder
37+
38+
- name: 初始化 fnm 环境
39+
run: |
40+
eval "$(fnm env --shell bash)"
41+
fnm use 24
42+
echo "$(dirname $(which node))" >> "$GITHUB_PATH"
43+
44+
- name: 安装 Dashboard 依赖
45+
run: pnpm install
46+
working-directory: dashboard
47+
48+
- name: 登录到 Harbor
49+
uses: docker/login-action@v3
50+
with:
51+
registry: ${{ env.REGISTRY }}
52+
username: ${{ env.REGISTRY_USERNAME }}
53+
password: ${{ env.REGISTRY_SECRET }}
54+
55+
- name: Set up Docker Buildx
56+
uses: docker/setup-buildx-action@v3
57+
with:
58+
driver-opts: network=host
59+
config-inline: |
60+
[registry."${{ env.REGISTRY }}"]
61+
[registry."${{ env.REGISTRY }}".auth]
62+
username = "${{ env.REGISTRY_USERNAME }}"
63+
password = "${{ env.REGISTRY_SECRET }}"
64+
65+
- name: 检查基础镜像可访问性,不存在则构建并推送
66+
run: |
67+
set -e
68+
BASE_IMAGE=$( \
69+
builder tag base ${{ inputs.profile }} \
70+
--registry ${{ env.REGISTRY }} \
71+
--user ${{ github.repository_owner }}
72+
)
73+
echo "🔍 检查基础镜像: $BASE_IMAGE"
74+
75+
if docker buildx imagetools inspect "$BASE_IMAGE" > /dev/null 2>&1; then
76+
echo "✅ 基础镜像已存在,跳过构建"
77+
else
78+
echo "⚠️ 基础镜像不存在,开始构建并推送..."
79+
builder image base ${{ inputs.profile }} \
80+
--arch amd,arm \
81+
--registry ${{ env.REGISTRY }} \
82+
--user ${{ github.repository_owner }}
83+
echo "✅ 基础镜像构建并推送完成"
84+
fi
85+
86+
- name: 使用 conv 构建并推送镜像(多架构)
87+
run: |
88+
# builder image convd 会自动:
89+
# 1. 构建二进制、Dashboard 和 Docker 镜像(多架构)
90+
# 2. 推送到指定的 registry
91+
# 3. 创建多架构 manifest(版本号 + latest 标签)
92+
builder image convd ${{ inputs.profile }} \
93+
--arch amd,arm \
94+
--dashboard \
95+
--registry ${{ env.REGISTRY }} \
96+
--user ${{ github.repository_owner }}
97+

.github/workflows/build-debug.yml

Lines changed: 6 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -6,87 +6,10 @@ on:
66
- debug
77
workflow_dispatch:
88

9-
permissions:
10-
contents: read
11-
packages: read
12-
13-
env:
14-
REGISTRY: harbor.internal.bppleman.cn:30443
15-
REGISTRY_USERNAME: robot$harbor-bppleman
16-
REGISTRY_SECRET: ${{ secrets.HARBOR_SECRET }}
17-
HTTP_PROXY: http://127.0.0.1:6152
18-
HTTPS_PROXY: http://127.0.0.1:6152
19-
209
jobs:
21-
build-and-push:
22-
name: 构建多平台镜像并推送到 Harbor
23-
runs-on: [self-hosted, macOS, ARM64]
24-
25-
steps:
26-
- name: 检出代码
27-
uses: actions/checkout@v4
28-
29-
# 构建 builder 工具用于后续步骤
30-
- name: 构建 builder 工具
31-
run: cargo install --path crates/builder
32-
33-
- name: 初始化 fnm 环境
34-
run: |
35-
eval "$(fnm env --shell bash)"
36-
fnm use 24
37-
echo "$(dirname $(which node))" >> "$GITHUB_PATH"
38-
39-
- name: 安装 Dashboard 依赖
40-
run: pnpm install
41-
working-directory: dashboard
42-
43-
- name: 登录到 Harbor
44-
uses: docker/login-action@v3
45-
with:
46-
registry: ${{ env.REGISTRY }}
47-
username: ${{ env.REGISTRY_USERNAME }}
48-
password: ${{ env.REGISTRY_SECRET }}
49-
50-
- name: Set up Docker Buildx
51-
uses: docker/setup-buildx-action@v3
52-
with:
53-
driver-opts: network=host
54-
config-inline: |
55-
[registry."${{ env.REGISTRY }}"]
56-
[registry."${{ env.REGISTRY }}".auth]
57-
username = "${{ env.REGISTRY_USERNAME }}"
58-
password = "${{ env.REGISTRY_SECRET }}"
59-
60-
- name: 检查基础镜像可访问性,不存在则构建并推送
61-
run: |
62-
set -e
63-
BASE_IMAGE=$( \
64-
builder tag base debug \
65-
--registry ${{ env.REGISTRY }} \
66-
--user ${{ github.repository_owner }}
67-
)
68-
echo "🔍 检查基础镜像: $BASE_IMAGE"
69-
70-
if docker buildx imagetools inspect "$BASE_IMAGE" > /dev/null 2>&1; then
71-
echo "✅ 基础镜像已存在,跳过构建"
72-
else
73-
echo "⚠️ 基础镜像不存在,开始构建并推送..."
74-
builder image base debug \
75-
--arch amd,arm \
76-
--registry ${{ env.REGISTRY }} \
77-
--user ${{ github.repository_owner }}
78-
echo "✅ 基础镜像构建并推送完成"
79-
fi
80-
81-
- name: 使用 conv 构建并推送镜像(多架构)
82-
run: |
83-
# builder image convd 会自动:
84-
# 1. 构建二进制、Dashboard 和 Docker 镜像(多架构)
85-
# 2. 推送到指定的 registry
86-
# 3. 创建多架构 manifest(版本号 + latest 标签)
87-
builder image convd \
88-
debug \
89-
--arch amd,arm \
90-
--dashboard \
91-
--registry ${{ env.REGISTRY }} \
92-
--user ${{ github.repository_owner }}
10+
build:
11+
uses: ./.github/workflows/_build-shared.yml
12+
with:
13+
profile: debug
14+
secrets:
15+
HARBOR_SECRET: ${{ secrets.HARBOR_SECRET }}

0 commit comments

Comments
 (0)