release-police
v1.0.0
Published
Interactive release workflow with configurable steps
Maintainers
Readme
release-police
Interactive release workflow CLI with configurable steps. Automates version bumping, testing, and publishing with beautiful prompts.
Features
- Interactive prompts with beautiful CLI UI
- Configurable via TypeScript, JavaScript, or package.json
- Dry-run mode to preview changes
- Skip individual steps via CLI flags
- Automatic remote sync detection
- Customizable test, build, and changelog commands
- GitHub release creation (draft or published)
Installation
npm install -D release-policeOr run directly:
npx release-policeQuick Start
# Run with defaults
npx release-police
# Preview what would happen
npx release-police --dry-run
# Skip tests
npx release-police --skip-tests
# Pre-select version type
npx release-police --version-type minorConfiguration
Generate a config file with all options:
npx release-police initOr create release.config.ts manually:
import { defineConfig } from 'release-police';
export default defineConfig({
// Branches that allow releases (default: ['main', 'master'])
releaseBranches: ['main', 'master', 'release/*'],
// Commands to run (set to null to skip)
commands: {
test: 'npm run test:all', // default
install: 'npm install', // run after pulling
build: null, // optional pre-release build
changelog: null, // optional changelog generation
},
// Git settings
git: {
pullStrategy: 'rebase', // 'rebase' | 'merge' | 'ff-only'
requireCleanWorkingDir: true,
},
// GitHub integration (optional)
github: {
release: false, // Create GitHub release after push
draft: true, // Create as draft
generateNotes: true, // Auto-generate release notes
},
// Enable/disable steps
steps: {
checkBranch: true,
syncRemote: true,
runTests: true,
commitChanges: true,
versionBump: true,
push: true,
githubRelease: false, // Matches github.release
},
});Alternative: Configure in package.json
For simple configurations, add to your package.json:
{
"releasePolice": {
"commands": {
"test": "npm test"
},
"releaseBranches": ["main"]
}
}CLI Options
| Command/Flag | Description |
|------|-------------|
| init | Create a release.config.ts file with all options |
| --dry-run | Preview what would happen without making changes |
| --skip-tests | Skip the test step |
| --skip-sync | Skip remote sync step |
| --skip-push | Skip push to remote (local version bump only) |
| --github-release | Create GitHub release after push |
| --version-type <type> | Pre-select version bump: patch, minor, or major |
| -c, --config <path> | Path to config file |
Workflow Steps
- Branch Check - Verify you're on an allowed release branch
- Remote Sync - Fetch and pull latest changes if behind
- Run Tests - Execute your test command
- Commit Changes - Stage and commit uncommitted changes
- Version Bump - Interactive version selection (patch/minor/major)
- Push - Push commits and tags to remote
- GitHub Release - Create GitHub release (optional)
Programmatic Usage
import { runRelease, defineConfig, loadConfig } from 'release-police';
// Run with CLI options
await runRelease({
dryRun: true,
skipTests: false,
});
// Load and inspect config
const config = await loadConfig();
console.log(config.commands.test);Examples
Custom test command
// release.config.ts
import { defineConfig } from 'release-police';
export default defineConfig({
commands: {
test: 'npm run lint && npm run test:unit && npm run test:e2e',
},
});Skip changelog (use AI-generated instead)
// release.config.ts
import { defineConfig } from 'release-police';
export default defineConfig({
commands: {
changelog: null, // Skip - generate with Claude Code instead
},
});CI-friendly release
# In CI, skip interactive prompts
npx release-police --version-type patch --skip-pushGitHub Release Integration
Create a GitHub release automatically after pushing:
// release.config.ts
import { defineConfig } from 'release-police';
export default defineConfig({
github: {
release: true, // Enable GitHub release creation
draft: true, // Create as draft (recommended)
generateNotes: true, // Auto-generate notes from commits
},
});Or via CLI flag:
npx release-police --github-releaseRequirements: GitHub CLI must be installed and authenticated (gh auth login).
Why draft by default?
- Review and edit release notes before publishing
- Won't accidentally trigger CD workflows
- Matches the safe, interactive philosophy of release-police
Development
npm run build # Build the package
npm run test # Run tests
npm run lint # Lint code
npm run typecheck # Type checkLicense
MIT © oharu121
