Skip to content

Commit 8fa905d

Browse files
AlexMikhalevclaude
andcommitted
fix(ci): switch npm publishing to GitHub Packages registry
- Update publish-bun.yml to use npm.pkg.github.com instead of npmjs.org - Update publish-npm.yml to use npm.pkg.github.com - Add publishConfig to package.json for GitHub Packages - Use GITHUB_TOKEN instead of NPM_TOKEN for authentication - Remove OIDC provenance flag (not needed for GitHub Packages) - Bump version to 1.3.1 This fixes the npm publishing 404 error caused by expired/revoked access token and OIDC authentication issues with npmjs.org. GitHub Packages uses the built-in GITHUB_TOKEN which is automatically available in GitHub Actions with proper permissions. Generated with Terraphim AI Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 8c8bcb0 commit 8fa905d

3 files changed

Lines changed: 93 additions & 103 deletions

File tree

.github/workflows/publish-bun.yml

Lines changed: 48 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish to Bun Registry
1+
name: Publish to GitHub Packages (Bun Compatible)
22

33
on:
44
workflow_dispatch:
@@ -342,7 +342,7 @@ jobs:
342342
if-no-files-found: error
343343

344344
publish-to-bun:
345-
name: Publish to Bun Registry
345+
name: Publish to GitHub Packages
346346
runs-on: [self-hosted, Linux]
347347
needs: build
348348
# Run after builds complete (tests and universal are optional)
@@ -362,19 +362,13 @@ jobs:
362362
uses: actions/setup-node@v4
363363
with:
364364
node-version: '20'
365-
registry-url: 'https://registry.npmjs.org'
365+
registry-url: 'https://npm.pkg.github.com'
366+
scope: '@terraphim'
366367

