@@ -20,8 +20,8 @@ if ! gh auth status &>/dev/null; then
2020 exit 1
2121fi
2222
23- if ! git diff --quiet || ! git diff --cached --quiet ; then
24- echo " Error: working directory has uncommitted changes . Commit or stash them first."
23+ if [[ -n " $( git status --porcelain ) " ]] ; then
24+ echo " Error: working directory is not clean . Commit, stash, or remove changes first."
2525 exit 1
2626fi
2727
@@ -67,7 +67,7 @@ if [[ "${need_deploy:-N}" =~ ^[Yy] ]]; then
6767 echo " Enter component versions (press enter to keep current):"
6868
6969 # Fetch current defaults from the deploy workflow
70- DEPLOY_WORKFLOW=$( gh api repos/${DEPLOY_REPO} /contents/.github/workflows/build_binaries.yml --jq ' .content' | base64 -d )
70+ DEPLOY_WORKFLOW=$( gh api repos/${DEPLOY_REPO} /contents/.github/workflows/build_binaries.yml --jq ' .content' | base64 --decode )
7171 current_deploy_default () {
7272 echo " $DEPLOY_WORKFLOW " | sed -n " /${1} :/,/default:/{s/.*default: \" \(.*\)\" /\1/p;}" | head -1
7373 }
@@ -90,11 +90,22 @@ if [[ "${need_deploy:-N}" =~ ^[Yy] ]]; then
9090
9191 read -rp " New deploy release tag [${SUGGESTED_DEPLOY} ]: " NEW_DEPLOY_VERSION
9292 NEW_DEPLOY_VERSION=" ${NEW_DEPLOY_VERSION:- $SUGGESTED_DEPLOY } "
93+
94+ if [[ ! " $NEW_DEPLOY_VERSION " =~ ^v[0-9]+\. [0-9]+\. [0-9]+$ ]]; then
95+ echo " Error: deploy tag must match vX.Y.Z"
96+ exit 1
97+ fi
98+
99+ if gh api " repos/${DEPLOY_REPO} /git/ref/tags/${NEW_DEPLOY_VERSION} " & > /dev/null; then
100+ echo " Error: deploy tag ${NEW_DEPLOY_VERSION} already exists in ${DEPLOY_REPO} ."
101+ exit 1
102+ fi
93103fi
94104
95105# 2. PySCIPOpt version bump
96106
97107CURRENT_VERSION=$( sed -n " s/^__version__.*'\(.*\)'/\1/p" " $VERSION_FILE " )
108+ validate_version " $CURRENT_VERSION "
98109MAJOR=$( echo " $CURRENT_VERSION " | cut -d. -f1)
99110MINOR=$( echo " $CURRENT_VERSION " | cut -d. -f2)
100111PATCH=$( echo " $CURRENT_VERSION " | cut -d. -f3)
@@ -117,7 +128,12 @@ case "$bump_type" in
117128esac
118129
119130if git rev-parse " v${NEW_VERSION} " & > /dev/null; then
120- echo " Error: tag 'v${NEW_VERSION} ' already exists."
131+ echo " Error: tag 'v${NEW_VERSION} ' already exists locally."
132+ exit 1
133+ fi
134+
135+ if git ls-remote --tags --exit-code origin " refs/tags/v${NEW_VERSION} " & > /dev/null; then
136+ echo " Error: tag 'v${NEW_VERSION} ' already exists on origin."
121137 exit 1
122138fi
123139
@@ -166,8 +182,17 @@ if [[ "$NEED_DEPLOY" == true ]]; then
166182 -f ipopt_version=" $IPOPT_VERSION "
167183
168184 # Wait for the run to appear
169- sleep 5
170- RUN_ID=$( gh run list --workflow=build_binaries.yml --repo " $DEPLOY_REPO " --limit 1 --json databaseId --jq ' .[0].databaseId' )
185+ DISPATCH_TIME=$( date -u +%Y-%m-%dT%H:%M:%SZ)
186+ for i in {1..12}; do
187+ sleep 5
188+ RUN_ID=$( gh run list --workflow=build_binaries.yml --repo " $DEPLOY_REPO " --limit 1 --event workflow_dispatch --json databaseId,createdAt --jq " [.[] | select(.createdAt >= \" ${DISPATCH_TIME} \" )] | .[0].databaseId" )
189+ [[ -n " $RUN_ID " && " $RUN_ID " != " null" ]] && break
190+ done
191+
192+ if [[ -z " $RUN_ID " || " $RUN_ID " == " null" ]]; then
193+ echo " Error: could not find the triggered workflow run."
194+ exit 1
195+ fi
171196
172197 echo " Waiting for build to complete (run ${RUN_ID} )..."
173198 echo " https://github.com/${DEPLOY_REPO} /actions/runs/${RUN_ID} "
0 commit comments