class ReleaseManager

The ReleaseManager orchestrates all aspects of the release process including:

  • Version calculation based on conventional commits
  • File updates using intelligent handlers or custom patterns
  • Changelog generation following Keep a Changelog format
  • Git operations (tagging, pushing)
  • GitHub release creation
  • Documentation generation

Release Flow

  1. Environment Validation - Checks git repository, uncommitted changes
  2. Version Calculation - Analyzes commits to determine version bump
  3. File Updates - Updates version in configured files
  4. Changelog Generation - Creates/updates CHANGELOG.md
  5. Git Operations - Commits changes and creates tag
  6. GitHub Release - Creates release on GitHub (if configured)
  7. Documentation - Generates docs (if configured)

Examples

Basic usage with automatic version detection

const config: NagareConfig = {
  project: { name: "My App", repository: "https://github.com/user/app" },
  versionFile: { path: "./version.ts", template: "typescript" }
};

const manager = new ReleaseManager(config);
const result = await manager.release(); // Auto-detects version bump
if (result.success) {
  console.log(`Released version ${result.version}`);
}

CI/CD integration with skip confirmation

const config: NagareConfig = {
  project: { name: "My App", repository: "https://github.com/user/app" },
  versionFile: { path: "./version.ts", template: "typescript" },
  options: {
    skipConfirmation: true,  // No interactive prompts
    logLevel: LogLevel.DEBUG // Verbose output for CI logs
  }
};

const manager = new ReleaseManager(config);
const result = await manager.release("patch");

With intelligent file handlers (v1.1.0+)

const config: NagareConfig = {
  project: { name: "My App", repository: "https://github.com/user/app" },
  versionFile: { path: "./version.ts", template: "typescript" },
  updateFiles: [
    { path: "./deno.json" },     // Auto-detected JSON handler
    { path: "./package.json" },  // Auto-detected JSON handler
    { path: "./README.md" },     // Auto-detected Markdown handler
    {
      path: "./custom.yaml",     // Custom pattern for edge cases
      patterns: {
        version: /^version:\s*['"]?([^'"]+)['"]?$/m
      }
    }
  ]
};

Dry run mode for testing

const config: NagareConfig = {
  project: { name: "My App", repository: "https://github.com/user/app" },
  versionFile: { path: "./version.ts", template: "typescript" },
  options: { dryRun: true }  // Preview without making changes
};

const manager = new ReleaseManager(config);
const result = await manager.release();
// Shows what would happen without actually doing it

Custom commit type mappings

const config: NagareConfig = {
  project: { name: "My App", repository: "https://github.com/user/app" },
  versionFile: { path: "./version.ts", template: "typescript" },
  commitTypes: {
    feat: "added",      // New features
    fix: "fixed",       // Bug fixes
    perf: "improved",   // Performance improvements
    docs: "documented", // Documentation changes
    enhance: "enhanced" // Custom type
  }
};

Constructors

ReleaseManager(
config: NagareConfig,
deps?: ReleaseManagerDeps
)

Constructor with optional dependency injection

Static Methods

validateConfig(config: NagareConfig): { valid: boolean; errors: string[]; }

Validates required fields and configuration consistency. Useful for checking configuration before creating a ReleaseManager.

Methods

Get the current configuration

release(bumpType?: BumpType): Promise<ReleaseResult>

Coordinates the entire release workflow:

  1. Validates environment and configuration
  2. Analyzes commits to determine version bump
  3. Generates release notes
  4. Updates configured files (with preview in dry-run mode)
  5. Creates git commit and tag
  6. Pushes to remote repository
  7. Creates GitHub release (if configured)
  8. Generates documentation (if enabled)