diff options
-rwxr-xr-x | compile.sh | 2 | ||||
-rwxr-xr-x | scripts/bootstrap/buildenv.sh | 21 |
2 files changed, 22 insertions, 1 deletions
diff --git a/compile.sh b/compile.sh index 24a179f05a..56299b8f1b 100755 --- a/compile.sh +++ b/compile.sh @@ -83,7 +83,7 @@ fi if [ "${EMBED_LABEL-x}" = "x" ]; then # Add a default label when unspecified git_sha1=$(git_sha1) - EMBED_LABEL="head (@${git_sha1:-non-git})" + EMBED_LABEL="$(get_last_version) (@${git_sha1:-non-git})" fi if [[ $PLATFORM == "darwin" ]] && \ diff --git a/scripts/bootstrap/buildenv.sh b/scripts/bootstrap/buildenv.sh index 98eacf7a26..3b7956c271 100755 --- a/scripts/bootstrap/buildenv.sh +++ b/scripts/bootstrap/buildenv.sh @@ -182,6 +182,27 @@ function git_sha1() { fi } +function git_date() { + if [ -x "$(which git || true)" ] && [ -d .git ]; then + git log -1 --pretty=%ai | cut -d " " -f 1 || true + fi +} + +# Get the latest release version and append the date of +# the last commit if any. +function get_last_version() { + local version="$(fgrep -m 1 '## Release' CHANGELOG.md \ + | sed -E 's|.*Release (.*) \(.*\)|\1|')" + local date="$(git_date)" + if [ -z "${version-}" ]; then + version="unknown" + fi + if [ -n "${date-}" ]; then + date="$(date +%Y-%m-%d)" + fi + echo "${version}-${date}" +} + if [[ ${PLATFORM} == "darwin" ]]; then function md5_file() { echo $(cat $1 | md5) $1 |