fix race in ci/release.sh
This commit is contained in:
1 parent
4248fb171b
commit
de2c5f5a43
1 file changed
+25
-2
+25
-2
@@ -29,6 +29,11 @@ readonly REPO_ROOT
|
||||
|
||||
readonly MOD_ID="lua_mod_automator"
|
||||
readonly RELEASE_BRANCH="master"
|
||||
|
||||
# Seconds publish waits for HEAD to arrive on the release branch. A push can deliver the tag
|
||||
# before the branch (git-flow pushes both), so the checkout may hold the branch from before.
|
||||
readonly RELEASE_BRANCH_WAIT=60
|
||||
readonly RELEASE_BRANCH_POLL=10
|
||||
readonly WORK_DIR="${REPO_ROOT}/build/ci"
|
||||
|
||||
# DepotDownloader downloads single files of a depot; steamcmd only whole apps. Same release
|
||||
@@ -49,9 +54,27 @@ fail() {
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Whether HEAD is on the release branch, as fetched from origin.
|
||||
# Whether HEAD is on the release branch. Fetches the branch again rather than trusting the
|
||||
# checkout, and waits up to RELEASE_BRANCH_WAIT seconds for it to arrive.
|
||||
on_release_branch() {
|
||||
git -C "${REPO_ROOT}" merge-base --is-ancestor HEAD "origin/${RELEASE_BRANCH}" 2> /dev/null
|
||||
local waited=0
|
||||
|
||||
while true; do
|
||||
git -C "${REPO_ROOT}" fetch --quiet origin "+refs/heads/${RELEASE_BRANCH}:refs/remotes/origin/${RELEASE_BRANCH}" \
|
||||
|| log "Cannot fetch ${RELEASE_BRANCH}; checking against the one fetched before"
|
||||
|
||||
if git -C "${REPO_ROOT}" merge-base --is-ancestor HEAD "origin/${RELEASE_BRANCH}" 2> /dev/null; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
if (( waited >= RELEASE_BRANCH_WAIT )); then
|
||||
return 1
|
||||
fi
|
||||
|
||||
log "HEAD is not on ${RELEASE_BRANCH} (yet); fetching it again in ${RELEASE_BRANCH_POLL} seconds"
|
||||
sleep "${RELEASE_BRANCH_POLL}"
|
||||
waited=$(( waited + RELEASE_BRANCH_POLL ))
|
||||
done
|
||||
}
|
||||
|
||||
# Prints the v* tag on HEAD, or nothing.
|
||||
|
||||
Reference in new issue
Block a user