mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-02-09 13:36:56 +02:00
feat: save changelog to dist
This feature will save a CHANGELOG.md into the dist folder. This file can then be included in docker images and etc. closes #655
This commit is contained in:
parent
ce96cba4e1
commit
16c4d096a5
@ -4,10 +4,13 @@ package changelog
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/apex/log"
|
||||
"github.com/goreleaser/goreleaser/context"
|
||||
"github.com/goreleaser/goreleaser/internal/git"
|
||||
"github.com/goreleaser/goreleaser/pipeline"
|
||||
@ -39,7 +42,9 @@ func (Pipe) Run(ctx *context.Context) error {
|
||||
return err
|
||||
}
|
||||
ctx.ReleaseNotes = fmt.Sprintf("## Changelog\n\n%v", strings.Join(entries, "\n"))
|
||||
return nil
|
||||
var path = filepath.Join(ctx.Config.Dist, "CHANGELOG.md")
|
||||
log.WithField("changelog", path).Info("writing")
|
||||
return ioutil.WriteFile(path, []byte(ctx.ReleaseNotes), 0644)
|
||||
}
|
||||
|
||||
func checkSortDirection(mode string) error {
|
||||
|
@ -1,6 +1,8 @@
|
||||
package changelog
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/apex/log"
|
||||
@ -27,7 +29,7 @@ func TestSnapshot(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestChangelog(t *testing.T) {
|
||||
_, back := testlib.Mktmp(t)
|
||||
folder, back := testlib.Mktmp(t)
|
||||
defer back()
|
||||
testlib.GitInit(t)
|
||||
testlib.GitCommit(t, "first")
|
||||
@ -42,6 +44,7 @@ func TestChangelog(t *testing.T) {
|
||||
testlib.GitCommit(t, "this is not a Merge pull request")
|
||||
testlib.GitTag(t, "v0.0.2")
|
||||
var ctx = context.New(config.Project{
|
||||
Dist: folder,
|
||||
Changelog: config.Changelog{
|
||||
Filters: config.Filters{
|
||||
Exclude: []string{
|
||||
@ -63,6 +66,10 @@ func TestChangelog(t *testing.T) {
|
||||
assert.NotContains(t, ctx.ReleaseNotes, "ignored")
|
||||
assert.NotContains(t, ctx.ReleaseNotes, "cArs")
|
||||
assert.NotContains(t, ctx.ReleaseNotes, "from goreleaser/some-branch")
|
||||
|
||||
bts, err := ioutil.ReadFile(filepath.Join(folder, "CHANGELOG.md"))
|
||||
assert.NoError(t, err)
|
||||
assert.NotEmpty(t, string(bts))
|
||||
}
|
||||
|
||||
func TestChangelogSort(t *testing.T) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user