Fix release publish ordering ahead of protected main push
Problem
The daily release workflow ran npm publish and then git push origin HEAD:main. Because main is protected (required checks test (22) and test (26), enforce_admins: true, required_conversation_resolution: true), that push was rejected with GH006, and the job's fail-fast shell mode killed it before the tag push. The result: npm held the new version while main stayed on an older version with no matching tag — every daily release failed.
Fix
Ported the verified ordering fix from pm-beads#65:
- Added
pull-requests: writepermission. - Captured
base_shain theDecide releasestep. - Replaced the publish-then-push steps with:
- Merge release metadata through protected PR — merges the release commit into
mainvia a protected PR before any publish, using the same merge loop (resolve review threads, attempt the merge API, fail fast only on DIRTY/BEHIND, 30-minute deadline). - Verify merged release — re-checks the merged main commit byte-for-byte before publication.
- Publish npm package — keeps the idempotence guard so an already-published version reconciles instead of failing with a 403.
- Push release tag — tag only;
git push origin HEAD:mainno longer appears.
- Merge release metadata through protected PR — merges the release commit into
- The verify diff file list names the paths this repo actually commits.
dist/is gitignored here, so it is excluded from the verify diff.
The merge loop is byte-identical to pm-beads (only the PR title and the verify diff path list differ per repo). All existing repo-specific details (build steps, RELEASE_TIMEZONE, changelog generation, commit pathspec, GitHub release title) are preserved.
Tracking
pm item: https://github.com/unbraind/pm-github/blob/main/.agents/pm/issues/pm-github-v2kt.toon
Summary by Sourcery
Gate daily releases through a protected PR that merges release metadata into main before publication, ensuring branch protection is respected and main and npm stay in sync.
Enhancements:
- Capture the base main SHA in the release decision step and use it to detect main advancing during release preparation.
- Introduce a merge-and-verify flow that creates a temporary release branch, merges it via the GitHub merge API under branch protection, and byte-checks the merged main state before publishing.
- Make the publish step idempotent by treating already-published versions as successful runs and reconciling workflow state.
- Change the release tagging step to only create and push tags for the verified merged main commit, dropping direct pushes to main.
- Add project management tracking artifacts for this release workflow change.
CI:
- Grant pull request write permissions and expand the release workflow to manage and merge a protected release PR as part of the automated daily release.
Summary by cubic
Fixes the daily release workflow by merging the release commit through a protected PR before npm publish, then pushing only the release tag. Prevents GH006 rejections and keeps main, tags, and npm in sync.
- Bug Fixes
- Merge the release commit into
mainvia a protected PR beforenpm publish; removedgit push HEAD:main. - Verify the merged
maincommit and package version before publishing; ifdist/is gitignored, exclude it; if tracked, rebuild from clean and check with git status including untracked and ignored files so hidden artifacts can’t slip in. - Keep publish idempotent (skip if version already exists) and push only the release tag; fetch remote tags first (using
--refs), compare targets, and exit cleanly if the tag already points to the verified commit. - Grant
pull-requests: writeandactions: write; capturebase_sha; merge loop fails fast on DIRTY/BEHIND, resolves only threads where every comment is bot-authored (skips empty and any truncated/paginated threads), detects CI runs parked onaction_required(logs URL, attempts approval, now scans 100 runs per page), and distinguishes awaiting-approval from failed checks.
- Merge the release commit into