diff --git a/README.md b/README.md index 521a658..79e2a1c 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ Examples: * `GoVetShadow` * `Nakedret` * `UnitTest` - trigger unit test suite +* `GoReleaser`, `CleanGoReleaser` - Normalize [goreleaser](https://goreleaser.com/) # SYSTEM REQUIREMENTS @@ -44,7 +45,6 @@ Prior art and personal plugs. * [invoke](https://pypi.org/project/invoke/) - 100% Python task runner * [mage](https://magefile.org/) - 100% Go task runner * [mcandre/tinyrick](https://github.com/mcandre/tinyrick) - 100% Rust task runner -* [mcandre/tuco](https://github.com/mcandre/tuco) - Go port multiplexer * [Shake](https://shakebuild.com/) - 100% Haskell task runner 🐱 diff --git a/goreleaser.go b/goreleaser.go new file mode 100644 index 0000000..25a8f59 --- /dev/null +++ b/goreleaser.go @@ -0,0 +1,32 @@ +package mx + +import ( + "bytes" + "io" + "log" + "os" + + "github.com/magefile/mage/sh" +) + +// CleanGoReleaser removes artifacts from the standard goreleaser directory "dist". +func CleanGoReleaser() error { return sh.Rm("dist") } + +// GoReleaser executes goreleaser with the UNIX / Go idiom of silencing extraneous output. +func GoReleaser(env map[string]string, args ...string) error { + var stdout bytes.Buffer + var stderr bytes.Buffer + _, err := sh.Exec(env, &stdout, &stderr, "goreleaser", args...) + + if err != nil { + if _, err2 := io.Copy(os.Stdout, &stdout); err2 != nil { + log.Println(err2) + } + + if _, err2 := io.Copy(os.Stderr, &stderr); err2 != nil { + log.Println(err2) + } + } + + return err +}