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 (#1025)

Signed-off-by: wuhuizuo <wuhuizuo@126.com>

---------

Signed-off-by: wuhuizuo <wuhuizuo@126.com>
  • Loading branch information
wuhuizuo committed Mar 12, 2024
1 parent 3af78de commit 13d52b4
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 11 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,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
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,23 @@ spec:
# publish the tiup packages
:> publish.sh
tiup_last_index=$(yq --output-format=yaml '.["net.pingcap.tibuild.tiup"] | length - 1' artifact-config.json)
os="$(yq --output-format=yaml '.os' artifact-config.json)"
architecture="$(yq --output-format=yaml '.architecture' artifact-config.json)"
version="$(yq --output-format=yaml '.version' artifact-config.json)"
os=$(yq --output-format=yaml '.["net.pingcap.tibuild.os"]' artifact-config.json)
architecture=$(yq --output-format=yaml '.["net.pingcap.tibuild.architecture"]' artifact-config.json)
version=$(yq --output-format=yaml '.["org.opencontainers.image.version"]' artifact-config.json)
if [ "$(params.nightly)" == "true" ]; then
# from vX.Y.Z-alpha-574-g75b451c454 => vX.Y.Z-alpha-nightly
version=`echo "$version" | sed -E 's/\-[0-9]+-g[0-9a-f]+$//'`
version="${version}-nightly"
fi
for i in `seq 0 $tiup_last_index`; do
pkg_file="$(yq --output-format=yaml .["net.pingcap.tibuild.tiup"][$i].file artifact-config.json)"
pkg_file="$(yq --output-format=yaml .[\"net.pingcap.tibuild.tiup\"][$i].file artifact-config.json)"
pkg_name=$(echo "$pkg_file" | sed -E "s/-v[0-9]+.+//")
entrypoint="$(yq --output-format=yaml .["net.pingcap.tibuild.tiup"][$i].entrypoint artifact-config.json)"
desc="$(yq --output-format=yaml .["net.pingcap.tibuild.tiup"][$i].description artifact-config.json)"
entrypoint="$(yq --output-format=yaml .[\"net.pingcap.tibuild.tiup\"][$i].entrypoint artifact-config.json)"
desc="$(yq --output-format=yaml .[\"net.pingcap.tibuild.tiup\"][$i].description artifact-config.json)"
# tiup mirror publish <comp-name> <version> <tarball> <entry> [flags]
if yq -e -oy ".["net.pingcap.tibuild.tiup"][$i].standalone" artifact-config.json; then
if yq -e -oy ".[\"net.pingcap.tibuild.tiup\"][$i].standalone" artifact-config.json; then
printf 'tiup mirror publish %s %s %s %s --os %s --arch %s --standalone --desc "%s"\n' \
$pkg_name $version $pkg_file $entrypoint $os $architecture "$desc" \
>> publish.sh
Expand Down

0 comments on commit 13d52b4

Please sign in to comment.