You've already forked goreleaser
							
							
				mirror of
				https://github.com/goreleaser/goreleaser.git
				synced 2025-10-30 23:58:09 +02:00 
			
		
		
		
	Merge branch 'master' into artifactory-support
* master: fix: remove brew taps listing from release notes fix: tests should pass now style: improved goreleaser output
This commit is contained in:
		| @@ -38,7 +38,6 @@ type Context struct { | ||||
| 	Binaries     map[string]map[string][]Binary | ||||
| 	Artifacts    []string | ||||
| 	Dockers      []string | ||||
| 	Brews        []string | ||||
| 	ReleaseNotes string | ||||
| 	Version      string | ||||
| 	Validate     bool | ||||
| @@ -53,7 +52,6 @@ var ( | ||||
| 	artifactsLock sync.Mutex | ||||
| 	dockersLock   sync.Mutex | ||||
| 	binariesLock  sync.Mutex | ||||
| 	brewsLock     sync.Mutex | ||||
| ) | ||||
|  | ||||
| // AddArtifact adds a file to upload list | ||||
| @@ -65,14 +63,6 @@ func (ctx *Context) AddArtifact(file string) { | ||||
| 	log.WithField("artifact", file).Info("new release artifact") | ||||
| } | ||||
|  | ||||
| // AddBrew adds a brew tap to the brews list | ||||
| func (ctx *Context) AddBrew(tap string) { | ||||
| 	brewsLock.Lock() | ||||
| 	defer brewsLock.Unlock() | ||||
| 	ctx.Brews = append(ctx.Brews, tap) | ||||
| 	log.WithField("tap", tap).Info("new brew tap") | ||||
| } | ||||
|  | ||||
| // AddDocker adds a docker image to the docker images list | ||||
| func (ctx *Context) AddDocker(image string) { | ||||
| 	dockersLock.Lock() | ||||
|   | ||||
| @@ -20,10 +20,6 @@ func TestMultipleAdds(t *testing.T) { | ||||
| 		"c/d:2.0.0", | ||||
| 		"e/f:3.0.0", | ||||
| 	} | ||||
| 	var brews = []string{ | ||||
| 		"foo/tap/foo", | ||||
| 		"bar/bar/bar", | ||||
| 	} | ||||
| 	var ctx = New(config.Project{ | ||||
| 		Dist: "dist", | ||||
| 	}) | ||||
| @@ -44,20 +40,10 @@ func TestMultipleAdds(t *testing.T) { | ||||
| 		}) | ||||
| 	} | ||||
| 	assert.NoError(t, g.Wait()) | ||||
| 	for _, b := range brews { | ||||
| 		b := b | ||||
| 		g.Go(func() error { | ||||
| 			ctx.AddBrew(b) | ||||
| 			return nil | ||||
| 		}) | ||||
| 	} | ||||
| 	assert.NoError(t, g.Wait()) | ||||
| 	assert.Len(t, ctx.Artifacts, len(artifacts)) | ||||
| 	assert.Contains(t, ctx.Artifacts, "a", "b", "c", "d") | ||||
| 	assert.Len(t, ctx.Dockers, len(dockerfiles)) | ||||
| 	assert.Contains(t, ctx.Dockers, "a/b:1.0.0", "c/d:2.0.0", "e/f:3.0.0") | ||||
| 	assert.Len(t, ctx.Brews, len(brews)) | ||||
| 	assert.Contains(t, ctx.Brews, "foo/tap/foo", "bar/bar/bar") | ||||
| } | ||||
|  | ||||
| func TestMultipleBinaryAdds(t *testing.T) { | ||||
|   | ||||
| @@ -7,6 +7,7 @@ import ( | ||||
| 	"strings" | ||||
|  | ||||
| 	"github.com/apex/log" | ||||
| 	"github.com/apex/log/handlers/cli" | ||||
| 	"github.com/goreleaser/goreleaser/config" | ||||
| 	"github.com/goreleaser/goreleaser/context" | ||||
| 	"github.com/goreleaser/goreleaser/pipeline" | ||||
| @@ -27,6 +28,15 @@ import ( | ||||
| 	yaml "gopkg.in/yaml.v2" | ||||
| ) | ||||
|  | ||||
| var ( | ||||
| 	normalPadding    = cli.Default.Padding | ||||
| 	increasedPadding = normalPadding * 2 | ||||
| ) | ||||
|  | ||||
| func init() { | ||||
| 	log.SetHandler(cli.Default) | ||||
| } | ||||
|  | ||||
| var pipes = []pipeline.Piper{ | ||||
| 	defaults.Pipe{},    // load default configs | ||||
| 	git.Pipe{},         // get and validate git repo state | ||||
| @@ -91,12 +101,14 @@ func Release(flags Flags) error { | ||||
| 	} | ||||
| 	ctx.RmDist = flags.Bool("rm-dist") | ||||
| 	for _, pipe := range pipes { | ||||
| 		cli.Default.Padding = normalPadding | ||||
| 		log.Infof("\033[1m%s\033[0m", strings.ToUpper(pipe.String())) | ||||
| 		cli.Default.Padding = increasedPadding | ||||
| 		if err := handle(pipe.Run(ctx)); err != nil { | ||||
| 			return err | ||||
| 		} | ||||
| 	} | ||||
| 	log.Infof("\033[1mSUCCESS!\033[0m") | ||||
| 	cli.Default.Padding = normalPadding | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
|   | ||||
							
								
								
									
										9
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								main.go
									
									
									
									
									
								
							| @@ -3,6 +3,7 @@ package main | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"os" | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/apex/log" | ||||
| 	lcli "github.com/apex/log/handlers/cli" | ||||
| @@ -17,7 +18,7 @@ var ( | ||||
| ) | ||||
|  | ||||
| func init() { | ||||
| 	log.SetHandler(lcli.New(os.Stdout)) | ||||
| 	log.SetHandler(lcli.Default) | ||||
| } | ||||
|  | ||||
| func main() { | ||||
| @@ -64,11 +65,13 @@ func main() { | ||||
| 		}, | ||||
| 	} | ||||
| 	app.Action = func(c *cli.Context) error { | ||||
| 		log.Infof("running goreleaser %v", version) | ||||
| 		start := time.Now() | ||||
| 		log.Infof("\033[1mreleasing...\033[0m") | ||||
| 		if err := goreleaserlib.Release(c); err != nil { | ||||
| 			log.WithError(err).Error("release failed") | ||||
| 			log.WithError(err).Errorf("\033[1mrelease failed after %0.2fs\033[0m", time.Since(start).Seconds()) | ||||
| 			return cli.NewExitError("\n", 1) | ||||
| 		} | ||||
| 		log.Infof("\033[1mrelease succeeded after %0.2fs\033[0m", time.Since(start).Seconds()) | ||||
| 		return nil | ||||
| 	} | ||||
| 	app.Commands = []cli.Command{ | ||||
|   | ||||
| @@ -115,21 +115,9 @@ func doRun(ctx *context.Context, client client.Client) error { | ||||
| 	if err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 	ctx.AddBrew(brewTapPath(ctx)) | ||||
| 	return client.CreateFile(ctx, content, path) | ||||
| } | ||||
|  | ||||
| func brewTapPath(ctx *context.Context) string { | ||||
| 	return strings.Join( | ||||
| 		[]string{ | ||||
| 			ctx.Config.Brew.GitHub.Owner, | ||||
| 			strings.TrimPrefix(ctx.Config.Brew.GitHub.Name, "homebrew-"), | ||||
| 			ctx.Config.ProjectName, | ||||
| 		}, | ||||
| 		"/", | ||||
| 	) | ||||
| } | ||||
|  | ||||
| func buildFormula(ctx *context.Context, client client.Client, folder string) (bytes.Buffer, error) { | ||||
| 	data, err := dataFor(ctx, client, folder) | ||||
| 	if err != nil { | ||||
|   | ||||
| @@ -139,8 +139,6 @@ func TestRunPipe(t *testing.T) { | ||||
| 	// ioutil.WriteFile("testdata/run_pipe.rb", []byte(client.Content), 0644) | ||||
|  | ||||
| 	assert.Equal(t, string(bts), client.Content) | ||||
|  | ||||
| 	assert.Equal(t, "test/test/run-pipe", ctx.Brews[0]) | ||||
| } | ||||
|  | ||||
| func TestRunPipeFormatOverride(t *testing.T) { | ||||
| @@ -304,20 +302,6 @@ func TestDefault(t *testing.T) { | ||||
| 	assert.Equal(t, `bin.install "foo"`, ctx.Config.Brew.Install) | ||||
| } | ||||
|  | ||||
| func TestBrewTapPath(t *testing.T) { | ||||
| 	assert.Equal(t, "goreleaser/tap/goreleaser", brewTapPath(&context.Context{ | ||||
| 		Config: config.Project{ | ||||
| 			ProjectName: "goreleaser", | ||||
| 			Brew: config.Homebrew{ | ||||
| 				GitHub: config.Repo{ | ||||
| 					Owner: "goreleaser", | ||||
| 					Name:  "homebrew-tap", | ||||
| 				}, | ||||
| 			}, | ||||
| 		}, | ||||
| 	})) | ||||
| } | ||||
|  | ||||
| type DummyClient struct { | ||||
| 	CreatedFile bool | ||||
| 	Content     string | ||||
|   | ||||
| @@ -40,7 +40,7 @@ func (Pipe) Run(ctx *context.Context) error { | ||||
| 		ctx.Config.Dist = "dist" | ||||
| 	} | ||||
| 	for _, defaulter := range defaulters { | ||||
| 		log.Infof("\t%s", defaulter.String()) | ||||
| 		log.Info(defaulter.String()) | ||||
| 		if err := defaulter.Default(ctx); err != nil { | ||||
| 			return err | ||||
| 		} | ||||
|   | ||||
| @@ -18,14 +18,6 @@ const bodyTemplate = `{{ .ReleaseNotes }} | ||||
| {{- end -}} | ||||
| {{- end }} | ||||
|  | ||||
| {{- if .Brews }} | ||||
|  | ||||
| ## Homebrew taps | ||||
| {{ range $element := .Brews }} | ||||
| - ` + "`brew install {{ . -}}`" + ` | ||||
| {{- end -}} | ||||
| {{- end }} | ||||
|  | ||||
| --- | ||||
| Automated with [GoReleaser](https://github.com/goreleaser) | ||||
| Built with {{ .GoVersion }}` | ||||
| @@ -45,12 +37,10 @@ func describeBodyVersion(ctx *context.Context, version string) (bytes.Buffer, er | ||||
| 	err := template.Execute(&out, struct { | ||||
| 		ReleaseNotes, GoVersion string | ||||
| 		DockerImages            []string | ||||
| 		Brews                   []string | ||||
| 	}{ | ||||
| 		ReleaseNotes: ctx.ReleaseNotes, | ||||
| 		GoVersion:    version, | ||||
| 		DockerImages: ctx.Dockers, | ||||
| 		Brews:        ctx.Brews, | ||||
| 	}) | ||||
| 	return out, err | ||||
| } | ||||
|   | ||||
| @@ -18,10 +18,6 @@ func TestDescribeBody(t *testing.T) { | ||||
| 			"goreleaser/goreleaser:latest", | ||||
| 			"goreleaser/godownloader:v0.1.0", | ||||
| 		}, | ||||
| 		Brews: []string{ | ||||
| 			"caarlos0/tap/foo", | ||||
| 			"goreleaser/tap/bar", | ||||
| 		}, | ||||
| 	} | ||||
| 	out, err := describeBodyVersion(ctx, "go version go1.9 darwin/amd64") | ||||
| 	assert.NoError(t, err) | ||||
|   | ||||
							
								
								
									
										5
									
								
								pipeline/release/testdata/release1.txt
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								pipeline/release/testdata/release1.txt
									
									
									
									
										vendored
									
									
								
							| @@ -8,11 +8,6 @@ feature2: other description | ||||
| - `docker pull goreleaser/goreleaser:latest` | ||||
| - `docker pull goreleaser/godownloader:v0.1.0` | ||||
|  | ||||
| ## Homebrew taps | ||||
|  | ||||
| - `brew install caarlos0/tap/foo` | ||||
| - `brew install goreleaser/tap/bar` | ||||
|  | ||||
| --- | ||||
| Automated with [GoReleaser](https://github.com/goreleaser) | ||||
| Built with go version go1.9 darwin/amd64 | ||||
		Reference in New Issue
	
	Block a user