From cb95eb5a073c4f9a484324e3b7ee0cc80d3c07d2 Mon Sep 17 00:00:00 2001 From: Sallvainian Date: Sun, 26 Apr 2026 04:27:46 -0400 Subject: [PATCH] ci(publish): cut follow-on prerelease after stable to keep @next ahead When a stable release is cut via workflow_dispatch with channel=latest, @latest can leapfrog the current @next head. Without a corresponding prerelease publish, the @next dist-tag is left pointing at an older version, which turns `npx bmad-method@next install` into a downgrade. This is the root cause of #2317: @latest=6.5.0 but @next=6.4.1-next.0, so users running `npx bmad-method@next install` get the older code written over the newer. Add a final step in the latest-channel branch that derives the next prerelease (max(@next-stripped, @latest) bumped to -next.0) and publishes it with --tag next, reusing the proven `npm publish --provenance` flow rather than mutating dist-tags directly. Runs after the GitHub Release and Discord notify steps so they still see the stable version in package.json. Refs #2317 Co-Authored-By: Claude Opus 4.7 (1M context) --- .github/workflows/publish.yaml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 0079a5e81..c6f4450b5 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -150,3 +150,29 @@ jobs: jq -n --arg content "$MSG" '{content: $content}' | curl -sf --retry 2 -X POST "$WEBHOOK" -H "Content-Type: application/json" -d @- env: WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + + # After cutting a stable release, also publish a follow-on prerelease + # so the @next dist-tag never lags behind @latest. Without this, a + # stable that leapfrogs the current @next head leaves @next pointing at + # an older version, and `npx bmad-method@next install` becomes a + # downgrade. Reuses the proven `npm publish --provenance` flow rather + # than mutating dist-tags directly. Runs last so the GitHub Release and + # Discord notify steps above still see the stable version in package.json. + - name: Cut follow-on prerelease so @next stays ahead of @latest + if: github.event_name == 'workflow_dispatch' && inputs.channel == 'latest' + run: | + NEXT_VER=$(npm view bmad-method@next version 2>/dev/null || echo "") + LATEST_VER=$(node -p 'require("./package.json").version') + + BASE=$(node -e " + const semver = require('semver'); + const next = process.argv[1] || null; + const latest = process.argv[2]; + if (!next) { console.log(latest); process.exit(0); } + const nextBase = next.replace(/-next\.\d+$/, ''); + console.log(semver.gt(latest, nextBase) ? latest : next); + " "$NEXT_VER" "$LATEST_VER") + + npm version "$BASE" --no-git-tag-version --allow-same-version + npm version prerelease --preid=next --no-git-tag-version + npm publish --tag next --provenance