From e527ea14f82c0d632ca3b5fca75dd34d3fb6c8c5 Mon Sep 17 00:00:00 2001 From: Robb Kidd Date: Thu, 7 Nov 2024 15:58:25 -0500 Subject: [PATCH 1/3] set a better version for dev builds --- build-docker.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/build-docker.sh b/build-docker.sh index fe181ec24b..7727f1cffa 100755 --- a/build-docker.sh +++ b/build-docker.sh @@ -15,12 +15,12 @@ if [[ "${CIRCLE_BRANCH}" == "main" ]]; then TAGS+=",latest" fi -# Local builds just get "dev" for version -VERSION="dev" +# Determine a version number based on most recent version tag in git. +VERSION=$(git describe --tags --match='v[0-9]*' --always) -# If we are doing a dev build on circle, we will version it as the circleci buildnumber -if [[ -n "${CIRCLE_BUILD_NUM}" ]]; then - VERSION="${CIRCLE_BUILD_NUM}" +# If we are doing a dev build on circle, append the build number (job id) to the version +if [[ -n "${CIRCLE_BUILD_NUM:-}" ]]; then + VERSION="${VERSION}-ci${CIRCLE_BUILD_NUM}" fi # if we're running off a git tag, it is a release which we tag with the versions as well as latest From 570abf1c293d3208b2e4066b1a9fe8fdb34fda98 Mon Sep 17 00:00:00 2001 From: Robb Kidd Date: Thu, 7 Nov 2024 17:11:10 -0500 Subject: [PATCH 2/3] include a dev version decoder ring --- build-docker.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/build-docker.sh b/build-docker.sh index 7727f1cffa..289bb3d520 100755 --- a/build-docker.sh +++ b/build-docker.sh @@ -16,9 +16,20 @@ if [[ "${CIRCLE_BRANCH}" == "main" ]]; then fi # Determine a version number based on most recent version tag in git. +# git describe - Return the most recent annotated tag that is reachable from a commit. +# --tags - OK, any tag, not just the annotated ones. We don't always remember to annotate a version tag. +# --match='v[0-9]*' - But of all those tags, only the version ones (starts with a v and a digit). +# --always - … and if a tag can't be found, fallback to the commit ID. +# Ex: v2.1.1-45-ga1b2c3d +# - The build was on git commit ID a1b2c3d. +# - 2.1.1 is the most recent version tag in the history behind that commit +# - That commit is 45 commits ahead of that version tag. VERSION=$(git describe --tags --match='v[0-9]*' --always) # If we are doing a dev build on circle, append the build number (job id) to the version +# Ex: v2.1.1-45-ga1b2c3d-ci8675309 +# - The git information gleaned above plus ... +# - The build happened within CircleCI job 8675309. if [[ -n "${CIRCLE_BUILD_NUM:-}" ]]; then VERSION="${VERSION}-ci${CIRCLE_BUILD_NUM}" fi From 944276327efbf1cd3f1761cfc1c82c3f747f6210 Mon Sep 17 00:00:00 2001 From: Robb Kidd Date: Thu, 7 Nov 2024 17:21:18 -0500 Subject: [PATCH 3/3] Be super pedantic about the tag name in the example, Robb. --- build-docker.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-docker.sh b/build-docker.sh index 289bb3d520..bb1710ccb3 100755 --- a/build-docker.sh +++ b/build-docker.sh @@ -22,7 +22,7 @@ fi # --always - … and if a tag can't be found, fallback to the commit ID. # Ex: v2.1.1-45-ga1b2c3d # - The build was on git commit ID a1b2c3d. -# - 2.1.1 is the most recent version tag in the history behind that commit +# - v2.1.1 is the most recent version tag in the history behind that commit # - That commit is 45 commits ahead of that version tag. VERSION=$(git describe --tags --match='v[0-9]*' --always)