# Release history

{{- $releases := gitHubListReleases "twpayne/chezmoi" }}
{{- $latestRelease := index $releases 0 }}

[Upcoming changes](https://github.com/twpayne/chezmoi/compare/{{ $latestRelease.Name }}...master)

{{- $lastReleaseIndex := sub (len $releases) 1 }}
{{- range $index, $release := $releases }}

## [{{ $release.Name | trimPrefix "v" }}]({{ $release.HTMLURL }}) ({{ $release.PublishedAt | gitHubTimestampFormat "2006-01-02" }})

{{ $release.Body
   | replaceAllRegex "(?m)^#+ (Changelog\\r?|What's Changed)$" ""
   | replaceAllRegex "(?m)^#+ (.*)\\r?$" "\n\n$1\n"
   | replaceAllRegex "\\*\\*(Full Changelog)\\*\\*.*\n" ""
   | replaceAllRegex "(https://github\\.com/twpayne/chezmoi/compare/(\\S+))" "[`$2`]($1)"
   | replaceAllRegex "@(\\S+)" "[**$0**](https://github.com/$1)"
   | replaceAllRegex "pull request #(\\d+)" "pull request https://github.com/twpayne/chezmoi/pull/$1"
   | replaceAllRegex "\\(#(\\d+)[)]" "(https://github.com/twpayne/chezmoi/pull/$1)"
   | replaceAllRegex "(https://github\\.com/twpayne/chezmoi/pull/(\\d+))" "[#$2]($1)"
   | replaceAllRegex "(?m)^([0-9a-f]{7,})" "* $1"
   | replaceAllRegex "(?m)^\\* (([0-9a-f]{7})[0-9a-f]*)" "* [`$2`](https://github.com/twpayne/chezmoi/commit/$1)"
   | replaceAllRegex "\\r\\n" "\\n"
   | trim
   | default "Internal changes only"
}}

{{- if ne $index $lastReleaseIndex }}
{{-   $prevRelease := index $releases (add $index 1) }}

Full changelog: [{{ $prevRelease.Name }}...{{ $release.Name }}](https://github.com/twpayne/chezmoi/compare/{{ $prevRelease.Name }}...{{ $release.Name }})
{{- end }}

{{- end }}
