-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: andy.lee <[email protected]>
- Loading branch information
Showing
1 changed file
with
57 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/bin/bash | ||
shopt -s extglob | ||
|
||
if [ -n "$(git status --porcelain --untracked-files=no)" ]; then | ||
DIRTY="-dirty" | ||
fi | ||
|
||
COMMIT=$(git rev-parse --short HEAD) | ||
COMMIT_DATE=$(git --no-pager log -1 --format='%ct') | ||
COMMIT_BRANCH=$(git rev-parse --abbrev-ref HEAD | sed -E 's/[^a-zA-Z0-9.-]+/-/g') | ||
GIT_TAG=${CI_BUILD_TAG:-$(git tag -l --contains HEAD | head -n 1)} | ||
LAST_TAG=${GIT_TAG:-'v0.0.0'} | ||
|
||
if [[ -z "$DIRTY" && -n "$GIT_TAG" ]]; then | ||
# human readable version used on rancher dashboard about page | ||
export DASHBOARD_VERSION=$GIT_TAG | ||
# computer readable version | ||
VERSION=$GIT_TAG | ||
else | ||
# human readable version used on rancher dashboard about page | ||
export DASHBOARD_VERSION="${COMMIT_BRANCH} ${COMMIT}" | ||
# computer readable version | ||
VERSION="${COMMIT}${DIRTY}" | ||
fi | ||
|
||
# Chart tag. | ||
if [[ -z "${DIRTY}" && -n "${GIT_TAG}" ]]; then | ||
CHART_VERSION="${GIT_TAG}" | ||
elif [[ "$DIRTY" ]]; then | ||
CHART_VERSION="${LAST_TAG}${DIRTY}.${COMMIT}" | ||
else | ||
CHART_VERSION="${LAST_TAG}-${COMMIT_DATE}.${COMMIT}.${COMMIT_BRANCH}" | ||
fi | ||
|
||
# Drop the v prefix for Chart Version to follow existing pattern. | ||
CHART_VERSION="$(echo ${CHART_VERSION} | sed -E 's/^v//' | sed -e 's/^\(.\{55\}\).*/\1/')" | ||
|
||
# Chart Repo - Target Repo for releases. | ||
case $CHART_VERSION in | ||
*-alpha*) # All alpha tags | ||
CHART_REPO="alpha" ;; | ||
*-rc*) # All rc tags | ||
CHART_REPO="latest" ;; | ||
+([0-9]).+([0-9]).+([0-9])) # All release tags | ||
CHART_REPO="latest" ;; | ||
*) # Anything else - Future use | ||
CHART_REPO="dev" ;; | ||
esac | ||
|
||
if [ -z "$ARCH" ]; then | ||
ARCH=amd64 | ||
fi | ||
|
||
echo "ARCH: $ARCH" | ||
echo "CHART_REPO: $CHART_REPO" | ||
echo "CHART_VERSION: $CHART_VERSION" | ||
echo "VERSION: $VERSION" |