-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
version is based on git state or BUILD_VERSION
Git version to be calculated by 'git describe --tags --always' and add '-unsupported' when the local workspace has an uncommitted change. the rules are: * BUILD_VERSION will override any calculated version if set as env/make cli variable * if current commit is tagged, use just the tag * else <tag>-<num commits since>-g<commit id> release target will use CURRENT_VERSION to make it simple to set in the release branch Signed-off-by: Chris Plock <chrisplo@cisco.com>
- Loading branch information
Showing
4 changed files
with
52 additions
and
50 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 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,32 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
BUILD_VERSION=${BUILD_VERSION:-} | ||
NIGHTLY_RELEASE=${NIGHTLY_RELEASE:-} | ||
|
||
# calculate version | ||
if command -v git &>/dev/null && git rev-parse &>/dev/null; then | ||
GIT_COMMIT=$(git describe --tags --always 2>/dev/null || echo unknown) | ||
if [ -n "$(git status --porcelain --untracked-files=no)" ]; then | ||
GIT_COMMIT="$GIT_COMMIT-unsupported" | ||
fi | ||
VERSION=$GIT_COMMIT | ||
else | ||
echo >&2 'error: unable to determine the git revision' | ||
exit 1 | ||
fi | ||
|
||
# BUILD_VERSION overrides the git calculated version | ||
if [ -n "$BUILD_VERSION" ]; then | ||
VERSION=$BUILD_VERSION | ||
fi | ||
|
||
if [ -z "$NIGHTLY_RELEASE" ]; then | ||
VERSION="$VERSION" | ||
else | ||
BUILD_TIME=$(date -u +%m-%d-%Y.%H-%M-%S.UTC) | ||
VERSION="$VERSION-$BUILD_TIME" | ||
fi | ||
|
||
echo $VERSION |