1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-08 03:31:59 +02:00

fix: docker images on release notes

This commit is contained in:
Carlos Alexandro Becker 2017-12-17 23:11:17 -02:00
parent 9cfa2c35ce
commit 64485c9c37
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
4 changed files with 21 additions and 12 deletions

View File

@ -29,8 +29,6 @@ type Context struct {
Token string
Git GitInfo
Artifacts artifact.Artifacts
Checksums []string
Dockers []string
ReleaseNotes string
Version string
Validate bool

View File

@ -9,13 +9,12 @@ import (
"path/filepath"
"text/template"
"github.com/goreleaser/goreleaser/internal/artifact"
"github.com/apex/log"
"github.com/pkg/errors"
"github.com/goreleaser/goreleaser/config"
"github.com/goreleaser/goreleaser/context"
"github.com/goreleaser/goreleaser/internal/artifact"
"github.com/goreleaser/goreleaser/pipeline"
)

View File

@ -6,6 +6,7 @@ import (
"text/template"
"github.com/goreleaser/goreleaser/context"
"github.com/goreleaser/goreleaser/internal/artifact"
)
const bodyTemplate = `{{ .ReleaseNotes }}
@ -34,13 +35,17 @@ func describeBody(ctx *context.Context) (bytes.Buffer, error) {
func describeBodyVersion(ctx *context.Context, version string) (bytes.Buffer, error) {
var out bytes.Buffer
var template = template.Must(template.New("release").Parse(bodyTemplate))
var dockers []string
for _, a := range ctx.Artifacts.Filter(artifact.ByType(artifact.DockerImage)).List() {
dockers = append(dockers, a.Name)
}
err := template.Execute(&out, struct {
ReleaseNotes, GoVersion string
DockerImages []string
}{
ReleaseNotes: ctx.ReleaseNotes,
GoVersion: version,
DockerImages: ctx.Dockers,
DockerImages: dockers,
})
return out, err
}

View File

@ -5,19 +5,26 @@ import (
"os"
"testing"
"github.com/goreleaser/goreleaser/internal/artifact"
"github.com/goreleaser/goreleaser/config"
"github.com/goreleaser/goreleaser/context"
"github.com/stretchr/testify/assert"
)
func TestDescribeBody(t *testing.T) {
var changelog = "\nfeature1: description\nfeature2: other description"
var ctx = &context.Context{
ReleaseNotes: changelog,
Dockers: []string{
"goreleaser/goreleaser:0.40.0",
"goreleaser/goreleaser:latest",
"goreleaser/godownloader:v0.1.0",
},
var ctx = context.New(config.Project{})
ctx.ReleaseNotes = changelog
for _, d := range []string{
"goreleaser/goreleaser:0.40.0",
"goreleaser/goreleaser:latest",
"goreleaser/godownloader:v0.1.0",
} {
ctx.Artifacts.Add(artifact.Artifact{
Name: d,
Type: artifact.DockerImage,
})
}
out, err := describeBodyVersion(ctx, "go version go1.9 darwin/amd64")
assert.NoError(t, err)