Changie utilizes go template and sprig functions for formatting. In addition to that, a few template functions are available when working with changes.
When batching changes into a version, the headers and footers are placed as such:
All elements are optional and will be added together if all are provided.
type: string
| default: ""
| optional
Filepath for your version header file relative to unreleasedDir
.
It is also possible to use the --header-path
parameter when using the batch command.
type: string
| default: ""
| optional
Filepath for your version header file relative to unreleasedDir
.
It is also possible to use the --footer-path
parameter when using the batch command.
type: string
| default: ""
| optional
Format string to use directly in the version header.
type: string
| default: ""
| optional
Format string to use directly in the version footer.
All version header and footers, whether from file or by format string, include the same data object you can use for custom values.
Arguments
Field | Type | Description |
---|---|---|
Time | time.Time | Current time |
Version | string | Version releasing now |
PreviousVersion | string | Previously released version |
Major | int | Current version major value |
Minor | int | Current version minor value |
Patch | int | Current version patch value |
Prerelease | string | Current version prerelease value |
Metadata | string | Current version metadata value |
Changes | []Change | Change Type |
Below are all the custom template functions available for headers and footers.
For functions that return a slice you can use the range action to loop through the values.
returns: int
| requires: value and items
Get the number of occurances of value in items.
Value is a string
, items is a []string
.
Can be used in a few functions below.
Example: Owner made {{customs .Changes "Author" | count "owner"}} changes
returns: []string
| requires: changes
Get all the components for our changes.
Example: {{components .Changes | uniq | len}} components updated
returns: []string
| requires: changes
Get all the kinds for our changes.
Example: {{kinds .Changes | count "Fixed"}} fixed issues this release
returns: []string
| requires: changes
Get all the bodies for our changes.
Example: newest change {{bodies .Changes | first}}
returns: []time.Time
| requires: changes
Get all the timestamps for the changes.
Example: oldest change {{times .Changes | last}}
returns: []string
| requires: changes and key
Get all values with a key in the changes. Will return an error if that key is missing from any change.
Example: {{range (customs .Changes "Issue")}}* {{.}}{{end}}
Display all unique contributors from a custom choice.
# config yaml
custom:
- key: Author
type: string
minLength: 3
footerFormat: |
### Contributors
{{- range (customs .Changes "Author" | uniq) }}
* [{{.}}](https://github.com/{{.}})
{{- end}}