Skip to content

Commit c9fcfe3

Browse files
committed
chore(apps/prod/tekton/configs/tasks): add tag for release branches when building (#1025)
Signed-off-by: wuhuizuo <[email protected]> --------- Signed-off-by: wuhuizuo <[email protected]>
1 parent 3af78de commit c9fcfe3

File tree

6 files changed

+61
-10
lines changed

6 files changed

+61
-10
lines changed

apps/prod/tekton/configs/pipelines/pingcap-build-package-darwin.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ spec:
8787
runAfter:
8888
- checkout
8989
taskRef:
90-
name: pingcap-get-release-version
90+
name: pingcap-get-set-release-version
9191
workspaces:
9292
- name: source
9393
workspace: source

apps/prod/tekton/configs/pipelines/pingcap-build-package.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ spec:
9393
runAfter:
9494
- checkout
9595
taskRef:
96-
name: pingcap-get-release-version
96+
name: pingcap-get-set-release-version
9797
workspaces:
9898
- name: source
9999
workspace: source

apps/prod/tekton/configs/tasks/kustomization.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ resources:
3030
- pingcap-compose-offline-pkgs.yaml
3131
- pingcap-deliver-image.yaml
3232
- pingcap-get-builder-image.yaml
33-
- pingcap-git-clone-ext.yaml
3433
- pingcap-get-release-version.yaml
34+
- pingcap-get-set-release-version.yaml
35+
- pingcap-git-clone-ext.yaml
3536
- publish-tiup-from-oci-artifact.yaml
3637
- restore-cache-with-ks3.yaml
3738
- save-cache-with-ks3.yaml

apps/prod/tekton/configs/tasks/pingcap-get-release-version.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ spec:
2525
if [[ "$RESULT_VERSION" == *"-alpha-"* ]]; then
2626
echo "First patch version detected. Skipping patch increment."
2727
else
28-
echo "The code is checkouted on branch, I will increase the path version."
28+
echo "The code is checkouted on branch, I will increase the patch version."
2929
# Extract version components
3030
version_part=$(echo "$RESULT_VERSION" | cut -d '-' -f 1)
3131
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
apiVersion: tekton.dev/v1beta1
2+
kind: Task
3+
metadata:
4+
name: pingcap-get-set-release-version
5+
spec:
6+
results:
7+
- description: The release version of the git repo
8+
name: version
9+
type: string
10+
steps:
11+
- image: alpine/git:2.40.1
12+
name: git-describe
13+
workingDir: $(workspaces.source.path)
14+
resources:
15+
requests:
16+
memory: 512Mi
17+
cpu: '100m'
18+
script: |
19+
#!/bin/sh
20+
set -e
21+
22+
RESULT_VERSION="$(git describe --tags --always --dirty --exclude 'v20[0-9][0-9].[0-1][0-9].[0-3][0-9]*')"
23+
if [[ "$RESULT_VERSION" =~ "-[0-9]+-g[0-9a-f]{7,10}(-dirty)?$" ]]; then
24+
# Check if "-alpha-" is included in the version string
25+
if [[ "$RESULT_VERSION" == *"-alpha-"* ]]; then
26+
echo "First patch version detected. Skipping patch increment."
27+
else
28+
echo "The code is checkouted on branch, I will increase the patch version."
29+
# Extract version components
30+
version_part=$(echo "$RESULT_VERSION" | cut -d '-' -f 1)
31+
32+
major=$(echo "$version_part" | cut -d '.' -f 1)
33+
minor=$(echo "$version_part" | cut -d '.' -f 2)
34+
patch=$(echo "$version_part" | cut -d '.' -f 3)
35+
36+
# Increment the patch version
37+
((++patch))
38+
# force add a local tag for build.
39+
git_tag="$major.$minor.$patch"
40+
git tag --contains | git tag -d
41+
git tag -f ${git_tag}
42+
43+
RESULT_VERSION="${git_tag}-pre"
44+
fi
45+
fi
46+
47+
printf "%s" "${RESULT_VERSION}" > $(results.version.path)
48+
49+
workspaces:
50+
- name: source

apps/prod/tekton/configs/tasks/publish-tiup-from-oci-artifact.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ spec:
4242
# publish the tiup packages
4343
:> publish.sh
4444
tiup_last_index=$(yq --output-format=yaml '.["net.pingcap.tibuild.tiup"] | length - 1' artifact-config.json)
45-
os="$(yq --output-format=yaml '.os' artifact-config.json)"
46-
architecture="$(yq --output-format=yaml '.architecture' artifact-config.json)"
45+
os=$(yq --output-format=yaml '.["net.pingcap.tibuild.os"]' artifact-config.json)
46+
architecture=$(yq --output-format=yaml '.["net.pingcap.tibuild.architecture"]' artifact-config.json)
4747
version="$(yq --output-format=yaml '.version' artifact-config.json)"
4848
if [ "$(params.nightly)" == "true" ]; then
4949
# from vX.Y.Z-alpha-574-g75b451c454 => vX.Y.Z-alpha-nightly
@@ -52,13 +52,13 @@ spec:
5252
fi
5353
5454
for i in `seq 0 $tiup_last_index`; do
55-
pkg_file="$(yq --output-format=yaml .["net.pingcap.tibuild.tiup"][$i].file artifact-config.json)"
55+
pkg_file="$(yq --output-format=yaml .[\"net.pingcap.tibuild.tiup\"][$i].file artifact-config.json)"
5656
pkg_name=$(echo "$pkg_file" | sed -E "s/-v[0-9]+.+//")
57-
entrypoint="$(yq --output-format=yaml .["net.pingcap.tibuild.tiup"][$i].entrypoint artifact-config.json)"
58-
desc="$(yq --output-format=yaml .["net.pingcap.tibuild.tiup"][$i].description artifact-config.json)"
57+
entrypoint="$(yq --output-format=yaml .[\"net.pingcap.tibuild.tiup\"][$i].entrypoint artifact-config.json)"
58+
desc="$(yq --output-format=yaml .[\"net.pingcap.tibuild.tiup\"][$i].description artifact-config.json)"
5959
6060
# tiup mirror publish <comp-name> <version> <tarball> <entry> [flags]
61-
if yq -e -oy ".["net.pingcap.tibuild.tiup"][$i].standalone" artifact-config.json; then
61+
if yq -e -oy ".[\"net.pingcap.tibuild.tiup\"][$i].standalone" artifact-config.json; then
6262
printf 'tiup mirror publish %s %s %s %s --os %s --arch %s --standalone --desc "%s"\n' \
6363
$pkg_name $version $pkg_file $entrypoint $os $architecture "$desc" \
6464
>> publish.sh

0 commit comments

Comments
 (0)