Overview
Context loading allows you to export git-cliff’s internal changelog context as JSON, modify it with external tools, and then load it back to generate customized changelogs. This enables powerful programmatic workflows and integrations.Basic workflow
The typical context loading workflow involves three steps:- Export context to JSON
- Process/modify the context
- Load context and generate changelog
Export context
Generate a JSON file containing the changelog context:Process context
Modify the context using any tool that can manipulate JSON (jq, Python, Node.js, etc.).Load context
Generate a changelog from the modified context:JSON context structure
The context JSON contains all the data git-cliff uses to generate changelogs.Commit structure
Each commit in the context has this structure:Adding custom metadata
Use theextra field to add arbitrary metadata to commits or releases:
Programmatic usage
Filter commits with jq
Remove commits from specific authors:Add metadata with Python
Enrich commits with external data:Process with Node.js
Group commits by custom criteria:Advanced use cases
Multi-language changelogs
Generate changelogs in multiple languages:Changelog aggregation
Combine changelogs from multiple repositories:Conditional changelog sections
Add context-based conditional rendering:External approval workflow
Export, review, approve, and generate:Integration examples
GitHub Actions workflow
Pipeline with validation
Best practices
- Validate context after modification: Ensure your modifications produce valid JSON and maintain the expected structure.
- Version control context files: Track context files in your repository for reproducibility.
- Use schema validation: Validate context against a JSON schema before loading:
- Keep transformations simple: Complex transformations should be broken into smaller, testable steps.
-
Document custom fields: If you add custom fields to
extra, document what they mean and how they’re used in templates.