fix(release): push the public mirror explicitly and verify the tag lands at the right commit before publishing
All checks were successful
CI / Node 22 (push) Successful in 2m57s
CI / Node 24 (push) Successful in 2m49s
CI / Bun (latest) (push) Successful in 3m2s

Origin moved to the private forge; the public repo is now a mirror with an
unknown sync cadence. The release flow creates the GitHub release directly,
and a missing tag there would be silently created at the default-branch
head - the wrong commit. The script now pushes branch+tag to the mirror
itself and hard-stops if the tag's commit on the mirror differs from local,
before anything irreversible (npm publish) happens.
This commit is contained in:
David Snelling 2026-07-23 10:01:28 -07:00
parent 3a1efc9460
commit 6ba94c8c43

View file

@ -175,10 +175,26 @@ echo -e "${BLUE}7⃣ Creating git tag v${NEW_VERSION}...${NC}"
git tag -a "v${NEW_VERSION}" -m "Release v${NEW_VERSION}"
echo -e "${GREEN}✅ Tag created${NC}\n"
# Step 9: Push to GitHub
echo -e "${BLUE}8⃣ Pushing to GitHub...${NC}"
# Step 9: Push to origin (source of truth) and the public GitHub mirror
echo -e "${BLUE}8⃣ Pushing to origin...${NC}"
git push --follow-tags origin "$CURRENT_BRANCH"
echo -e "${GREEN}✅ Pushed to GitHub${NC}\n"
echo -e "${GREEN}✅ Pushed to origin${NC}\n"
# The public GitHub repo is a mirror of origin with an unknown sync cadence.
# `gh release create` below targets GitHub directly: if the new tag hasn't
# reached GitHub yet, gh would CREATE it — pointed at GitHub's default-branch
# head, i.e. the wrong commit. Push branch+tag to GitHub explicitly, then
# verify the tag resolves there to the same commit before any release is cut.
GITHUB_URL="https://github.com/soulcraftlabs/brainy.git"
echo -e "${BLUE}8⃣½ Pushing to the public GitHub mirror...${NC}"
git push --follow-tags "$GITHUB_URL" "$CURRENT_BRANCH"
LOCAL_TAG_SHA="$(git rev-parse "v${NEW_VERSION}^{}")"
GITHUB_TAG_SHA="$(git ls-remote --tags "$GITHUB_URL" "v${NEW_VERSION}^{}" | cut -f1)"
if [ "$LOCAL_TAG_SHA" != "$GITHUB_TAG_SHA" ]; then
echo -e "${RED}❌ Tag v${NEW_VERSION} on GitHub (${GITHUB_TAG_SHA:-absent}) does not match local (${LOCAL_TAG_SHA}) — aborting before npm publish. Fix the mirror, then re-run.${NC}"
exit 1
fi
echo -e "${GREEN}✅ GitHub mirror has the tag at the right commit${NC}\n"
# Step 10: Publish to npm
echo -e "${BLUE}9⃣ Publishing to npm (dist-tag: ${NPM_TAG})...${NC}"