1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-24 04:16:27 +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 Token string
Git GitInfo Git GitInfo
Artifacts artifact.Artifacts Artifacts artifact.Artifacts
Checksums []string
Dockers []string
ReleaseNotes string ReleaseNotes string
Version string Version string
Validate bool Validate bool

View File

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

View File

@ -6,6 +6,7 @@ import (
"text/template" "text/template"
"github.com/goreleaser/goreleaser/context" "github.com/goreleaser/goreleaser/context"
"github.com/goreleaser/goreleaser/internal/artifact"
) )
const bodyTemplate = `{{ .ReleaseNotes }} 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) { func describeBodyVersion(ctx *context.Context, version string) (bytes.Buffer, error) {
var out bytes.Buffer var out bytes.Buffer
var template = template.Must(template.New("release").Parse(bodyTemplate)) 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 { err := template.Execute(&out, struct {
ReleaseNotes, GoVersion string ReleaseNotes, GoVersion string
DockerImages []string DockerImages []string
}{ }{
ReleaseNotes: ctx.ReleaseNotes, ReleaseNotes: ctx.ReleaseNotes,
GoVersion: version, GoVersion: version,
DockerImages: ctx.Dockers, DockerImages: dockers,
}) })
return out, err return out, err
} }

View File

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