From 5c22db022f076095466e715ddf73f4f471dfd095 Mon Sep 17 00:00:00 2001 From: Michael Keller Date: Wed, 1 Jan 2025 17:48:07 +1300 Subject: [PATCH] CICD: Fix the Version Number Generation Fix the script used to generate version numbers for CICD builds. If there is a race condition and we are not the first to create the branch named after the lates changeset id, go and do a `git pull` before attempting to read the branch that was created by another process. Signed-off-by: Michael Keller --- scripts/get-or-create-build-nr.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/scripts/get-or-create-build-nr.sh b/scripts/get-or-create-build-nr.sh index c0a7d8450..986fa85cd 100755 --- a/scripts/get-or-create-build-nr.sh +++ b/scripts/get-or-create-build-nr.sh @@ -18,7 +18,7 @@ cd nightly-builds latest=$( latest-subsurface-buildnumber git commit -a -m "record build number for this SHA" @@ -36,7 +38,7 @@ else if git push origin "$SHA_BRANCH" then # yay - we win! now let's make sure that we remember this number for next time - git checkout main + git switch main echo $latest > latest-subsurface-buildnumber git commit -a -m "record latest build number in main branch" if ! git push origin main @@ -46,9 +48,10 @@ else fi else # someone else was faster - get the number they wrote - git checkout main &> /dev/null - git branch -D "$SHA_BRANCH" &> /dev/null - if ! git checkout "$SHA_BRANCH" + git switch main + git branch -D "$SHA_BRANCH" + git pull + if ! git switch "$SHA_BRANCH" then echo "push to $SHA_BRANCH failed, but switching to it failed as well" exit 2