This guide explains how to publish the EnvGuard CLI package to npm.
- npm Account: You need an npm account. Create one at https://www.npmjs.com/signup
- npm Login: You must be logged in to npm:
npm login
- Access Rights: For scoped packages (@envguard/cli), ensure you have access or the package is public
Before publishing, ensure:
- All tests pass:
pnpm test - Type checking passes:
pnpm typecheck - Build succeeds:
pnpm build - README.md is up to date
- CHANGELOG.md is updated (if exists)
- Version number is bumped in package.json
- Git working directory is clean
- All changes are committed
Follow Semantic Versioning:
- Patch (0.1.0 → 0.1.1): Bug fixes
- Minor (0.1.0 → 0.2.0): New features, backward compatible
- Major (0.1.0 → 1.0.0): Breaking changes
Update version:
cd packages/cli
# Automatically bump version
npm version patch # for bug fixes
npm version minor # for new features
npm version major # for breaking changes
# Or manually edit package.jsonTest what will be published without actually publishing:
cd packages/cli
# Show what files will be included
pnpm pack:check
# Create actual tarball (without publishing)
npm packThis creates a .tgz file you can inspect.
cd packages/clinpm whoamiIf not logged in:
npm login# Type check
pnpm typecheck
# Build
pnpm build
# Verify package contents
pnpm pack:check# For first-time publish or public scoped package
npm publish --access public
# For subsequent publishes
npm publishCheck that the package is available:
# View on npm
open https://www.npmjs.com/package/@envguard/cli
# Or install it globally to test
npm install -g @envguard/cli
envg --versionFor pre-release versions:
# Update version to beta (e.g., 0.2.0-beta.0)
npm version prerelease --preid=beta
# Publish with beta tag
npm publish --tag beta --access publicUsers can install beta with:
npm install -g @envguard/cli@betaThe latest tag is automatically assigned to the most recent stable publish. To explicitly set:
npm publish --tag latest --access publicAfter publishing:
-
Create Git Tag:
git tag v0.1.0 git push origin v0.1.0
-
Create GitHub Release:
- Go to: https://github.com/amannirala13/envguard/releases/new
- Select the tag you just created
- Add release notes
-
Announce: Share on Twitter, Discord, etc.
-
Monitor: Check npm download stats and GitHub issues
Solution: The package name might be taken, or you need access. For scoped packages, ensure you use --access public.
Solution: You forgot to bump the version. Update package.json version number.
Solution: Wait a few minutes. npm can take time to propagate. Clear npm cache:
npm cache clean --forceIf you published wrong files:
- Unpublish within 24 hours (if no one has installed it):
npm unpublish @envguard/cli@<version>
- Fix the issue
- Bump version and republish
Note: npm does not allow unpublishing after 24 hours or if downloads occurred.
For automated publishing with GitHub Actions, see the root repository's CI/CD setup using changesets:
# At monorepo root
pnpm changeset
pnpm changeset:version
pnpm ci:publishCheck package visibility:
npm view @envguard/cliMake package public (if it was accidentally private):
npm access public @envguard/cli# Check what's in your package
npm pack --dry-run
# View package info on npm
npm view @envguard/cli
# View all versions
npm view @envguard/cli versions
# Deprecate a version
npm deprecate @envguard/cli@<version> "Reason for deprecation"
# View download stats
npm info @envguard/cliIf you encounter issues:
- npm documentation: https://docs.npmjs.com/
- GitHub issues: https://github.com/amannirala13/envguard/issues