1- name : Publish Node.js Package to npm
1+ name : Publish Node.js Package to GitHub Packages
22
33on :
44 workflow_dispatch :
@@ -316,7 +316,7 @@ jobs:
316316 if-no-files-found : error
317317
318318 publish :
319- name : Publish to npm
319+ name : Publish to GitHub Packages
320320 runs-on : [self-hosted, Linux, X64]
321321 needs : [test-universal, test-macos]
322322 environment : production
@@ -328,42 +328,15 @@ jobs:
328328 uses : actions/setup-node@v4
329329 with :
330330 node-version : ' 20'
331+ registry-url : ' https://npm.pkg.github.com'
332+ scope : ' @terraphim'
331333 cache : ' yarn'
332334 cache-dependency-path : terraphim_ai_nodejs/yarn.lock
333335
334336 - name : Install dependencies
335337 working-directory : terraphim_ai_nodejs
336338 run : yarn install --frozen-lockfile
337339
338- - name : Install 1Password CLI
339- run : |
340- curl -sSf https://downloads.1password.com/linux/keys/1password.asc | \
341- gpg --dearmor --output /usr/share/keyrings/1password-archive-keyring.gpg
342- echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/1password-archive-keyring.gpg] https://downloads.1password.com/linux/debian/$(dpkg --print-architecture) stable main" | \
343- sudo tee /etc/apt/sources.list.d/1password.list
344- sudo apt update && sudo apt install op -y
345-
346- - name : Authenticate with 1Password
347- run : |
348- echo "${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}" | op account add --service-account-token
349-
350- - name : Get npm token from 1Password
351- id : token
352- run : |
353- TOKEN=$(op read "op://TerraphimPlatform/npm.token/token" || echo "")
354- if [[ -z "$TOKEN" ]]; then
355- echo "⚠️ npm token not found in 1Password, checking GitHub secrets"
356- TOKEN="${{ secrets.NPM_TOKEN }}"
357- fi
358-
359- if [[ -z "$TOKEN" ]]; then
360- echo "❌ No npm token available"
361- exit 1
362- fi
363-
364- echo "token=$TOKEN" >> $GITHUB_OUTPUT
365- echo "✅ npm token retrieved successfully"
366-
367340 - name : Download all artifacts
368341 uses : actions/download-artifact@v4
369342 with :
@@ -397,14 +370,16 @@ jobs:
397370 npm version ${{ inputs.version }} --no-git-tag-version
398371 fi
399372
400- - name : Configure npm for publishing
373+ - name : Configure npm for GitHub Packages
401374 working-directory : terraphim_ai_nodejs
375+ env :
376+ NODE_AUTH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
402377 run : |
403- echo "//registry.npmjs.org /:_authToken=${{ steps.token.outputs.token }}" > ~/.npmrc
404- npm config set provenance true
378+ echo "//npm.pkg.github.com /:_authToken=${{ secrets.GITHUB_TOKEN }}" > ~/.npmrc
379+ echo "@terraphim:registry=https:// npm.pkg.github.com" >> ~/.npmrc
405380
406381 # Show current package info
407- echo "📋 Package information:"
382+ echo "Package information:"
408383 npm pack --dry-run | head -20
409384
410385 - name : Determine publishing strategy
@@ -437,40 +412,45 @@ jobs:
437412 echo "npm_tag=$NPM_TAG" >> $GITHUB_OUTPUT
438413 echo "🎯 Publishing strategy: $VERSION_TYPE -> $NPM_TAG"
439414
440- - name : Publish to npm
415+ - name : Publish to GitHub Packages
441416 working-directory : terraphim_ai_nodejs
417+ env :
418+ NODE_AUTH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
442419 run : |
443420 if [[ "${{ inputs.dry_run }}" == "true" ]]; then
444- echo "🧪 Dry run mode - checking package only"
421+ echo "Dry run mode - checking package only"
445422 npm publish --dry-run --access public --tag ${{ steps.strategy.outputs.npm_tag }}
446423 else
447- echo "🚀 Publishing @terraphim/autocomplete to npm"
424+ echo "Publishing @terraphim/autocomplete to GitHub Packages"
425+ echo "Registry: https://npm.pkg.github.com"
448426 echo "Tag: ${{ steps.strategy.outputs.npm_tag }}"
449427
450- # Publish with appropriate tag
428+ # Publish to GitHub Packages
451429 npm publish --access public --tag ${{ steps.strategy.outputs.npm_tag }}
452430
453- echo "✅ Package published successfully!"
431+ echo "Package published successfully!"
432+ echo "Install with: npm install @terraphim/autocomplete --registry=https://npm.pkg.github.com"
454433 fi
455434
456435 - name : Verify published package
457436 if : inputs.dry_run != 'true'
458437 working-directory : terraphim_ai_nodejs
438+ env :
439+ NODE_AUTH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
459440 run : |
460- echo "🔍 Verifying published package..."
441+ echo "Verifying published package..."
461442
462- # Wait a moment for npm to update
463- sleep 30
443+ # Wait a moment for registry to update
444+ sleep 10
464445
465446 # Check if package is available
466447 PACKAGE_NAME="@terraphim/autocomplete"
467448 PACKAGE_VERSION=$(node -p "require('./package.json').version")
468449
469450 echo "Checking: $PACKAGE_NAME@$PACKAGE_VERSION"
470- npm view $PACKAGE_NAME@$PACKAGE_VERSION || echo "⚠️ Package not immediately visible (may take a few minutes)"
451+ npm view $PACKAGE_NAME@$PACKAGE_VERSION --registry=https://npm.pkg.github.com || echo "Package not immediately visible (may take a few minutes)"
471452
472- echo "📊 Package info:"
473- npm view $PACKAGE_NAME || echo "⚠️ General package info not available yet"
453+ echo "GitHub Packages URL: https://github.com/terraphim/terraphim-ai/packages"
474454
475455 - name : Create GitHub Release
476456 if : startsWith(github.ref, 'refs/tags/') && inputs.dry_run != 'true'
@@ -487,25 +467,25 @@ jobs:
487467 **Version**: ${{ steps.strategy.outputs.version_type }}
488468 **Tag**: ${{ steps.strategy.outputs.npm_tag }}
489469
490- ### 🚀 Installation
470+ ### Installation
491471 ```bash
492- npm install @terraphim/autocomplete@${{ steps.strategy.outputs.npm_tag }}
472+ npm install @terraphim/autocomplete@${{ steps.strategy.outputs.npm_tag }} --registry=https://npm.pkg.github.com
493473 ```
494474
495- ### ✨ Features
475+ ### Features
496476 - **Autocomplete**: Fast prefix search with scoring
497477 - **Knowledge Graph**: Semantic connectivity analysis
498478 - **Native Performance**: Rust backend with NAPI bindings
499479 - **Cross-Platform**: Linux, macOS, Windows support
500480 - **TypeScript**: Auto-generated type definitions
501481
502- ### 📊 Performance
482+ ### Performance
503483 - **Autocomplete Index**: ~749 bytes
504484 - **Knowledge Graph**: ~856 bytes
505485 - **Native Library**: ~10MB (optimized for production)
506486
507- ### 🔗 Links
508- - [npm package ](https://www.npmjs. com/package/@ terraphim/autocomplete )
487+ ### Links
488+ - [GitHub Package ](https://github. com/terraphim/ terraphim-ai/packages )
509489 - [Documentation](https://github.com/terraphim/terraphim-ai/tree/main/terraphim_ai_nodejs)
510490
511491 ---
@@ -515,8 +495,13 @@ jobs:
515495
516496 - name : Notify on success
517497 if : inputs.dry_run != 'true'
498+ working-directory : terraphim_ai_nodejs
518499 run : |
519- echo "🎉 npm publishing workflow completed successfully!"
520- echo "📦 Package: @terraphim/autocomplete"
521- echo "🏷️ Tag: ${{ steps.strategy.outputs.npm_tag }}"
522- echo "📋 Version: $(node -p "require('./package.json').version")"
500+ echo "Publishing workflow completed successfully!"
501+ echo "Package: @terraphim/autocomplete"
502+ echo "Registry: GitHub Packages (npm.pkg.github.com)"
503+ echo "Tag: ${{ steps.strategy.outputs.npm_tag }}"
504+ echo "Version: $(node -p "require('./package.json').version")"
505+ echo ""
506+ echo "Install with:"
507+ echo " npm install @terraphim/autocomplete --registry=https://npm.pkg.github.com"
0 commit comments