Skip to content

Commit fb60cf3

Browse files
lybcodesti-chi-bot
authored andcommitted
This is an automated cherry-pick of pingcap#6606
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
1 parent 7740398 commit fb60cf3

3 files changed

Lines changed: 304 additions & 0 deletions

File tree

.github/workflows/release-v1.yaml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Release Charts v1
2+
3+
on:
4+
push:
5+
tags:
6+
- "v1.*.*"
7+
workflow_dispatch:
8+
inputs:
9+
git_ref:
10+
description: 'Branch or commit hash (for v1.x branch)'
11+
required: true
12+
type: string
13+
release_tag:
14+
description: 'Release tag (empty means the same with GitRef)'
15+
required: false
16+
type: string
17+
br_federation:
18+
description: 'Whether to release BR federation manager'
19+
required: false
20+
type: boolean
21+
default: true
22+
fips:
23+
description: 'Whether to enable FIPS'
24+
required: false
25+
type: boolean
26+
default: false
27+
28+
jobs:
29+
release-charts:
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@v4
33+
with:
34+
ref: ${{ github.event.inputs.git_ref || github.ref }}
35+
36+
- name: Set up Helm
37+
uses: azure/setup-helm@v4
38+
with:
39+
version: '3.14.0'
40+
41+
- name: Determine release tag and validate
42+
id: release_tag
43+
run: |
44+
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
45+
RELEASE_TAG="${{ github.event.inputs.release_tag }}"
46+
if [ -z "$RELEASE_TAG" ]; then
47+
RELEASE_TAG="${{ github.event.inputs.git_ref }}"
48+
fi
49+
if [ "${{ github.event.inputs.fips }}" == "true" ]; then
50+
RELEASE_TAG="${RELEASE_TAG}-fips"
51+
fi
52+
BR_FEDERATION="${{ github.event.inputs.br_federation }}"
53+
if [ -z "$BR_FEDERATION" ]; then
54+
BR_FEDERATION="true"
55+
fi
56+
else
57+
# push tags
58+
RELEASE_TAG="${{ github.ref_name }}"
59+
BR_FEDERATION="true"
60+
fi
61+
62+
if [[ ! "$RELEASE_TAG" =~ ^v1\.[0-9]+\.[0-9]+ ]]; then
63+
echo "Error: Release tag must be v1.x.x format, got: $RELEASE_TAG"
64+
echo "This workflow is only for v1.x releases. Please use the correct version format."
65+
exit 1
66+
fi
67+
68+
echo "tag=${RELEASE_TAG}" >> $GITHUB_OUTPUT
69+
echo "br_federation=${BR_FEDERATION}" >> $GITHUB_OUTPUT
70+
71+
- name: Build charts
72+
env:
73+
V_RELEASE: ${{ steps.release_tag.outputs.tag }}
74+
BR_FEDERATION: ${{ steps.release_tag.outputs.br_federation }}
75+
run: |
76+
make charts/build
77+
78+
- name: Update index.yaml
79+
if: ${{ !contains(steps.release_tag.outputs.tag, 'latest') && !contains(steps.release_tag.outputs.tag, 'nightly') && !contains(steps.release_tag.outputs.tag, 'test') }}
80+
run: |
81+
set -e
82+
CHARTS_BUILD_DIR="output/chart"
83+
cd ${CHARTS_BUILD_DIR}
84+
curl -f http://charts.pingcap.org/index.yaml -o index.yaml 2>/dev/null || true
85+
helm repo index . --url https://charts.pingcap.org/ --merge index.yaml 2>/dev/null || helm repo index . --url https://charts.pingcap.org/
86+
87+
- name: Upload all charts and index.yaml to Tencent COS
88+
uses: sylingd/tencent-cos-and-cdn-action@v1
89+
with:
90+
secret_id: ${{ secrets.TENCENT_COS_ACCESS_KEY }}
91+
secret_key: ${{ secrets.TENCENT_COS_SECRET_KEY }}
92+
cos_bucket: ${{ vars.TENCENT_COS_BUCKET_NAME }}
93+
cos_region: ap-beijing
94+
local_path: ./output/chart
95+
remote_path: /

Makefile

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,154 @@ docker-release:
256256
# More info on the awk command:
257257
# http://linuxcommand.org/lc3_adv_awk.php
258258

