Skip to content

Commit

Permalink
chore(apps/prod/tekton/configs/tasks): add tag for release branches w…
Browse files Browse the repository at this point in the history
…hen building

Signed-off-by: wuhuizuo <wuhuizuo@126.com>
  • Loading branch information
wuhuizuo committed Mar 12, 2024
1 parent d3287e0 commit 31c3f83
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ spec:
runAfter:
- checkout
taskRef:
name: pingcap-get-release-version
name: pingcap-get-set-release-version
workspaces:
- name: source
workspace: source
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ spec:
runAfter:
- checkout
taskRef:
name: pingcap-get-release-version
name: pingcap-get-set-release-version
workspaces:
- name: source
workspace: source
Expand Down
3 changes: 2 additions & 1 deletion apps/prod/tekton/configs/tasks/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ resources:
- pingcap-compose-offline-pkgs.yaml
- pingcap-deliver-image.yaml
- pingcap-get-builder-image.yaml
- pingcap-git-clone-ext.yaml
- pingcap-get-release-version.yaml
- pingcap-get-set-release-version.yaml
- pingcap-git-clone-ext.yaml
- publish-tiup-from-oci-artifact.yaml
- restore-cache-with-ks3.yaml
- save-cache-with-ks3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spec:
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 path version."
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)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
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
RESULT_VERSION="$major.$minor.$((++patch))-pre"
# force add a local tag with the value of `RESULT_VERSION`
git tag --contains | git tag -d
git tag -f ${RESULT_VERSION}
fi
fi
printf "%s" "${RESULT_VERSION}" > $(results.version.path)
workspaces:
- name: source

0 comments on commit 31c3f83

Please sign in to comment.