Publishing
tspub's publish command runs the full pipeline: build, check, version bump, changelog, git tag, and npm publish.
Quick Start
bash
# Publish a patch release
tspub publish patch
# Publish a minor release
tspub publish minor
# Publish a major release
tspub publish majorPrerequisite Gates
Before publishing begins, tspub validates 5 prerequisite gates:
- Clean git — Working directory has no uncommitted changes
- Correct branch — Current branch matches configured
publish.branch - Registry reachable — npm registry is accessible
- Authenticated — Valid npm credentials are available
- Check passes —
tspub checkfinds no errors
If any gate fails, publishing is aborted before any changes are made.
What Happens
- Build —
tspub buildruns first - Check —
tspub checkvalidates the package - Version — Bumps
package.jsonversion - Changelog — Generates/updates
CHANGELOG.md - Git — Commits, tags, and pushes
- Publish —
npm publishwith provenance
If any step fails, the process stops. Nothing gets published.
Rollback on Failure
If npm publish fails after git changes have been made:
- The git tag is deleted locally
- The version commit is reverted
package.jsonis restored to its previous state- A clear error message explains what happened
This ensures your repository stays in a consistent state even when npm has issues.
Configuration
typescript
// tspub.config.ts
export default {
publish: {
registry: "https://registry.npmjs.org",
access: "public",
provenance: true,
branch: "main", // Only allow publishing from main
changelogStyle: "conventional",
ci: {
enabled: true,
skipPush: false,
},
},
};Branch Protection
Restrict which branches can publish:
typescript
export default {
publish: {
branch: ["main", "release/*"],
},
};Pre-release
bash
tspub publish premajor --preid beta
# 1.0.0 → 2.0.0-beta.0