This guide explains how to publish the component packages from this monorepo to GitHub Packages.
-
GitHub Personal Access Token (PAT)
- Go to GitHub Settings → Developer settings → Personal access tokens → Tokens (classic)
- Generate a new token with the following scopes:
write:packages- Upload packages to GitHub Package Registryread:packages- Download packages from GitHub Package Registrydelete:packages- Delete packages from GitHub Package Registry (optional)
- Save your token securely
-
Authentication Setup
Set your GitHub token as an environment variable:
# Linux/macOS export NODE_AUTH_TOKEN=your_github_token_here # Windows (Command Prompt) set NODE_AUTH_TOKEN=your_github_token_here # Windows (PowerShell) $env:NODE_AUTH_TOKEN="your_github_token_here"
Alternatively, create a
.npmrcfile in your home directory://npm.pkg.github.com/:_authToken=YOUR_GITHUB_TOKEN
All packages are configured to publish to GitHub Packages with the following settings:
- Scope:
@banegasn - Registry:
https://npm.pkg.github.com - Access:
public
Ensure all packages are built before publishing:
pnpm buildUse the provided version scripts to bump versions across all packages:
# Patch version (1.0.0 → 1.0.1)
pnpm version:patch
# Minor version (1.0.0 → 1.1.0)
pnpm version:minor
# Major version (1.0.0 → 2.0.0)
pnpm version:majorOr update versions manually in each package's package.json.
pnpm publish:packagesThis command will:
- Build all packages using Turbo
- Publish all packages in the
packages/directory - Skip git checks (useful for CI/CD)
To publish a specific package:
# From the root directory
pnpm --filter @banegasn/example-component publish
# Or navigate to the package directory
cd packages/example-component
pnpm publishUsers can install your packages by first configuring their .npmrc:
@banegasn:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=GITHUB_TOKEN
Then install with:
npm install @banegasn/example-component
# or
pnpm add @banegasn/example-component
# or
yarn add @banegasn/example-componentIf you get 401 Unauthorized or 403 Forbidden errors:
- Verify your token has the correct scopes
- Check that
NODE_AUTH_TOKENenvironment variable is set - Ensure the package name scope matches your GitHub username/org (
@banegasn)
GitHub Packages doesn't allow overwriting existing package versions. You must:
- Bump the version number
- Or delete the existing version from GitHub (requires
delete:packagesscope)
If packages aren't publishing to the correct registry:
- Check
publishConfig.registryin each package'spackage.json - Verify the
.npmrcconfiguration - Ensure you're authenticated with the correct registry
Published packages are set to public access. To view them:
- Go to your GitHub profile
- Click on "Packages" tab
- You should see
@banegasn/example-componentand@banegasn/svelte-components
- Semantic Versioning: Follow semver (major.minor.patch)
- Changelog: Keep a CHANGELOG.md for each package
- Git Tags: Tag releases in git:
git tag v1.0.0 && git push --tags - Test Before Publishing: Always build and test before publishing
- README Updates: Keep package READMEs up to date with usage examples
# Build all packages
pnpm build
# Bump versions
pnpm version:patch # 1.0.0 → 1.0.1
pnpm version:minor # 1.0.0 → 1.1.0
pnpm version:major # 1.0.0 → 2.0.0
# Publish all packages
pnpm publish:packages
# Publish single package
pnpm --filter @banegasn/example-component publish