Skip to content

Latest commit

 

History

History
255 lines (184 loc) · 6.88 KB

File metadata and controls

255 lines (184 loc) · 6.88 KB

🎉 Publishing Setup Complete!

Archetype Engine is now configured with automated npm publishing using OIDC Trusted Publishing.


✅ What We Accomplished

Phase 1: Code Quality (Complete)

  • Code Quality Score: 78/100 → 92/100
  • Eliminated technical debt
  • Improved type safety
  • Created Architecture Decision Records
  • Updated all project URLs and metadata
  • All 209 tests passing

Phase 2: Automated Publishing (Complete)

  • ✅ Configured npm Trusted Publisher on npmjs.com
  • ✅ Created .github/workflows/publish.yml with OIDC authentication
  • ✅ Fixed npm version requirement (npm 9.5.0+ for OIDC)
  • ✅ Successfully published v2.0.1 with provenance
  • ✅ Created automatic GitHub releases
  • ✅ Comprehensive documentation written

🚀 Publishing is Now Fully Automated

How to Release a New Version

# 1. Make your changes and commit
git add .
git commit -m "feat: new feature"
git push origin main

# 2. Update CHANGELOG.md
# (edit the file with your changes)

# 3. Bump version and release
npm version patch   # or minor, or major
git push origin main --tags

# Done! GitHub Actions will:
# ✓ Run all tests
# ✓ Build the package
# ✓ Publish to npm with provenance
# ✓ Create GitHub release

🔒 Security Features

OIDC Trusted Publishing

  • No npm tokens - Zero secrets to manage or rotate
  • Automatic provenance - npm verifies build authenticity
  • Short-lived credentials - Tokens expire immediately after use
  • Audit trail - Every publish linked to exact GitHub commit

Published With

published just now by GitHub Actions <npm-oidc-no-reply@github.com>

This proves the package was published via OIDC, not with a user token.

Provenance Available

Users can verify package authenticity: https://www.npmjs.com/package/archetype-engine?activeTab=provenance


📊 Current Status

Published Versions

  • v2.0.0 - Initial release (manual publish)
  • v2.0.1 - First automated release with OIDC (SUCCESS!)

Package Info

  • Name: archetype-engine
  • Latest: 2.0.1
  • License: MIT
  • Bundle Size: 91.7 kB (compressed), 424.8 kB (unpacked)
  • Dependencies: 4 runtime deps (lean)
  • Author: IFAKA
  • Provenance: ✅ SLSA provenance enabled

Links


🔧 The Solution

The key to making OIDC work was:

  1. Configure trusted publisher on npmjs.com:

    • Repository: IFAKA/archetype-engine
    • Workflow: publish.yml
  2. Use npm 9.5.0+ with --provenance flag:

    npx --yes npm@latest publish --provenance --access public
  3. Set proper GitHub Actions permissions:

    permissions:
      contents: write  # For creating releases
      id-token: write  # For OIDC authentication
  4. Don't set registry-url in setup-node (it creates conflicting auth)


📚 Documentation Created

All guides are available in .github/:

File Purpose
SETUP_TOKEN.md One-time trusted publisher setup
PUBLISHING_GUIDE.md Complete publishing workflow guide
workflows/release.md Quick command reference
NEXT_STEPS.md Step-by-step guide for what to do next

🎯 Key Takeaways

What Worked

  • ✅ npm Trusted Publishing (OIDC) is more secure than tokens
  • ✅ GitHub Actions + npm 9.5.0+ = zero-config authentication
  • ✅ Automatic provenance builds user trust
  • ✅ No maintenance needed (no token rotation)

Lessons Learned

  1. npm version matters - OIDC requires npm 9.5.0+
  2. Keep it simple - Don't set registry-url when using OIDC
  3. Use latest npm - npx npm@latest ensures compatibility
  4. Provenance is free - Just add --provenance flag

Common Pitfalls Avoided

  • ❌ Using registry-url in setup-node (creates conflicting auth)
  • ❌ Trying to use old npm version (lacks OIDC support)
  • ❌ Rerunning workflow without updating code (git tag points to old commit)
  • ❌ Not configuring trusted publisher first (causes 404 errors)

🧪 Verification

To verify the setup is working:

# Check npm package
npm info archetype-engine

# Should show:
# - latest: 2.0.1
# - published by: GitHub Actions <npm-oidc-no-reply@github.com>

# Check provenance
npm view archetype-engine@2.0.1 --json | grep provenance

# Should show SLSA provenance URL

# Test installation
npx create-next-app test-app
cd test-app
npm install archetype-engine@latest
npx archetype init --help

🎓 Understanding OIDC Flow

Here's what happens when you push a version tag:

  1. Tag Push → GitHub Actions workflow triggers
  2. Workflow Runs with id-token: write permission
  3. GitHub generates signed OIDC token with claims:
    • Repository: IFAKA/archetype-engine
    • Workflow: publish.yml
    • Commit SHA, branch, actor, etc.
  4. npm CLI detects OIDC environment (via --provenance)
  5. npm requests token exchange from GitHub OIDC provider
  6. npm validates token signature and trusted publisher config
  7. npm issues temporary publish credentials
  8. Package publishes with automatic provenance
  9. Credentials expire immediately (can't be reused)

Security Benefit: Even if someone captures the workflow logs, there's nothing useful to steal.


📈 Next Steps (Optional Improvements)

Now that publishing is automated, consider:

  1. Automate Changelog

    • Use conventional commits
    • Auto-generate changelog from commits
    • Tools: conventional-changelog, release-please
  2. Add Release Notes Template

    • Standardize what goes in each release
    • Highlight breaking changes automatically
  3. Pre-release Channels

    • Set up alpha/beta dist-tags
    • Allow users to test features early
  4. Download Badge

    • Add npm download badge to README
    • Track package adoption
  5. Bundle Size Monitoring

    • Track bundle size over time
    • Alert on significant increases

🙏 Credits

Solved By:

  • OIDC Trusted Publishing configuration on npmjs.com
  • Using npm@latest (v10+) with --provenance flag
  • Proper GitHub Actions permissions (id-token: write)
  • Removing conflicting registry-url configuration

Date: December 24, 2025

First Automated Release: v2.0.1

Status: ✅ Production Ready


🔗 Important Links


Congratulations! Your package now has enterprise-grade publishing automation. 🎉