fix(release): poll branch readiness before .version write
The .version PUT fired immediately after CHANGELOG.md created the next-release branch, racing Gitea's branch indexing. With curl -sf (fail-silent) any 404/409 produced exit 22 with no body, leaving the log without diagnostic output. - Move the branch-readiness poll to run right after CHANGELOG.md commit, before .version is written. - Replace silent .version write with a 5-attempt retry loop that logs HTTP code and body on failure, matching the PR creation block.
This commit is contained in:
@@ -158,37 +158,7 @@ jobs:
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check if .version exists on base branch
|
||||
VERSION_SHA=$(curl -sf --retry 3 --retry-delay 2 --retry-connrefused \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
"${API_URL}/contents/.version?ref=${BASE_BRANCH}" | jq -r '.sha // empty')
|
||||
|
||||
if [ -n "${VERSION_SHA}" ]; then
|
||||
echo "Updating .version on next-release branch..."
|
||||
curl -sf --retry 3 --retry-delay 2 --retry-connrefused -X PUT \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
--data "$(jq -n \
|
||||
--arg content "${VERSION_CONTENT}" \
|
||||
--arg sha "${VERSION_SHA}" \
|
||||
--arg message "${TITLE}" \
|
||||
--arg branch "next-release" \
|
||||
'{content: $content, sha: $sha, message: $message, branch: $branch}')" \
|
||||
"${API_URL}/contents/.version"
|
||||
else
|
||||
echo "Creating .version on next-release branch..."
|
||||
curl -sf --retry 3 --retry-delay 2 --retry-connrefused -X POST \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
--data "$(jq -n \
|
||||
--arg content "${VERSION_CONTENT}" \
|
||||
--arg message "${TITLE}" \
|
||||
--arg branch "next-release" \
|
||||
'{content: $content, message: $message, branch: $branch}')" \
|
||||
"${API_URL}/contents/.version"
|
||||
fi
|
||||
|
||||
echo "Creating new PR..."
|
||||
# Wait for next-release branch to be indexed by Gitea before subsequent writes
|
||||
echo "Waiting for next-release branch to be ready..."
|
||||
for i in $(seq 1 10); do
|
||||
BRANCH_STATUS=$(curl -s --retry 3 --retry-delay 2 --retry-connrefused \
|
||||
@@ -207,6 +177,53 @@ jobs:
|
||||
sleep 3
|
||||
done
|
||||
|
||||
# Check if .version exists on base branch
|
||||
VERSION_SHA=$(curl -sf --retry 3 --retry-delay 2 --retry-connrefused \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
"${API_URL}/contents/.version?ref=${BASE_BRANCH}" | jq -r '.sha // empty')
|
||||
|
||||
if [ -n "${VERSION_SHA}" ]; then
|
||||
echo "Updating .version on next-release branch..."
|
||||
VERSION_PAYLOAD=$(jq -n \
|
||||
--arg content "${VERSION_CONTENT}" \
|
||||
--arg sha "${VERSION_SHA}" \
|
||||
--arg message "${TITLE}" \
|
||||
--arg branch "next-release" \
|
||||
'{content: $content, sha: $sha, message: $message, branch: $branch}')
|
||||
VERSION_METHOD=PUT
|
||||
else
|
||||
echo "Creating .version on next-release branch..."
|
||||
VERSION_PAYLOAD=$(jq -n \
|
||||
--arg content "${VERSION_CONTENT}" \
|
||||
--arg message "${TITLE}" \
|
||||
--arg branch "next-release" \
|
||||
'{content: $content, message: $message, branch: $branch}')
|
||||
VERSION_METHOD=POST
|
||||
fi
|
||||
|
||||
for i in $(seq 1 5); do
|
||||
RESPONSE=$(curl -s --retry 3 --retry-delay 2 --retry-connrefused \
|
||||
-w "\n%{http_code}" -X "${VERSION_METHOD}" \
|
||||
-H "Authorization: token ${TOKEN}" \
|
||||
-H "Content-Type: application/json" \
|
||||
--data "${VERSION_PAYLOAD}" \
|
||||
"${API_URL}/contents/.version")
|
||||
HTTP_CODE=$(echo "${RESPONSE}" | tail -1)
|
||||
BODY=$(echo "${RESPONSE}" | sed '$d')
|
||||
if [ "${HTTP_CODE}" -lt 400 ]; then
|
||||
echo ".version write succeeded"
|
||||
break
|
||||
fi
|
||||
if [ "${i}" = "5" ]; then
|
||||
echo "Error writing .version after 5 attempts (HTTP ${HTTP_CODE}): ${BODY}"
|
||||
exit 1
|
||||
fi
|
||||
echo ".version write attempt ${i}/5 failed (HTTP ${HTTP_CODE}): ${BODY} — retrying..."
|
||||
sleep 3
|
||||
done
|
||||
|
||||
echo "Creating new PR..."
|
||||
|
||||
PR_DATA=$(jq -n \
|
||||
--arg title "${TITLE}" \
|
||||
--arg body "${DESCRIPTION}" \
|
||||
|
||||
Reference in New Issue
Block a user