Skip to content

Commit b89511e

Browse files
authored
hotfix: cron shift + version-release UX (norm, branch-aware default, prerelease, auto-latest) (#279)
1 parent cdb394c commit b89511e

2 files changed

Lines changed: 52 additions & 11 deletions

File tree

.github/workflows/moxygen-sync.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ name: moxygen sync
1313
on:
1414
schedule:
1515
# Fourth (final) stage of the openmoq sync cron cascade (UTC; ET shifts under DST):
16-
# 04:35 picoquic upstream-sync (private-octopus → openmoq/picoquic)
17-
# 05:35 moxygen upstream-sync (facebookexperimental → openmoq/moxygen)
18-
# 05:45 moxygen picoquic-pin sync (openmoq/picoquic → moxygen picoquic-rev.txt)
19-
# 09:05 moqx moxygen-submodule sync (this workflow — openmoq/moxygen → moqx deps/moxygen)
20-
# The 3h20m gap before this stage gives moxygen sync PRs (upstream + picoquic-pin)
16+
# 03:23 picoquic upstream-sync (private-octopus → openmoq/picoquic)
17+
# 04:23 moxygen upstream-sync (facebookexperimental → openmoq/moxygen)
18+
# 04:37 moxygen picoquic-pin sync (openmoq/picoquic → moxygen picoquic-rev.txt)
19+
# 08:23 moqx moxygen-submodule sync (this workflow — openmoq/moxygen → moqx deps/moxygen)
20+
# The 3h46m gap before this stage gives moxygen sync PRs (upstream + picoquic-pin)
2121
# time to run CI and auto-merge into openmoq/moxygen main before we pull it.
22-
- cron: '5 9 * * *'
22+
- cron: '23 8 * * *'
2323
repository_dispatch:
2424
types: [moxygen-update]
2525
workflow_dispatch:

.github/workflows/version-release.yml

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,44 @@ jobs:
124124
# Moxygen reference: explicit input or snapshot-latest fallback.
125125
MOX_REF="${{ inputs.moxygen_release }}"
126126
if [ -z "$MOX_REF" ]; then
127-
MOX_REF="snapshot-latest"
128-
echo "==> No moxygen_release input — defaulting to moxygen snapshot-latest"
127+
# Branch-aware default: from main, use GitHub's "latest" tagged
128+
# release (highest non-prerelease semver across all branches).
129+
# From release/vM.m, use the latest non-prerelease v M.m.* tag —
130+
# so a hotfix dispatch on a release line picks the matching
131+
# moxygen patch line, not whatever's newest globally.
132+
if [ "$BRANCH" = "main" ]; then
133+
MOX_REF=$(gh release view --repo openmoq/moxygen --json tagName --jq .tagName 2>/dev/null || true)
134+
if [ -z "$MOX_REF" ]; then
135+
echo "Error: no tagged moxygen release found." >&2
136+
exit 1
137+
fi
138+
echo "==> No moxygen_release input — defaulting to GitHub latest: $MOX_REF"
139+
else
140+
LABEL="${BRANCH#release/v}"
141+
MOX_REF=$(gh release list --repo openmoq/moxygen --limit 50 \
142+
--json tagName,isPrerelease \
143+
--jq ".[] | select(.isPrerelease == false) | select(.tagName | startswith(\"v$LABEL.\")) | .tagName" \
144+
| head -1)
145+
if [ -z "$MOX_REF" ]; then
146+
echo "Error: no v${LABEL}.* non-prerelease moxygen release found for this release branch line." >&2
147+
exit 1
148+
fi
149+
echo "==> No moxygen_release input — defaulting to latest v${LABEL}.* tag: $MOX_REF"
150+
fi
129151
else
152+
# Accept bare semver (0.1.4) or v-prefixed (v0.1.4); normalize.
153+
if [[ "$MOX_REF" =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]]; then
154+
MOX_REF="v$MOX_REF"
155+
echo "==> Normalized bare semver to $MOX_REF"
156+
fi
130157
echo "==> Pinning to moxygen release: $MOX_REF"
131158
fi
132159
133-
# Verify moxygen reference exists.
160+
# Verify moxygen reference exists; on failure, list recent releases.
134161
if ! gh release view "$MOX_REF" --repo openmoq/moxygen >/dev/null 2>&1; then
135162
echo "Error: moxygen release $MOX_REF does not exist on openmoq/moxygen" >&2
163+
echo "Available recent releases:" >&2
164+
gh release list --repo openmoq/moxygen --limit 10 --json tagName --jq '.[].tagName' | sed 's/^/ /' >&2
136165
exit 1
137166
fi
138167
@@ -196,9 +225,17 @@ jobs:
196225
PORTABLE_NOTE="_Portable Linux tarballs not produced for this release: moxygen \`${MOX_REF}\` does not include the required portable assets._"
197226
fi
198227
228+
# Mark prereleases (1.2.3-rc1) as such so GitHub's "latest"
229+
# algorithm correctly excludes them.
230+
PRERELEASE_FLAG=()
231+
if [[ "$VERSION" == *-* ]]; then
232+
PRERELEASE_FLAG=(--prerelease)
233+
fi
234+
199235
gh release create "$TAG" \
200236
--target "$SNAPSHOT_SHA" \
201237
--title "moqx $VERSION" \
238+
"${PRERELEASE_FLAG[@]}" \
202239
--notes "$(cat <<EOF
203240
**Version:** \`${VERSION}\`
204241
**Commit:** \`${SNAPSHOT_SHA}\`
@@ -437,11 +474,15 @@ jobs:
437474
app-id: ${{ secrets.OMOQ_APP_ID }}
438475
private-key: ${{ secrets.OMOQ_APP_PRIV_KEY }}
439476

440-
- name: Mark release as latest
477+
- name: Confirm release published
441478
env:
442479
GH_TOKEN: ${{ steps.app-token.outputs.token }}
443480
REPO: ${{ github.repository }}
444481
TAG: ${{ needs.validate.outputs.tag }}
445482
run: |
446-
gh release edit "$TAG" --repo "$REPO" --latest
483+
# No --latest flag here. Let GitHub's auto-latest algorithm
484+
# pick the highest non-prerelease semver tag. Forcing --latest
485+
# would mark a hotfix patch from a release/vM.m branch as
486+
# latest even when a newer vM.(m+1) line exists.
447487
echo "Released: $TAG"
488+
gh release view "$TAG" --repo "$REPO" --json isLatest,isPrerelease,name --jq '"isLatest=\(.isLatest) isPrerelease=\(.isPrerelease) name=\(.name)"'

0 commit comments

Comments
 (0)