@@ -173,16 +173,16 @@ jobs:
173173 with :
174174 sarif_file : ' trivy-results.sarif'
175175
176- # Phase 4 : NPM Publish (depends on build-and-test )
177- npm-publish :
178- name : Publish to NPM
176+ # Phase 4a : NPM Publish Stable (main branch )
177+ npm-publish-stable :
178+ name : Publish to NPM (Stable)
179179 runs-on : ubuntu-latest
180180 needs : build-and-test
181181 if : |
182- github.event_name == 'workflow_dispatch' ||
183- ( github.event_name == 'push' &&
184- (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop') &&
185- contains(github.event.head_commit.message, '[publish]') )
182+ github.ref == 'refs/heads/main' && (
183+ github.event_name == 'workflow_dispatch' ||
184+ (github.event_name == 'push' && contains( github.event.head_commit.message, '[publish]'))
185+ )
186186 permissions :
187187 contents : read
188188 id-token : write
@@ -242,10 +242,10 @@ jobs:
242242 - name : Create summary
243243 if : always()
244244 run : |
245- echo "## 📦 NPM Publish Results" >> $GITHUB_STEP_SUMMARY
245+ echo "## 📦 NPM Publish Results (Stable) " >> $GITHUB_STEP_SUMMARY
246246
247247 if [ "${{ steps.check_versions.outputs.has_packages_to_publish }}" == "true" ]; then
248- echo "### ✅ Successfully Published" >> $GITHUB_STEP_SUMMARY
248+ echo "### ✅ Successfully Published to latest tag " >> $GITHUB_STEP_SUMMARY
249249 echo "${{ steps.publish.outputs.published_packages }}" >> $GITHUB_STEP_SUMMARY
250250 else
251251 echo "### ℹ️ No Packages to Publish" >> $GITHUB_STEP_SUMMARY
@@ -257,11 +257,100 @@ jobs:
257257 echo "**Branch:** ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
258258 echo "**Commit:** ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
259259
260+ # Phase 4b: NPM Publish Dev (develop branch)
261+ npm-publish-dev :
262+ name : Publish to NPM (Dev)
263+ runs-on : ubuntu-latest
264+ needs : build-and-test
265+ if : |
266+ github.ref == 'refs/heads/develop' && (
267+ github.event_name == 'workflow_dispatch' ||
268+ github.event_name == 'push'
269+ )
270+ permissions :
271+ contents : read
272+ id-token : write
273+
274+ steps :
275+ - name : Checkout code
276+ uses : actions/checkout@v4
277+ with :
278+ fetch-depth : 0
279+
280+ - name : Setup Node.js
281+ uses : actions/setup-node@v4
282+ with :
283+ node-version : ' 20'
284+ registry-url : ' https://registry.npmjs.org'
285+
286+ - name : Setup pnpm
287+ uses : pnpm/action-setup@v4
288+ with :
289+ version : 10.13.1
290+ run_install : false
291+
292+ - name : Restore pnpm cache
293+ uses : actions/cache@v4
294+ with :
295+ path : ~/.pnpm-store
296+ key : ${{ needs.build-and-test.outputs.cache-key }}
297+ restore-keys : |
298+ ${{ runner.os }}-pnpm-
299+
300+ - name : Install dependencies
301+ run : ./.github/scripts/setup-node.sh
302+
303+ - name : Restore build artifacts
304+ uses : actions/cache@v4
305+ with :
306+ path : |
307+ packages/*/build
308+ packages/web/.next-build
309+ key : build-${{ github.sha }}-20
310+
311+ - name : Bump to dev prerelease versions
312+ id : bump_versions
313+ run : |
314+ ./.github/scripts/bump-dev-versions.sh
315+
316+ - name : Publish dev packages
317+ id : publish_dev
318+ env :
319+ NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
320+ run : |
321+ ./.github/scripts/publish-dev-packages.sh
322+
323+ - name : Create summary
324+ if : always()
325+ run : |
326+ echo "## 📦 NPM Publish Results (Dev)" >> $GITHUB_STEP_SUMMARY
327+
328+ if [ "${{ steps.publish_dev.outcome }}" == "success" ]; then
329+ echo "### ✅ Successfully Published to dev tag" >> $GITHUB_STEP_SUMMARY
330+ echo "${{ steps.publish_dev.outputs.published_packages }}" >> $GITHUB_STEP_SUMMARY
331+ echo "" >> $GITHUB_STEP_SUMMARY
332+ echo "Install dev versions with:" >> $GITHUB_STEP_SUMMARY
333+ echo "\`\`\`bash" >> $GITHUB_STEP_SUMMARY
334+ echo "npm install @codervisor/devlog-core@dev" >> $GITHUB_STEP_SUMMARY
335+ echo "npm install @codervisor/devlog-mcp@dev" >> $GITHUB_STEP_SUMMARY
336+ echo "npm install @codervisor/devlog-ai@dev" >> $GITHUB_STEP_SUMMARY
337+ echo "npm install @codervisor/devlog-cli@dev" >> $GITHUB_STEP_SUMMARY
338+ echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
339+ else
340+ echo "### ❌ Dev Publishing Failed" >> $GITHUB_STEP_SUMMARY
341+ echo "Check the logs for details" >> $GITHUB_STEP_SUMMARY
342+ fi
343+
344+ echo "" >> $GITHUB_STEP_SUMMARY
345+ echo "**Trigger:** ${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY
346+ echo "**Branch:** ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
347+ echo "**Commit:** ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
348+
260349 # Final Summary Job
261350 deployment-summary :
262351 name : Deployment Summary
263352 runs-on : ubuntu-latest
264- needs : [build-and-test, docker-build, npm-publish]
353+ needs : [build-and-test, docker-build, npm-publish-stable, npm-publish-dev ]
265354 if : always() && github.event_name != 'pull_request'
266355
267356 steps :
@@ -278,4 +367,5 @@ jobs:
278367 echo "### Job Status:" >> $GITHUB_STEP_SUMMARY
279368 echo "- 🧪 **Build & Test:** ${{ needs.build-and-test.result }}" >> $GITHUB_STEP_SUMMARY
280369 echo "- 🐳 **Docker Build:** ${{ needs.docker-build.result }}" >> $GITHUB_STEP_SUMMARY
281- echo "- 📦 **NPM Publish:** ${{ needs.npm-publish.result }}" >> $GITHUB_STEP_SUMMARY
370+ echo "- 📦 **NPM Publish (Stable):** ${{ needs.npm-publish-stable.result }}" >> $GITHUB_STEP_SUMMARY
371+ echo "- 🚧 **NPM Publish (Dev):** ${{ needs.npm-publish-dev.result }}" >> $GITHUB_STEP_SUMMARY
0 commit comments