367-
- name: Get publish token
368-
id: token
368+
- name: Verify GitHub token
369369
run: |
370-
# Use NPM_TOKEN from GitHub secrets (works for both npm and Bun)
371-
TOKEN="${{ secrets.NPM_TOKEN }}"
372-
if [[ -z "$TOKEN" ]]; then
373-
echo "No NPM_TOKEN available for publishing"
374-
exit 1
375-
fi
376-
echo "token=$TOKEN" >> $GITHUB_OUTPUT
377-
echo "Publish token configured"
370+
echo "Using GITHUB_TOKEN for GitHub Packages authentication"
371+
echo "Registry: https://npm.pkg.github.com"
378372
379373
- name: Download all artifacts
380374
uses: actions/download-artifact@v4
@@ -400,16 +394,18 @@ jobs:
400394
fi
401395
402396
- name: Configure package managers
397+
env:
398+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
403399
run: |
404-
# Configure npm (primary registry)
405-
echo "//registry.npmjs.org/:_authToken=${{ steps.token.outputs.token }}" > ~/.npmrc
406-
npm config set provenance true
407-
408-
# Configure Bun registry (if different token available)
409-
if [[ "${{ secrets.BUN_TOKEN }}" != "" && "${{ secrets.BUN_TOKEN }}" != "${{ steps.token.outputs.token }}" ]]; then
410-
echo "//registry.npmjs.org/:_authToken=${{ secrets.BUN_TOKEN }}" > ~/.bunfig.toml
411-
echo "[install.scopes]\n\"@terraphim\" = \"https://registry.npmjs.org/\"" >> ~/.bunfig.toml
412-
fi
400+
# Configure npm for GitHub Packages
401+
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > ~/.npmrc
402+
echo "@terraphim:registry=https://npm.pkg.github.com" >> ~/.npmrc
403+
404+
# Configure Bun registry for GitHub Packages
405+
cat > ~/.bunfig.toml << 'EOF'
406+
[install.scopes]
407+
"@terraphim" = { url = "https://npm.pkg.github.com", token = "$NODE_AUTH_TOKEN" }
408+
EOF
413409
414410
# Show current package info
415411
echo "Package information:"
@@ -458,43 +454,45 @@ jobs:
458454
echo "Platform packages created:"
459455
ls -la npm/ 2>/dev/null || echo "No npm/ directory"
460456
461-
- name: Publish to npm (works with Bun)
457+
- name: Publish to GitHub Packages (works with Bun)
462458
env:
463-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
459+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
464460
run: |
465461
if [[ "${{ inputs.dry_run }}" == "true" ]]; then
466462
echo "Dry run mode - checking package only"
467-
npm publish --dry-run --access public --tag ${{ steps.strategy.outputs.npm_tag }} --provenance --ignore-scripts
463+
npm publish --dry-run --access public --tag ${{ steps.strategy.outputs.npm_tag }} --ignore-scripts
468464
else
469-
echo "Publishing @terraphim/autocomplete to npm (Bun-compatible)"
465+
echo "Publishing @terraphim/autocomplete to GitHub Packages"
466+
echo "Registry: https://npm.pkg.github.com"
470467
echo "Tag: ${{ steps.strategy.outputs.npm_tag }}"
471468
472-
# Publish with OIDC provenance (no token needed - trusted publishing)
473-
npm publish --access public --tag ${{ steps.strategy.outputs.npm_tag }} --provenance --ignore-scripts
469+
# Publish to GitHub Packages
470+
npm publish --access public --tag ${{ steps.strategy.outputs.npm_tag }} --ignore-scripts
474471
475-
echo "Package published successfully! (Bun users can install with: bun add @terraphim/autocomplete)"
472+
echo "Package published successfully!"
473+
echo "Install with: npm install @terraphim/autocomplete --registry=https://npm.pkg.github.com"
474+
echo "Or with Bun: bun add @terraphim/autocomplete"
476475
fi
477476
478-
- name: Verify package for Bun users
477+
- name: Verify package on GitHub Packages
479478
if: inputs.dry_run != 'true'
479+
env:
480+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
480481
run: |
481-
echo "🔍 Verifying package for Bun users..."
482+
echo "Verifying package on GitHub Packages..."
482483
483-
# Wait a moment for npm registry to update
484-
sleep 30
484+
# Wait a moment for registry to update
485+
sleep 10
485486
486487
# Check if package is available
487488
PACKAGE_NAME="@terraphim/autocomplete"
488489
PACKAGE_VERSION=$(node -p "require('./package.json').version")
489490
490491
echo "Checking: $PACKAGE_NAME@$PACKAGE_VERSION"
491-
npm view $PACKAGE_NAME@$PACKAGE_VERSION || echo "⚠️ Package not immediately visible (may take a few minutes)"
492-
493-
echo "📊 Package verification completed for Bun users"
492+
npm view $PACKAGE_NAME@$PACKAGE_VERSION --registry=https://npm.pkg.github.com || echo "Package not immediately visible (may take a few minutes)"
494493
495-
# Test Bun installation
496-
echo "🧪 Testing Bun installation..."
497-
bunx pkg install $PACKAGE_NAME@$PACKAGE_VERSION --dry-run || echo "⚠️ Dry run failed (package may not be ready yet)"
494+
echo "Package verification completed"
495+
echo "GitHub Packages URL: https://github.com/terraphim/terraphim-ai/packages"
498496
499497
- name: Create Bun-specific GitHub Release
500498
if: startsWith(github.ref, 'refs/tags/') && inputs.dry_run != 'true'
@@ -553,8 +551,8 @@ jobs:
553551
- **Fast Test Execution**: Bun's test runner integration
554552
- **Enhanced Dependency Resolution**: Faster and more accurate
555553
556-
### 🔗 Links
557-
- [npm package](https://www.npmjs.com/package/@terraphim/autocomplete)
554+
### Links
555+
- [GitHub Package](https://github.com/terraphim/terraphim-ai/packages)
558556
- [Bun documentation](https://bun.sh/docs)
559557
- [Package Documentation](https://github.com/terraphim/terraphim-ai/tree/main/terraphim_ai_nodejs)
560558
@@ -567,8 +565,12 @@ jobs:
567565
- name: Notify on success
568566
if: inputs.dry_run != 'true'
569567
run: |
570-
echo "🎉 Bun publishing workflow completed successfully!"
571-
echo "📦 Package: @terraphim/autocomplete"
572-
echo "🏷️ Tag: ${{ steps.strategy.outputs.npm_tag }}"
573-
echo "🐢 Runtime: Bun-optimized"
574-
echo "📋 Version: $(node -p "require('./package.json').version")"
568+
echo "Publishing workflow completed successfully!"
569+
echo "Package: @terraphim/autocomplete"
570+
echo "Registry: GitHub Packages (npm.pkg.github.com)"
571+
echo "Tag: ${{ steps.strategy.outputs.npm_tag }}"
572+
echo "Version: $(node -p "require('./package.json').version")"
573+
echo ""
574+
echo "Install with:"
575+
echo " npm install @terraphim/autocomplete --registry=https://npm.pkg.github.com"
576+
echo " bun add @terraphim/autocomplete"

.github/workflows/publish-npm.yml

Lines changed: 41 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish Node.js Package to npm
1+
name: Publish Node.js Package to GitHub Packages
22

33
on:
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"

terraphim_ai_nodejs/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
{
22
"name": "@terraphim/autocomplete",
3-
"version": "1.0.0",
3+
"version": "1.3.1",
44
"description": "Fast autocomplete and knowledge graph functionality for Terraphim AI with native Node.js and WASM support",
55
"main": "index.js",
66
"types": "index.d.ts",
7+
"publishConfig": {
8+
"registry": "https://npm.pkg.github.com"
9+
},
710
"napi": {
811
"name": "terraphim_ai_nodejs",
912
"triples": {

0 commit comments

Comments
 (0)