-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(apps/prod/tekton/configs/tasks): add tag for release branches w…
…hen building (#1025) Signed-off-by: wuhuizuo <[email protected]> --------- Signed-off-by: wuhuizuo <[email protected]>
- Loading branch information
Showing
6 changed files
with
62 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
apps/prod/tekton/configs/tasks/pingcap-get-set-release-version.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
apiVersion: tekton.dev/v1beta1 | ||
kind: Task | ||
metadata: | ||
name: pingcap-get-set-release-version | ||
spec: | ||
results: | ||
- description: The release version of the git repo | ||
name: version | ||
type: string | ||
steps: | ||
- image: alpine/git:2.40.1 | ||
name: git-describe | ||
workingDir: $(workspaces.source.path) | ||
resources: | ||
requests: | ||
memory: 512Mi | ||
cpu: '100m' | ||
script: | | ||
#!/bin/sh | ||
set -e | ||
RESULT_VERSION="$(git describe --tags --always --dirty --exclude 'v20[0-9][0-9].[0-1][0-9].[0-3][0-9]*')" | ||
if [[ "$RESULT_VERSION" =~ "-[0-9]+-g[0-9a-f]{7,10}(-dirty)?$" ]]; then | ||
# Check if "-alpha-" is included in the version string | ||
if [[ "$RESULT_VERSION" == *"-alpha-"* ]]; then | ||
echo "First patch version detected. Skipping patch increment." | ||
else | ||
echo "The code is checkouted on branch, I will increase the patch version." | ||
# Extract version components | ||
version_part=$(echo "$RESULT_VERSION" | cut -d '-' -f 1) | ||
major=$(echo "$version_part" | cut -d '.' -f 1) | ||
minor=$(echo "$version_part" | cut -d '.' -f 2) | ||
patch=$(echo "$version_part" | cut -d '.' -f 3) | ||
# Increment the patch version | ||
((++patch)) | ||
# force add a local tag for build. | ||
git_tag="$major.$minor.$patch" | ||
git tag --contains | git tag -d | ||
git tag -f ${git_tag} | ||
RESULT_VERSION="${git_tag}-pre" | ||
fi | ||
fi | ||
printf "%s" "${RESULT_VERSION}" > $(results.version.path) | ||
workspaces: | ||
- name: source |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters