diff --git a/scripts/release.sh b/scripts/release.sh index 7d860564..42f5b345 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -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}"