Forgejo runners use the github.* context namespace. Using gitea.ref_name causes validation errors even when the input is explicitly provided.
108 lines
2.6 KiB
Markdown
108 lines
2.6 KiB
Markdown
# Generate Changelog
|
|
|
|
Generate a changelog from git history between two tags, grouped by [conventional commit](https://www.conventionalcommits.org/) types. Designed for use in Forgejo Actions release workflows.
|
|
|
|
## Features
|
|
|
|
- **Automatic tag detection**: Finds the previous tag automatically, or accepts a manual override
|
|
- **Conventional commit grouping**: Categorizes commits by type (`feat`, `fix`, `chore`, `refactor`, etc.)
|
|
- **Customizable categories**: Define your own commit type to section header mapping via JSON
|
|
- **Compare link**: Automatically adds a full changelog link when running on Forgejo
|
|
|
|
## Usage
|
|
|
|
```yaml
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0 # Required: full history needed for tag detection
|
|
|
|
- name: Generate changelog
|
|
id: changelog
|
|
uses: your-org/generate-changelog@v1
|
|
with:
|
|
tag: ${{ github.ref_name }}
|
|
|
|
- name: Create release
|
|
uses: actions/forgejo-release@v2
|
|
with:
|
|
body: ${{ steps.changelog.outputs.changelog }}
|
|
```
|
|
|
|
## Inputs
|
|
|
|
| Input | Description | Required | Default |
|
|
|-------|-------------|----------|---------|
|
|
| `tag` | The current release tag | Yes | `${{ github.ref_name }}` |
|
|
| `previous-tag` | Override for the previous tag. Auto-detected if omitted | No | |
|
|
| `categories` | JSON mapping of commit prefixes to section headers | No | See below |
|
|
|
|
### Default categories
|
|
|
|
```json
|
|
{
|
|
"feat": "✨ Features",
|
|
"fix": "🐛 Bug Fixes",
|
|
"refactor": "♻️ Refactoring",
|
|
"chore": "🔧 Chores"
|
|
}
|
|
```
|
|
|
|
Commits that don't match any category are listed under **📝 Other Changes**.
|
|
|
|
## Outputs
|
|
|
|
| Output | Description |
|
|
|--------|-------------|
|
|
| `changelog` | The generated changelog as a markdown string |
|
|
|
|
## Examples
|
|
|
|
### Custom categories
|
|
|
|
```yaml
|
|
- name: Generate changelog
|
|
id: changelog
|
|
uses: your-org/generate-changelog@v1
|
|
with:
|
|
tag: ${{ github.ref_name }}
|
|
categories: '{"feat": "New Features", "fix": "Bug Fixes", "docs": "Documentation", "perf": "Performance"}'
|
|
```
|
|
|
|
### Manual tag override
|
|
|
|
```yaml
|
|
- name: Generate changelog
|
|
id: changelog
|
|
uses: your-org/generate-changelog@v1
|
|
with:
|
|
tag: v2.0.0
|
|
previous-tag: v1.0.0
|
|
```
|
|
|
|
### Sample output
|
|
|
|
```markdown
|
|
# Release v1.2.0
|
|
|
|
## ✨ Features
|
|
|
|
- add user authentication (a1b2c3d)
|
|
- add rate limiting to API (e4f5g6h)
|
|
|
|
## 🐛 Bug Fixes
|
|
|
|
- handle empty input gracefully (i7j8k9l)
|
|
|
|
---
|
|
**Full Changelog**: https://forgejo.example.com/org/repo/compare/v1.1.0...v1.2.0
|
|
```
|
|
|
|
## Requirements
|
|
|
|
- The checkout step **must** use `fetch-depth: 0` so that the full git history and tags are available.
|
|
- `jq` is recommended on the runner for category parsing. A pure bash fallback is included.
|
|
|
|
## License
|
|
|
|
MIT
|