11# Package Release Workflow
22#
3- # Automatically releases the opennextjs-cli package to npm when a version tag
4- # is pushed. Supports both NPM_TOKEN (for first release) and OIDC (for subsequent releases).
3+ # Automatically releases both @jsonbored/opennextjs-cli and @jsonbored/opennextjs-mcp
4+ # packages to npm when a version tag is pushed. Supports both NPM_TOKEN (for first release)
5+ # and OIDC (for subsequent releases). Both packages are released with synchronized versions.
56#
67# **What it does:**
7- # 1. Builds and tests the package
8+ # 1. Builds both packages (CLI and MCP)
89# 2. Extracts version from tag (e.g., v1.0.0 → 1.0.0)
9- # 3. Verifies package.json version matches tag version
10+ # 3. Verifies both package.json versions match tag version
1011# 4. Generates changelog automatically using git-cliff
11- # 5. Publishes to npm (tries OIDC first, falls back to NPM_TOKEN)
12+ # 5. Publishes both packages to npm (tries OIDC first, falls back to NPM_TOKEN)
1213# 6. Creates GitHub Release with changelog notes
1314#
1415# **Trigger:**
6263
6364 - name : Setup pnpm
6465 uses : pnpm/action-setup@v4
65- with :
66- version : 8
6766
6867 - name : Setup Node.js
6968 uses : actions/setup-node@v4
@@ -75,10 +74,14 @@ jobs:
7574 - name : Install dependencies
7675 run : pnpm install --frozen-lockfile
7776
78- - name : Build
77+ - name : Build CLI package
7978 working-directory : packages/opennextjs-cli
8079 run : pnpm build
8180
81+ - name : Build MCP package
82+ working-directory : packages/opennextjs-mcp
83+ run : pnpm build
84+
8285 - name : Extract version from tag
8386 id : version
8487 run : |
@@ -89,16 +92,27 @@ jobs:
8992 echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
9093 echo "Tag version: $VERSION"
9194
92- - name : Verify package.json version matches tag
95+ - name : Verify CLI package.json version matches tag
9396 working-directory : packages/opennextjs-cli
9497 run : |
9598 PACKAGE_VERSION=$(node -p "require('./package.json').version")
9699 TAG_VERSION="${{ steps.version.outputs.VERSION }}"
97100 if [ "$PACKAGE_VERSION" != "$TAG_VERSION" ]; then
98- echo "❌ Version mismatch: package.json ($PACKAGE_VERSION) != tag ($TAG_VERSION)" >&2
101+ echo "❌ CLI version mismatch: package.json ($PACKAGE_VERSION) != tag ($TAG_VERSION)" >&2
99102 exit 1
100103 fi
101- echo "✅ Version match: $PACKAGE_VERSION"
104+ echo "✅ CLI version match: $PACKAGE_VERSION"
105+
106+ - name : Verify MCP package.json version matches tag
107+ working-directory : packages/opennextjs-mcp
108+ run : |
109+ PACKAGE_VERSION=$(node -p "require('./package.json').version")
110+ TAG_VERSION="${{ steps.version.outputs.VERSION }}"
111+ if [ "$PACKAGE_VERSION" != "$TAG_VERSION" ]; then
112+ echo "❌ MCP version mismatch: package.json ($PACKAGE_VERSION) != tag ($TAG_VERSION)" >&2
113+ exit 1
114+ fi
115+ echo "✅ MCP version match: $PACKAGE_VERSION"
102116
103117 - name : Check if git-cliff is installed
104118 id : git-cliff-check
@@ -146,8 +160,8 @@ jobs:
146160 cat /tmp/changelog-section.md >> $GITHUB_ENV
147161 echo "EOF" >> $GITHUB_ENV
148162
149- - name : Publish to npm (try OIDC first)
150- id : publish-oidc
163+ - name : Publish CLI to npm (try OIDC first)
164+ id : publish-cli- oidc
151165 working-directory : packages/opennextjs-cli
152166 run : |
153167 # Try publishing with OIDC (if configured)
@@ -156,8 +170,8 @@ jobs:
156170 echo "⚠️ OIDC publish failed, will try NPM_TOKEN fallback"
157171 continue-on-error : true
158172
159- - name : Publish to npm (fallback to NPM_TOKEN)
160- if : steps.publish-oidc.outcome == 'failure'
173+ - name : Publish CLI to npm (fallback to NPM_TOKEN)
174+ if : steps.publish-cli- oidc.outcome == 'failure'
161175 working-directory : packages/opennextjs-cli
162176 env :
163177 NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
@@ -173,13 +187,39 @@ jobs:
173187 echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" > ~/.npmrc
174188 npm publish --access public
175189 echo "✅ Published @jsonbored/opennextjs-cli@${{ steps.version.outputs.VERSION }} to npm (via NPM_TOKEN)"
190+
191+ - name : Publish MCP to npm (try OIDC first)
192+ id : publish-mcp-oidc
193+ working-directory : packages/opennextjs-mcp
194+ run : |
195+ # Try publishing with OIDC (if configured)
196+ npm publish --access public && \
197+ echo "✅ Published @jsonbored/opennextjs-mcp@${{ steps.version.outputs.VERSION }} to npm (via OIDC)" || \
198+ echo "⚠️ OIDC publish failed, will try NPM_TOKEN fallback"
199+ continue-on-error : true
200+
201+ - name : Publish MCP to npm (fallback to NPM_TOKEN)
202+ if : steps.publish-mcp-oidc.outcome == 'failure'
203+ working-directory : packages/opennextjs-mcp
204+ env :
205+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
206+ run : |
207+ if [ -z "$NODE_AUTH_TOKEN" ]; then
208+ echo "❌ NPM_TOKEN secret not found" >&2
209+ exit 1
210+ fi
211+ # Configure npm to use token (if not already configured)
212+ if [ ! -f ~/.npmrc ]; then
213+ echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" > ~/.npmrc
214+ fi
215+ npm publish --access public
216+ echo "✅ Published @jsonbored/opennextjs-mcp@${{ steps.version.outputs.VERSION }} to npm (via NPM_TOKEN)"
176217 echo "" >&2
177- echo "💡 After first release, set up OIDC trusted publishing for better security :" >&2
218+ echo "💡 After first release, set up OIDC trusted publishing for both packages :" >&2
178219 echo " 1. Go to: https://www.npmjs.com/settings/JSONbored/automation" >&2
179- echo " 2. Click 'Add GitHub Actions' or 'Configure' next to 'Trusted Publishers'" >&2
180- echo " 3. Select repository: JSONbored/opennextjs-cli" >&2
181- echo " 4. Select workflow: .github/workflows/release.yml" >&2
182- echo " 5. Save" >&2
220+ echo " 2. Add trusted publisher for @jsonbored/opennextjs-cli" >&2
221+ echo " 3. Add trusted publisher for @jsonbored/opennextjs-mcp" >&2
222+ echo " 4. Both use: repository JSONbored/opennextjs-cli, workflow .github/workflows/release.yml" >&2
183223 echo " Then you can remove the NPM_TOKEN secret." >&2
184224
185225 - name : Create GitHub Release
@@ -188,6 +228,11 @@ jobs:
188228 tag_name : ${{ github.ref_name }}
189229 name : Release ${{ steps.version.outputs.VERSION }}
190230 body : |
231+ ## Packages Released
232+
233+ - `@jsonbored/opennextjs-cli@${{ steps.version.outputs.VERSION }}`
234+ - `@jsonbored/opennextjs-mcp@${{ steps.version.outputs.VERSION }}`
235+
191236 ${{ env.CHANGELOG_SECTION }}
192237 draft : false
193238 prerelease : false
0 commit comments