1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-02-07 13:31:37 +02:00
Carlos Alexandro Becker 7378edc708
feat: allow to use ModulePath on templates (#2128)
Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
2021-03-22 08:55:01 -03:00

35 lines
661 B
Go

package gomod
import (
"fmt"
"os/exec"
"strings"
"github.com/goreleaser/goreleaser/internal/pipe"
"github.com/goreleaser/goreleaser/pkg/context"
)
// Pipe for env.
type Pipe struct{}
func (Pipe) String() string {
return "loading go mod information"
}
// Run the pipe.
func (Pipe) Run(ctx *context.Context) error {
out, err := exec.CommandContext(ctx, "go", "list", "-m").CombinedOutput()
if err != nil {
return fmt.Errorf("failed to get module path: %w: %s", err, string(out))
}
result := strings.TrimSpace(string(out))
if result == "command-line-arguments" {
return pipe.Skip("not a go module")
}
ctx.ModulePath = result
return nil
}