259+
<<<<<<< HEAD
259260
.PHONY: help
260261
help: ## Display this help.
261262
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
263+
=======
264+
.PHONY: runtimegen
265+
runtimegen: bin/runtime-gen
266+
$(RUNTIME_GEN) \
267+
--output-dir=$(RUNTIME_PKG_DIR) \
268+
--go-header-file=$(BOILERPLATE_FILE) \
269+
github.com/pingcap/tidb-operator/api/v2/core/v1alpha1
270+
271+
.PHONY: release
272+
release: bin/helm crd
273+
$(ROOT)/hack/release.sh
274+
275+
.PHONY: doc
276+
doc: bin/mdtoc
277+
find docs -name "*.md" | xargs $(MDTOC) --inplace --max-depth 5
278+
279+
.PHONY: crd
280+
crd: bin/controller-gen build/crd-modifier
281+
$(CONTROLLER_GEN) crd:generateEmbeddedObjectMeta=true output:crd:artifacts:config=$(ROOT)/manifests/crd paths=$(API_PATH)/...
282+
$(BIN_DIR)/crd-modifier -dir $(ROOT)/manifests/crd
283+
284+
285+
.PHONY: tidy
286+
tidy: $(addprefix tidy/,$(GO_TOOL_BIN))
287+
cd $(API_PATH) && go mod tidy
288+
cd $(VALIDATION_TEST_PATH) && go mod tidy
289+
go mod tidy
290+
291+
.PHONY: $(addprefix tidy/,$(GO_TOOL_BIN))
292+
$(addprefix tidy/,$(GO_TOOL_BIN)):
293+
cd $(TOOLS_PATH)/$(patsubst tidy/%,%,$@) && go mod tidy
294+
295+
gengo: GEN_DIR ?= ./...
296+
gengo: bin/mockgen
297+
BOILERPLATE_FILE=${MOCK_BOILERPLATE_FILE} GOBIN=$(BIN_DIR) GO_MODULE=$(GO_MODULE) go generate $(GEN_DIR)
298+
299+
.PHONY: license
300+
license: bin/license-eye
301+
$(LICENSE_EYE) -c .github/licenserc.yaml header fix
302+
303+
ALL_GEN = tidy codegen crd runtimegen gengo overlaygen doc
304+
.PHONY: generate
305+
generate: $(ALL_GEN) license
306+
307+
.PHONY: verify/license
308+
verify/license: bin/license-eye
309+
$(LICENSE_EYE) -c .github/licenserc.yaml header check
310+
311+
.PHONY: verify/feature-gates
312+
verify/feature-gates:
313+
cd $(ROOT) && go run cmd/verify-feature-gates/main.go
314+
315+
.PHONY: verify
316+
verify: $(addprefix verify/,$(ALL_GEN)) verify/license verify/feature-gates
317+
verify/%:
318+
$(ROOT)/hack/verify.sh make $*
319+
320+
.PHONY: lint
321+
lint: bin/golangci-lint
322+
$(GOLANGCI_LINT) run -v ./...
323+
324+
.PHONY: lint-fix
325+
lint-fix: bin/golangci-lint
326+
$(GOLANGCI_LINT) run -v ./... --fix
327+
328+
.PHONY: unit
329+
unit:
330+
cd $(VALIDATION_TEST_PATH) && go test -race ./...
331+
go test -race $$(go list -e ./... | grep -v cmd | grep -v tools | grep -v tests/e2e | grep -v third_party) \
332+
-cover -coverprofile=coverage.txt -covermode=atomic
333+
sed -i.bak '/generated/d;/fake.go/d' coverage.txt && rm coverage.txt.bak
334+
335+
.PHONY: check
336+
check: lint unit verify
337+
338+
.PHONY: install-githooks
339+
install-githooks:
340+
@echo "Installing git hooks..."
341+
@mkdir -p .git/hooks
342+
@ln -sf ../../hack/githooks/pre-push .git/hooks/pre-push
343+
@echo "pre-push hook installed successfully."
344+
@echo "You can run 'make check' manually to check your code before push."
345+
346+
.PHONY: e2e/prepare
347+
e2e/prepare: bin/kind release
348+
$(ROOT)/hack/e2e.sh --prepare
349+
350+
# e2e/run: Run e2e tests (excluding packages specified in E2E_EXCLUDED_PACKAGES)
351+
# Default excludes 'upgrade' package which requires special build tags
352+
# Usage: make e2e/run
353+
# To exclude additional packages: E2E_EXCLUDED_PACKAGES="upgrade,some-other-package" make e2e/run
354+
# To run all packages: E2E_EXCLUDED_PACKAGES="" make e2e/run
355+
.PHONY: e2e/run
356+
e2e/run:
357+
$(ROOT)/hack/e2e.sh run $(GINKGO_OPTS)
358+
359+
.PHONY: e2e/run-upgrade
360+
e2e/run-upgrade:
361+
$(ROOT)/hack/e2e.sh run-upgrade $(GINKGO_OPTS)
362+
363+
# e2e: Run full e2e test suite including both regular and upgrade tests
364+
.PHONY: e2e
365+
e2e: bin/kind release
366+
$(ROOT)/hack/e2e.sh --prepare run run-upgrade $(GINKGO_OPTS)
367+
368+
.PHONY: e2e/deploy
369+
e2e/deploy: bin/kubectl release
370+
$(KUBECTL) $(KUBE_OPT) apply --server-side=true -f $(OUTPUT_DIR)/manifests/tidb-operator.crds.yaml
371+
$(KUBECTL) $(KUBE_OPT) apply --server-side=true -f $(OUTPUT_DIR)/manifests/tidb-operator-e2e.yaml
372+
373+
.PHONY: kube
374+
kube: bin/kind bin/kubectl
375+
@echo "ensure that the kubernetes env is existing"
376+
V_KIND=$(KIND) V_KUBECTL=$(KUBECTL) $(ROOT)/hack/kind.sh
377+
378+
.PHONY: reload/operator
379+
reload/operator: bin/kubectl
380+
$(KUBECTL) $(KUBE_OPT) delete pod `$(KUBECTL) $(KUBE_OPT) get pods | awk '/operator/{ print $$1 }'`
381+
382+
.PHONY: logs/operator
383+
logs/operator: bin/kubectl
384+
$(KUBECTL) $(KUBE_OPT) logs -f `$(KUBECTL) $(KUBE_OPT) get pods | awk '/operator/{ print $$1 }'`
385+
386+
OVERLAY_GEN = $(BIN_DIR)/overlay-gen
387+
bin/overlay-gen:
388+
$(ROOT)/hack/build.sh overlay-gen
389+
390+
RUNTIME_GEN = $(BIN_DIR)/runtime-gen
391+
bin/runtime-gen:
392+
$(ROOT)/hack/build.sh runtime-gen
393+
394+
# Generic target for allowed bin/xxx tools - automatically defines XXX variable (with hyphens converted to underscores)
395+
# e.g. bin/abc-def will define ABC_DEF = $(BIN_DIR)/abc-def
396+
define make_bin_target
397+
$(eval $(shell echo $(1) | tr '[:lower:]-' '[:upper:]_') = $(BIN_DIR)/$(1))
398+
endef
399+
400+
.PHONY: $(addprefix bin/,$(GO_TOOL_BIN))
401+
$(addprefix bin/,$(GO_TOOL_BIN)): bin/%: tidy/%
402+
$(call make_bin_target,$(patsubst bin/%,%,$@))
403+
./hack/tools.sh $(patsubst bin/%,%,$@)
404+
405+
406+
.PHONY: charts/build
407+
charts/build:
408+
$(ROOT)/hack/charts-build.sh
409+
>>>>>>> b2e036e9d (feat: add new github action for tidb-operator-release v1.x (#6606))

hack/charts-build.sh

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2024 PingCAP, Inc.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
17+
set -o errexit
18+
set -o nounset
19+
set -o pipefail
20+
21+
ROOT=$(cd $(dirname "${BASH_SOURCE[0]}")/..; pwd -P)
22+
23+
RELEASE_TAG=${V_RELEASE:-"test"}
24+
CHARTS_BUILD_DIR="output/chart"
25+
CHART_ITEMS="tidb-operator tidb-drainer tidb-lightning"
26+
BR_FEDERATION=${BR_FEDERATION:-"true"}
27+
28+
mkdir -p ${CHARTS_BUILD_DIR}
29+
30+
# Build charts
31+
for chartItem in ${CHART_ITEMS}; do
32+
[ ! -d "charts/${chartItem}" ] && continue
33+
34+
chartPrefixName="${chartItem}-${RELEASE_TAG}"
35+
36+
# Update Chart.yaml
37+
sed -i.bak "s/^version:.*/version: ${RELEASE_TAG}/g" charts/${chartItem}/Chart.yaml
38+
sed -i.bak "s/^appVersion:.*/appVersion: ${RELEASE_TAG}/g" charts/${chartItem}/Chart.yaml
39+
rm -f charts/${chartItem}/Chart.yaml.bak
40+
41+
# Update values.yaml
42+
sed -i.bak -E "s#pingcap/(tidb-operator|tidb-backup-manager):[^[:space:]]*#pingcap/\\1:${RELEASE_TAG}#g" charts/${chartItem}/values.yaml 2>/dev/null || true
43+
rm -f charts/${chartItem}/values.yaml.bak 2>/dev/null || true
44+
45+
# Package chart
46+
tar -zcf ${CHARTS_BUILD_DIR}/${chartPrefixName}.tgz -C charts ${chartItem}
47+
sha256sum ${CHARTS_BUILD_DIR}/${chartPrefixName}.tgz > ${CHARTS_BUILD_DIR}/${chartPrefixName}.sha256
48+
done
49+
50+
# Handle br-federation
51+
if [[ "$BR_FEDERATION" == "true" ]] && [ -d "charts/br-federation" ]; then
52+
chartItem="br-federation"
53+
chartPrefixName="${chartItem}-${RELEASE_TAG}"
54+
sed -i.bak "s/^version:.*/version: ${RELEASE_TAG}/g" charts/${chartItem}/Chart.yaml
55+
sed -i.bak "s/^appVersion:.*/appVersion: ${RELEASE_TAG}/g" charts/${chartItem}/Chart.yaml
56+
rm -f charts/${chartItem}/Chart.yaml.bak
57+
sed -i.bak -E "s#pingcap/br-federation-manager:[^[:space:]]*#pingcap/br-federation-manager:${RELEASE_TAG}#g" charts/${chartItem}/values.yaml
58+
rm -f charts/${chartItem}/values.yaml.bak
59+
tar -zcf ${CHARTS_BUILD_DIR}/${chartPrefixName}.tgz -C charts ${chartItem}
60+
sha256sum ${CHARTS_BUILD_DIR}/${chartPrefixName}.tgz > ${CHARTS_BUILD_DIR}/${chartPrefixName}.sha256
61+
fi

0 commit comments

Comments
 (0)