Skip to content
This repository has been archived by the owner on Jun 19, 2022. It is now read-only.

Commit

Permalink
Use git tag without major version in master to get latest tag
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimmy Lin committed Jan 13, 2021
1 parent f34d67b commit 6da2285
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,21 @@ function cloud_run_events_setup() {
wait_until_pods_running events-system || return 1
}

function latest_version() {
echo "The current branch is $(current_branch)"
if [ $(current_branch) = "master" ]; then
echo "Current branch is master, using latest git tag"
# For master, simply use git tag without major version, this will work even if the release tag is not in the master
git tag | sort -r --version-sort | head -n1
else
local semver=$(git describe --match "v[0-9]*" --abbrev=0)
local major_minor=$(echo "$semver" | cut -d. -f1-2)

# Get the latest patch release for the major minor
git tag -l "${major_minor}*" | sort -r --version-sort | head -n1
fi
}

# Latest release. If user does not supply this as a flag, the latest
# tagged release on the current branch will be used.
readonly LATEST_RELEASE_VERSION=$(latest_version)
Expand Down

0 comments on commit 6da2285

Please sign in to comment.