@@ -38,43 +38,52 @@ jobs:
3838 uses : changesets/action@v1
3939 with :
4040 version : bun run version
41- publish : bun run release --no-git-tag
41+ publish : bun run release
4242 commit : " chore: version packages"
4343 title : " chore: version packages"
4444 env :
4545 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
4646 NPM_TOKEN : ${{ secrets.NPM_TOKEN }}
4747
4848 - name : Create GitHub Release
49- if : steps.changesets.outputs.publishedPackages != '' && steps.changesets.outputs.publishedPackages != '[]'
5049 env :
5150 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
52- PUBLISHED : ${{ steps.changesets.outputs.publishedPackages }}
5351 run : |
54- VERSION=$(echo "$PUBLISHED" | jq -r '.[0].version')
52+ # Query npm for the current published version instead of relying on
53+ # changesets' unreliable publishedPackages output
54+ VERSION=$(npm view @mohanscodex/spectra-ai version 2>/dev/null || echo "")
55+ if [ -z "$VERSION" ]; then
56+ echo "No version found on npm — nothing to release"
57+ exit 0
58+ fi
59+
5560 TAG="v${VERSION}"
5661
57- # Build release body
58- {
59- echo "## Published Packages"
60- echo ""
61- for row in $(echo "$PUBLISHED" | jq -r '.[] | @base64'); do
62- PKG_NAME=$(echo "$row" | base64 -d | jq -r '.name')
63- VER=$(echo "$row" | base64 -d | jq -r '.version')
64- echo "- \`\`${PKG_NAME}@${VER}\`\` — [npm](https://www.npmjs.com/package/${PKG_NAME}/v/${VER})"
65- done
66- echo ""
67- echo "## Install"
68- echo ""
69- echo '```sh'
70- echo "bun add @mohanscodex/spectra-ai@${VERSION}"
71- echo '```'
72- } > /tmp/release-body.md
73-
74- # Create and push unified tag, then create GitHub Release
62+ # Skip if release already exists (idempotent)
63+ if gh release view "$TAG" --repo "${{ github.repository }}" &>/dev/null; then
64+ echo "Release $TAG already exists — skipping"
65+ exit 0
66+ fi
67+
68+ # Write release body
69+ cat > /tmp/release-body.md <<- EOF
70+ ## Published Packages
71+
72+ - \`@mohanscodex/spectra-ai@${VERSION}\` — [npm](https://www.npmjs.com/package/@mohanscodex/spectra-ai/v/${VERSION})
73+ - \`@mohanscodex/spectra-agent@${VERSION}\` — [npm](https://www.npmjs.com/package/@mohanscodex/spectra-agent/v/${VERSION})
74+ - \`@mohanscodex/spectra-app@${VERSION}\` — [npm](https://www.npmjs.com/package/@mohanscodex/spectra-app/v/${VERSION})
75+
76+ ## Install
77+
78+ \`\`\`sh
79+ bun add @mohanscodex/spectra-ai@${VERSION} @mohanscodex/spectra-agent@${VERSION}
80+ bun add @mohanscodex/spectra-app@${VERSION}
81+ \`\`\`
82+ EOF
83+
84+ # Create tag and release using gh CLI (handles auth automatically)
7585 git tag "$TAG"
76- git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
77- git push origin "$TAG"
86+ git push "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" "$TAG"
7887
7988 gh release create "$TAG" \
8089 --title "Spectra $TAG" \
0 commit comments