diff --git a/apps/prod/tekton/configs/pipelines/pingcap-build-package-darwin.yaml b/apps/prod/tekton/configs/pipelines/pingcap-build-package-darwin.yaml index d9e50540e..6a9315ca5 100644 --- a/apps/prod/tekton/configs/pipelines/pingcap-build-package-darwin.yaml +++ b/apps/prod/tekton/configs/pipelines/pingcap-build-package-darwin.yaml @@ -87,7 +87,7 @@ spec: runAfter: - checkout taskRef: - name: pingcap-get-release-version + name: pingcap-get-set-release-version workspaces: - name: source workspace: source diff --git a/apps/prod/tekton/configs/pipelines/pingcap-build-package.yaml b/apps/prod/tekton/configs/pipelines/pingcap-build-package.yaml index 6ef4f04b6..a52e8a92c 100644 --- a/apps/prod/tekton/configs/pipelines/pingcap-build-package.yaml +++ b/apps/prod/tekton/configs/pipelines/pingcap-build-package.yaml @@ -93,7 +93,7 @@ spec: runAfter: - checkout taskRef: - name: pingcap-get-release-version + name: pingcap-get-set-release-version workspaces: - name: source workspace: source diff --git a/apps/prod/tekton/configs/tasks/kustomization.yaml b/apps/prod/tekton/configs/tasks/kustomization.yaml index f59001543..419e33f42 100644 --- a/apps/prod/tekton/configs/tasks/kustomization.yaml +++ b/apps/prod/tekton/configs/tasks/kustomization.yaml @@ -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 diff --git a/apps/prod/tekton/configs/tasks/pingcap-get-release-version.yaml b/apps/prod/tekton/configs/tasks/pingcap-get-release-version.yaml index 054686037..f981aca26 100644 --- a/apps/prod/tekton/configs/tasks/pingcap-get-release-version.yaml +++ b/apps/prod/tekton/configs/tasks/pingcap-get-release-version.yaml @@ -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) diff --git a/apps/prod/tekton/configs/tasks/pingcap-get-set-release-version.yaml b/apps/prod/tekton/configs/tasks/pingcap-get-set-release-version.yaml new file mode 100644 index 000000000..8ccd7cd79 --- /dev/null +++ b/apps/prod/tekton/configs/tasks/pingcap-get-set-release-version.yaml @@ -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