From a901f78be76274dba3ab67c5cbeb5a4ab6a4bfe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Thu, 14 Jan 2021 15:16:08 +0100 Subject: [PATCH] ci/build.sh: Use commit date rather than build date in version strings of CI builds --- scripts/ci/build.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/ci/build.sh b/scripts/ci/build.sh index b1f2f2cf3..033eb38b0 100755 --- a/scripts/ci/build.sh +++ b/scripts/ci/build.sh @@ -5,10 +5,20 @@ ROOTDIR="$(dirname "$0")/../.." cd "${ROOTDIR}" # shellcheck disable=SC2166 -if [ "$CIRCLE_BRANCH" = release -o -n "$CIRCLE_TAG" -o -n "$FORCE_RELEASE" ]; then echo -n >prerelease.txt; fi +if [ "$CIRCLE_BRANCH" = release -o -n "$CIRCLE_TAG" -o -n "$FORCE_RELEASE" ] +then + echo -n "" >prerelease.txt +else + # Use last commit date rather than build date to avoid ending up with builds for + # different platforms having different version strings (and therefore producing different bytecode) + # if the CI is triggered just before midnight. + last_commit_timestamp=$(git log -1 --date=iso --format=%ad HEAD) + date -d "$last_commit_timestamp" -u "+ci.%Y.%-m.%-d" >prerelease.txt +fi + if [ -n "$CIRCLE_SHA1" ] then - echo -n "$CIRCLE_SHA1" >commit_hash.txt + echo -n "$CIRCLE_SHA1" >commit_hash.txt fi mkdir -p build