-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(helm): update helm chart version fix
When pushing tags (annotated?), github's event.base_ref may not be set. When this happens, we can figure out the released branch ourselves, by inspecting all branches containing the tag, and ensuring it's the tip and it's the current HEAD. Signed-off-by: Tiago Castro <tiagolobocastro@gmail.com>
- Loading branch information
1 parent
3fe353c
commit 3c132b1
Showing
9 changed files
with
135 additions
and
299 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env bash | ||
|
||
SCRIPTDIR="$(dirname "$(realpath "${BASH_SOURCE[0]:-"$0"}")")" | ||
ROOTDIR="$SCRIPTDIR/../.." | ||
|
||
source "$ROOTDIR/scripts/utils/log.sh" | ||
|
||
set -euo pipefail | ||
|
||
# Check if the given branch matches the tag | ||
# Example: | ||
# release/2.7 matches tag v2.7.2, v2.7.2-rc.4, etc.. | ||
# release/2.7 does not match tag v2.6.0, etc... | ||
tag_matches_branch() { | ||
local tag="${1#v}" | ||
local release_branch="$2" | ||
|
||
branch_version="${release_branch#release/}" | ||
if ! [[ "$branch_version" =~ ^[0-9]+.[0-9]+$ ]]; then | ||
return 1 | ||
fi | ||
|
||
if ! [[ "$tag" = "$branch_version"* ]]; then | ||
return 1 | ||
fi | ||
} | ||
|
||
# For the given tag, find the branch which is compatible | ||
# See tag_matches_branch for more information. | ||
find_released_branch() { | ||
local tag="$1" | ||
local branches | ||
branches=$(git branch -r --contains "$TAG" --points-at "$TAG" --format "%(refname:short)" 2>/dev/null) | ||
local branch="" | ||
|
||
for release_branch in $branches; do | ||
release_branch=${release_branch#origin/} | ||
if tag_matches_branch "$TAG" "$release_branch"; then | ||
if [ -n "$branch" ]; then | ||
log_fatal "Multiple branches matched!" | ||
fi | ||
branch="$release_branch" | ||
fi | ||
done | ||
|
||
echo "$branch" | ||
} | ||
|
||
TAG="$1" | ||
BRANCH="$(find_released_branch "$TAG")" | ||
|
||
if [ -z "$BRANCH" ]; then | ||
log_fatal "Failed to find matching released branch for tag '$TAG'" | ||
fi | ||
|
||
echo "$BRANCH" |
Oops, something went wrong.