Skip to content

Commit e150b7e

Browse files
feat: add shared daily tags to base image builds
1 parent 0c1bea4 commit e150b7e

2 files changed

Lines changed: 25 additions & 6 deletions

File tree

‎.github/workflows/build_base_and_push.yml‎

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ on:
66
workflow_dispatch:
77
inputs:
88
dockerImageTag:
9-
description: 'Image Tag'
9+
description: 'Base image version prefix (YYYYMMDD is appended automatically)'
1010
default: 'v0.9.0'
1111
required: true
1212
dockerImageTagWithLatest:
13-
description: '是否发布latest tag(正式发版时选择,测试版本切勿选择)'
13+
description: 'Publish version, major-version and latest aliases (official releases only)'
1414
default: false
1515
required: true
1616
type: boolean
@@ -34,7 +34,22 @@ on:
3434
- dockerhub, aliyun-registry
3535

3636
jobs:
37+
prepare-tags:
38+
runs-on: ubuntu-latest
39+
outputs:
40+
image_tag: ${{ steps.tag.outputs.image_tag }}
41+
steps:
42+
- name: Generate dated base image tag
43+
id: tag
44+
env:
45+
VERSION_TAG: ${{ inputs.dockerImageTag }}
46+
run: |
47+
image_tag="$VERSION_TAG-$(TZ=Asia/Shanghai date +'%Y%m%d')"
48+
printf 'image_tag=%s\n' "$image_tag" >> "$GITHUB_OUTPUT"
49+
printf 'Base image tag: `%s`\n' "$image_tag" >> "$GITHUB_STEP_SUMMARY"
50+
3751
build-and-push-to-aliyun-registry:
52+
needs: prepare-tags
3853
if: ${{ contains(github.event.inputs.registry, 'aliyun') }}
3954
runs-on: ubuntu-latest
4055
steps:
@@ -47,13 +62,14 @@ jobs:
4762
env:
4863
DOCKER_IMAGE: ${{ secrets.ALIYUN_REGISTRY_HOST }}/dataease/sqlbot-python-pg
4964
TAG_NAME: ${{ inputs.dockerImageTag }}
65+
DATED_TAG: ${{ needs.prepare-tags.outputs.image_tag }}
5066
TAG_NAME_WITH_LATEST: ${{ inputs.dockerImageTagWithLatest }}
5167
run: |
5268
image_tags() {
5369
local image="$1"
54-
local tags="$image:$TAG_NAME"
70+
local tags="$image:$DATED_TAG"
5571
if [[ "$TAG_NAME_WITH_LATEST" == 'true' ]]; then
56-
tags="$tags,$image:${TAG_NAME%%.*},$image:latest"
72+
tags="$tags,$image:$TAG_NAME,$image:${TAG_NAME%%.*},$image:latest"
5773
fi
5874
printf '%s' "$tags"
5975
}
@@ -81,6 +97,7 @@ jobs:
8197
--set 'build-base.output=type=image,push=true,oci-mediatypes=false' base build-base
8298
8399
build-and-push-to-dockerhub:
100+
needs: prepare-tags
84101
if: ${{ contains(github.event.inputs.registry, 'dockerhub') }}
85102
runs-on: ubuntu-latest
86103
steps:
@@ -93,13 +110,14 @@ jobs:
93110
env:
94111
DOCKER_IMAGE: dataease/sqlbot-python-pg
95112
TAG_NAME: ${{ inputs.dockerImageTag }}
113+
DATED_TAG: ${{ needs.prepare-tags.outputs.image_tag }}
96114
TAG_NAME_WITH_LATEST: ${{ inputs.dockerImageTagWithLatest }}
97115
run: |
98116
image_tags() {
99117
local image="$1"
100-
local tags="$image:$TAG_NAME"
118+
local tags="$image:$DATED_TAG"
101119
if [[ "$TAG_NAME_WITH_LATEST" == 'true' ]]; then
102-
tags="$tags,$image:${TAG_NAME%%.*},$image:latest"
120+
tags="$tags,$image:$TAG_NAME,$image:${TAG_NAME%%.*},$image:latest"
103121
fi
104122
printf '%s' "$tags"
105123
}

‎docs/agents/packaging.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ node --check g2-ssr/charts/<changed-file.js>
5959
规则:
6060

6161
- `build-base-and-push` 使用 `docker buildx bake -f docker-bake.hcl base build-base` 生成并发布同一批次的 `sqlbot-python-pg` 和 `sqlbot-build-base`。两个镜像共享 PostgreSQL 底层和语言工具。图形运行库的补丁只影响运行基础镜像的构建。
62+
- 基础镜像标签为输入版本加北京时间日期(如 `v1.10.4-20261111`),同一次工作流中的两个镜像和所有仓库共用该标签,并在 Actions 摘要中显示。同版本同一天重跑会更新同一标签。正式发布选项还会生成原版本、主版本和 `latest` 别名。
6263
- 构建应用镜像时,`SQLBOT_RUNTIME_IMAGE` 和 `SQLBOT_BUILD_IMAGE` 可传入同一批次的基础镜像标签或 digest。工作流对应的输入为 `runtimeBaseImage` 和 `builderBaseImage`,各发布任务默认使用目标仓库中对应的 `latest` 标签。
6364
- 本地执行 `docker buildx bake -f docker-bake.hcl --load base build-base` 构建两个基础镜像,或执行 `docker buildx bake -f docker-bake.hcl --load app` 构建完整应用镜像。单独验证 PostgreSQL 镜像时使用 `docker buildx build -f Dockerfile-base --target pg-base --load -t sqlbot-pg-base:local .`。漏洞复扫以最终应用镜像为准。
6465
- 这些工作流都是发布/分发流程,不要因为普通代码修改建议运行。

0 commit comments

Comments
 (0)