Skip to content

Commit

Permalink
add end-to-end testing step
Browse files Browse the repository at this point in the history
  • Loading branch information
antoooks committed May 25, 2024
1 parent be7262a commit f7af37b
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/release-kustomize.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
46 changes: 46 additions & 0 deletions releasing/determine-next-version.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"

0 comments on commit f7af37b

Please sign in to comment.