Extra-Files¶
Track versions in arbitrary files using the extra-files configuration.
Configuration¶
{
"packages": {
".": {
"release-type": "simple",
"extra-files": [
{
"type": "generic",
"path": "README.md",
"glob": false
},
{
"type": "generic",
"path": "CONTRIBUTING.md",
"glob": false
}
]
}
}
}
Version Annotation¶
Files must contain the x-release-please-version annotation:
Release-please finds this comment and updates the version number on the same line.
Use Cases¶
| Use Case | File | Annotation |
|---|---|---|
| Documentation version | README.md |
Version: 1.0.0 # x-release-please-version |
| Distributed guidelines | CONTRIBUTING.md |
version: 1.0.0 # x-release-please-version |
| API version header | openapi.yaml |
version: '1.0.0' # x-release-please-version |
Distribution Side Effects
When extra-files are distributed to other repositories, version bumps trigger file changes. Use content comparison to avoid creating PRs for version-only changes.
Package Limitations¶
Release-please packages are directory-based. Each package path must point to a directory, not a single file.
What Doesn't Work¶
{
"packages": {
".": { "release-type": "simple" },
"CONTRIBUTING.md": {
"release-type": "simple",
"component": "contributing"
}
}
}
This fails because CONTRIBUTING.md is a file, not a directory.
Why This Limitation Exists¶
- Changelogs need location -
CHANGELOG.mdmust live somewhere - Version files need context -
package.json,Chart.yamlexist in directories - Monorepos are directories - Each package is a self-contained unit
The Solution¶
Use extra-files to track versions in single files:
{
"packages": {
".": {
"release-type": "simple",
"extra-files": [
{ "type": "generic", "path": "CONTRIBUTING.md", "glob": false }
]
}
}
}
The file shares the parent package's version. For independent versioning of single files, consider a directory wrapper or a different tool.
Related¶
- Release-Please Overview - Configuration basics
- Content Comparison - Skip version-only changes
- Customizing Release-Please - Official extra-files documentation