Overview of Cngpac package release manager
package.json, tagging, pushing, publishing to NPM, and creating GitHub releases. The pipeline is fully composable through plugins, allowing developers to swap or extend any stage of the process.website·Indexed 30 days ago
https://cngpac.devA highly configurable package release manager for npm that handles the entire release lifecycle. Cngpac uses a system of changenotes and a versioning pipeline to automate version bumping, changelog generation, and publishing via built-in publishers (like npm) and releasers (like GitHub).
package.json, tagging, pushing, publishing to NPM, and creating GitHub releases. The pipeline is fully composable through plugins, allowing developers to swap or extend any stage of the process.package.json, tagging, pushing to git, publishing to NPM, and creating GitHub releases. The pipeline is pluggable, allowing users to swap or extend any stage of the process.# Command Reference
init # Scaffold config and CI workflow
change # (Alias: cng) Add a new changenote
commit # Commit a staged changenote using its title
prepare # (Alias: prep) Calculate version and write prepare config
version # (Alias: vrsn) Bump version, generate changelog, publish, and release
reprepare # (Alias: reprep) Reattempt a failed release
preview # Generate changelog preview and open in browserWhen cngpac preview is executed, the tool performs the following steps:
.changenotes/.package.json.You can create a custom releaser by implementing the ReleaserPlugin type. The plugin function receives an object containing the following properties:
versionBump (VersionBump): Information about the version bump.changelog (string): The generated changelog in markdown format.tagName (string): The name of the git tag.config (CngpacConfig): The complete Cngpac configuration object.import type { ReleaserPlugin } from "cngpac";
const myReleaser: ReleaserPlugin = async ({ versionBump, changelog, tagName, config }) => {
// ...release logic...
};version command. Their primary purpose is to handle post-publishing tasks, such as creating a release entry on platforms like GitHub.version command. They are used to publish packages to registries or other distribution channels. The built-in createNpmPublisher plugin allows publishing specifically to the npm registry.To use Cngpac, you must meet the following requirements:
package.json fileThe cngpac init command automatically detects the package manager using npm_config_user_agent and configures the generated .github/workflows/version.yml with the appropriate install commands and runtime actions:
npm ci and actions/setup-node@v6.pnpm install --frozen-lockfile and actions/setup-node@v6.yarn install --frozen-lockfile and actions/setup-node@v6.bun install --frozen-lockfile and oven-sh/setup-bun@v2.Run the initialization command from the project root to set up the release pipeline. Cngpac auto-detects the GitHub repository from package.json and adapts the CI workflow based on the detected package manager (npm, pnpm, yarn, or bun).
This process creates two files:
cngpac.config.ts: Used for release pipeline configuration..github/workflows/version.yml: The CI workflow triggered by prepare.json.npx cngpac initReleaserPlugin type. They run after publishers during the version command and receive a context object containing version bump details, the generated changelog, the git tag name, and the full project configuration.import type { ReleaserPlugin } from "cngpac";
const myReleaser: ReleaserPlugin = async ({ versionBump, changelog, tagName, config }) => {
// Implement release logic here (e.g., calling an external API)
};
export default defineConfig({
// ...
releasers: [myReleaser],
});Cngpac follows a four-phase release flow:
cngpac init to create cngpac.config.ts and the GitHub Actions workflow.cngpac change to create a changenote and cngpac commit to stage/commit it using the changenote title.cngpac prepare release to calculate the next semantic version and generate prepare.json. Push this file to the main branch to trigger CI. For pre-releases, use prepare prerelease [tag], prepatch, preminor, or premajor.version command with flags to automate the release process.# Setup
cngpac init
# Development
cngpac change
cngpac commit
# Release Prep
cngpac prepare release
# OR for pre-release
cngpac prepare prerelease beta
# CI Command
cngpac version --commit --tag --push --publish --release