-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge "Get version for tag based on number of git commits"
- Loading branch information
Showing
1 changed file
with
7 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,13 @@ | ||
#!/bin/bash | ||
|
||
# Returns version for helm chart | ||
# Returns version for os controller image | ||
# <tag>: if current commit is tagged | ||
# <latest-tag+1>-<sha> - if current commit in other branches | ||
# <latest-tag+1>-<devVersion> - if current commit in other branches | ||
|
||
REPO_DIR=$(cd $(dirname "$0")/../ && pwd) | ||
GIT_SHA=$(git -C $REPO_DIR rev-parse --short HEAD) | ||
|
||
if git -C $REPO_DIR describe --exact-match --tags ${GIT_SHA} > /dev/null 2>&1; then | ||
GIT_TAG=$(git -C $REPO_DIR describe --exact-match --tags ${GIT_SHA}) | ||
IMG_TAG="${GIT_TAG}" | ||
else | ||
GIT_LATEST_TAG=$(git -C $REPO_DIR describe --tags --abbrev=0) | ||
tag_part1=$(echo ${GIT_LATEST_TAG} | awk -F '.' '{print $1}') | ||
tag_part2=$(echo ${GIT_LATEST_TAG} | awk -F '.' '{print $2}') | ||
tag_part3=$(echo ${GIT_LATEST_TAG} | awk -F '.' '{print $3}') | ||
next_tag="${tag_part1}.${tag_part2}.$(( tag_part3 + 1 ))" | ||
IMG_TAG="${next_tag}-${GIT_SHA}" | ||
fi | ||
# Fetch version with setup.py to align with PBR's version calculation. | ||
# Using rev-list may lead to confusion as it doesn't match PBR logic. | ||
pushd $REPO_DIR > /dev/null | ||
IMG_TAG=$(python3 setup.py --version 2>/dev/null | grep -v "Generating ChangeLog" | sed 's/.dev/-dev/g') | ||
popd > /dev/null | ||
echo $IMG_TAG |