Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

fix(open-knowledge): guard auto-promote against already-released + half-cut betas (#2199)

Andrew Mikofalvy53ed9c3c6e91
diff --git a/.github/workflows/promote-stable.yml b/.github/workflows/promote-stable.yml
index 20f1fe2ea..e4dfadf57 100644
--- a/.github/workflows/promote-stable.yml
+++ b/.github/workflows/promote-stable.yml
@@ -138,6 +138,7 @@ jobs:
set -euo pipefail
if [[ -n "${INPUT_BETA_TAG:-}" ]]; then
RESOLVED="$INPUT_BETA_TAG"
+ echo "auto=false" >> "$GITHUB_OUTPUT"
echo "Using explicitly provided beta tag: $RESOLVED"
else
RESOLVED=$(git tag --list 'v*-beta.*' --sort=-version:refname \
@@ -147,10 +148,59 @@ jobs:
echo "::error::No vX.Y.Z-beta.N tags found to promote. Did the auto-cadence beta release run?"
exit 1
fi
+ echo "auto=true" >> "$GITHUB_OUTPUT"
echo "Auto-resolved newest beta tag: $RESOLVED"
fi
echo "beta_tag=$RESOLVED" >> "$GITHUB_OUTPUT"
+ - name: Guard - auto-resolved beta is unpromoted + fully cut
+ # Only the auto path (Slack button / blank dispatch) needs these
+ # guards. The explicit beta_tag path is an operator override that
+ # keeps the workflow's idempotent recovery behavior (re-run to repair
+ # a partial promotion), so it bypasses this step.
+ if: steps.resolve.outputs.auto == 'true'
+ env:
+ GH_TOKEN: ${{ steps.app-token.outputs.token }}
+ BETA_TAG: ${{ steps.resolve.outputs.beta_tag }}
+ run: |
+ set -euo pipefail
+
+ # Guard A — must not already be promoted to stable. After a
+ # promotion the newest beta tag still points at the just-promoted
+ # version until a fresh beta is cut. release.yml's "beta base must
+ # lead the latest stable" guard guarantees no new vX.Y.Z-beta.M is
+ # cut once vX.Y.Z exists, so a present stable tag means this beta is
+ # already released — re-promoting would re-publish an existing npm
+ # version (hard error) and re-upload onto the live stable Release.
+ STABLE_TAG="v$(printf '%s' "$BETA_TAG" | sed -E 's/^v//; s/-beta\.[0-9]+$//')"
+ if git rev-parse "refs/tags/${STABLE_TAG}" >/dev/null 2>&1; then
+ echo "::error::Newest beta ${BETA_TAG} is already promoted to stable ${STABLE_TAG}. Cut a new beta before promoting again — there is nothing newer to release."
+ exit 1
+ fi
+
+ # Guard B — the beta cut must be COMPLETE. release.yml creates the
+ # beta Release as --draft; desktop-release.yml flips it to published
+ # ONLY after the signed DMG + beta-mac.yml upload succeeds, and it
+ # runs on a SEPARATE concurrency group, so promote-stable can
+ # otherwise acquire the release lock while the DMG is still building
+ # (up to 45 min). npm beta publish happens earlier in the same
+ # pipeline, so a published release implies the npm artifact too. A
+ # draft or asset-less release = the cut is in-flight or failed;
+ # promoting it would build stable from an unvalidated SHA.
+ meta=$(gh release view "$BETA_TAG" --json isDraft,assets 2>/dev/null || true)
+ if [[ -z "$meta" ]]; then
+ echo "::error::No GitHub Release exists for ${BETA_TAG} yet — its beta cut has not finished creating the release. Wait for the cut to complete, then retry."
+ exit 1
+ fi
+ isDraft=$(printf '%s' "$meta" | jq -r '.isDraft')
+ dmg=$(printf '%s' "$meta" | jq -r '[.assets[].name | select(endswith(".dmg"))] | length')
+ manifest=$(printf '%s' "$meta" | jq -r '[.assets[].name | select(endswith("-mac.yml"))] | length')
+ if [[ "$isDraft" == "true" || "$dmg" -eq 0 || "$manifest" -eq 0 ]]; then
+ echo "::error::Beta ${BETA_TAG} is not fully cut (draft=${isDraft}, dmg=${dmg}, mac.yml=${manifest}). Its desktop-release build is still running or failed — wait a few minutes and retry, or fix the failed cut before promoting."
+ exit 1
+ fi
+ echo "Beta ${BETA_TAG} is complete (published, ${dmg} dmg, ${manifest} mac.yml) and not yet promoted to ${STABLE_TAG}; safe to promote."
+
- name: Verify beta tag exists
env:
BETA_TAG: ${{ steps.resolve.outputs.beta_tag }}