diff --git a/.github/workflows/release-kustomize.yml b/.github/workflows/release-kustomize.yml index 520b3850ae9..c434304ea47 100644 --- a/.github/workflows/release-kustomize.yml +++ b/.github/workflows/release-kustomize.yml @@ -88,6 +88,10 @@ jobs: - name: Build test run: | make build-kustomize-api + - name: End-to-end test + run: | + export latestVersion=$(./releasing/determine-next-version.sh kustomize ${{ inputs.release_type }}) + sed -i "" "s/LATEST_RELEASE=.*/LATEST_RELEASE=$latestVersion/" Makefile - name: Commit pinned dependencies run: | diff --git a/releasing/determine-next-version.sh b/releasing/determine-next-version.sh new file mode 100755 index 00000000000..e06ac22b9f9 --- /dev/null +++ b/releasing/determine-next-version.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +set -eo pipefail +set -o nounset + +declare -a RELEASE_TYPES=("major" "minor" "patch") + +if [[ -z "${2-}" ]]; then + echo "Release type not specified, using default value: patch" + release_type="patch" +elif [[ ! "${RELEASE_TYPES[*]}" =~ "${2}" ]]; then + echo "Unsupported release type, only input these values: major, minor, patch." + exit 1 +fi + +function determineNextVersion { + module=$1 + currentTag=$(git tag --list "${module}*" --sort=-creatordate | head -n1) + currentVersion=$(echo ${currentTag##*/} | cut -d'v' -f2) + majorVer=$(echo $currentVersion | cut -d'.' -f1) + minorVer=$(echo $currentVersion | cut -d'.' -f2) + patchVer=$(echo $currentVersion | cut -d'.' -f3) + + if [[ ${release_type} == "major" ]]; then + majorVer="$(($majorVer + 1))" + elif [[ ${release_type} == "minor" ]]; then + minorVer="$(($minorVer + 1))" + elif [[ ${release_type} == "patch" ]]; then + patchVer="$(($patchVer + 1))" + else + echo "Error: release_type not supported. Available values 'major', 'minor', 'patch'" + exit 1 + fi + + echo "$majorVer.$minorVer.$patchVer" +} + +main() { + module=$1 + release_type=$2 + nextVersion=$(determineNextVersion $module) + echo "v$nextVersion" + exit 0 +} + +main "$@"