Skip to content

Commit

Permalink
feat(tidb-operator): add package config for operator v2 (#530)
Browse files Browse the repository at this point in the history
## Background

TiDB-operator owner want publish artifacts for the refactoring
tidb-operator, the version start from v2.0.0.

---------

Signed-off-by: wuhuizuo <wuhuizuo@126.com>
  • Loading branch information
wuhuizuo authored Jan 10, 2025
1 parent ee7bfd3 commit aa1a8e7
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 5 deletions.
6 changes: 3 additions & 3 deletions .github/scripts/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function test_get_builder_freedom_releasing() {
local profile="release"
local os="linux"
for ac in $architectures; do
for version in v1.5.0 v1.6.0; do
for version in v2.0.0 v1.6.0 v1.5.0; do
echo -en "[🚢] $cm $os $ac $version $profile:\t"
$script "$cm" "$os" "$ac" "$version" $profile
done
Expand Down Expand Up @@ -192,7 +192,7 @@ function test_gen_package_artifacts_script_freedom_releasing() {
local cm="tidb-operator"
local os="linux"
for ac in $architectures; do
for version in v1.5.0 v1.6.0; do
for version in v2.0.0 v1.6.0 v1.5.0; do
echo -en "[📃📦] $cm $os $ac $version $profile:\t"
$script "$cm" "$os" "$ac" "$version" $profile branch-xxx 123456789abcdef
shellcheck -S error packages/scripts/build-package-artifacts.sh
Expand Down Expand Up @@ -287,7 +287,7 @@ function test_gen_package_images_script_freedom_releasing() {
# tidb-operator
local cm="tidb-operator"
for ac in $architectures; do
for version in v1.6.0 v1.5.0; do
for version in v2.0.0 v1.6.0 v1.5.0; do
echo -en "[📃💿] $cm $os $ac $version $profile:\t"
$script "$cm" linux "$ac" "$version" "$profile" branch-xxx 123456789abcdef
shellcheck -S error packages/scripts/build-package-images.sh
Expand Down
27 changes: 25 additions & 2 deletions packages/packages.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -1387,8 +1387,31 @@ components:
- if: {{ semver.CheckConstraint "< 1.6.0-0" .Release.version }}
image: ghcr.io/pingcap-qe/cd/builders/tidb-operator:v2024.10.8-14-g52a7228-go1.21
routers:
- description: starts from 1.5.0
if: {{ semver.CheckConstraint ">= 1.5.0-0" .Release.version }}
- description: for range [v2.0.0, )
if: {{ semver.CheckConstraint ">= 2.0.0-0" .Release.version }}
os: [linux]
arch: [amd64, arm64]
profile: [release]
steps:
release:
- script: make build
artifacts:
- name: container image - operator
type: image
artifactory:
repo: "{{ .Release.registry }}/pingcap/tidb-operator/images/tidb-operator"
context: .
dockerfile: image/Dockerfile
target: operator # target build stage in Dockerfile
- name: container image - prestop-checker
type: image
artifactory:
repo: "{{ .Release.registry }}/pingcap/tidb-operator/images/prestop-checker"
context: .
dockerfile: image/Dockerfile
target: prestop-checker # target build stage in Dockerfile
- description: for range [v1.5.0, v2.0.0)
if: {{ semver.CheckConstraint ">= 1.5.0-0, < 2.0.0-0" .Release.version }}
os: [linux]
arch: [amd64, arm64]
profile: [release, fips]
Expand Down
7 changes: 7 additions & 0 deletions packages/scripts/build-package-images.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Code generated by gomplate, DO NOT EDIT.

# It needs kaniko and oras tools, but it can be run in different containers for seperated stages.
# kaniko: https://github.com/GoogleContainerTools/kaniko/blob/main/README.md
# oras: https://oras.land/docs/category/oras-commands/

set -exo pipefail

Expand Down Expand Up @@ -123,12 +125,17 @@ build_and_push_images() {
destination="{{ .artifactory.repo }}:$tag"
digest_file="${archive_dir}/digest.txt"
kaniko_options="$kaniko_global_options --destination=${destination} --digest-file=${digest_file}"

{{- if has . "build_args" }}
{{- range .build_args }}
kaniko_options="$kaniko_options --build-arg {{.}}"
{{- end }}
{{- end }}

{{- if has . "target" }}
kaniko_options="$kaniko_options --target {{.target}} --skip-unused-stages"
{{- end }}

{{- if has . "context" }}
# just build it with native build from git repo's dockerfile
$kaniko_executor $kaniko_options --context {{ .context }} --dockerfile {{ .dockerfile }}
Expand Down

0 comments on commit aa1a8e7

Please sign in to comment.