mirror of
https://github.com/go-task/task.git
synced 2025-08-10 22:42:19 +02:00
Updated the version output to use Go module build information if avalable. Enabled GoReleaser module proxying for verifiable builds.
Co-authored-by: Jamie Edge <JamieEdge@users.noreply.github.com> Co-authored-by: Carlos Alexandro Becker <caarlos0@gmail.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
build:
|
||||
binary: task
|
||||
main: cmd/task/task.go
|
||||
main: cmd/task
|
||||
goos:
|
||||
- windows
|
||||
- darwin
|
||||
@@ -17,6 +17,11 @@ build:
|
||||
goarch: 386
|
||||
env:
|
||||
- CGO_ENABLED=0
|
||||
ldflags:
|
||||
- -s -w # Don't set main.version.
|
||||
|
||||
gomod:
|
||||
proxy: true
|
||||
|
||||
archives:
|
||||
- name_template: "{{.Binary}}_{{.Os}}_{{.Arch}}"
|
||||
|
@@ -1,5 +1,10 @@
|
||||
# Changelog
|
||||
|
||||
## Unreleased
|
||||
|
||||
- Improve version reporting when building Task from source using Go Modules
|
||||
([#462](https://github.com/go-task/task/pull/462), [#473](https://github.com/go-task/task/pull/473)).
|
||||
|
||||
## v3.4.1 - 2021-04-17
|
||||
|
||||
- Improve error reporting when parsing YAML: in some situations where you
|
||||
|
@@ -7,6 +7,7 @@ import (
|
||||
"os"
|
||||
"os/signal"
|
||||
"path/filepath"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
@@ -19,7 +20,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
version = "master"
|
||||
version = ""
|
||||
)
|
||||
|
||||
const usage = `Usage: task [-ilfwvsd] [--init] [--list] [--force] [--watch] [--verbose] [--silent] [--dir] [--taskfile] [--dry] [--summary] [task...]
|
||||
@@ -93,7 +94,7 @@ func main() {
|
||||
pflag.Parse()
|
||||
|
||||
if versionFlag {
|
||||
fmt.Printf("Task version: %s\n", version)
|
||||
fmt.Printf("Task version: %s\n", getVersion())
|
||||
return
|
||||
}
|
||||
|
||||
@@ -217,3 +218,21 @@ func getSignalContext() context.Context {
|
||||
}()
|
||||
return ctx
|
||||
}
|
||||
|
||||
func getVersion() string {
|
||||
if version != "" {
|
||||
return version
|
||||
}
|
||||
|
||||
info, ok := debug.ReadBuildInfo()
|
||||
if !ok || info.Main.Version == "" {
|
||||
return "unknown"
|
||||
}
|
||||
|
||||
version = info.Main.Version
|
||||
if info.Main.Sum != "" {
|
||||
version += fmt.Sprintf(" (%s)", info.Main.Sum)
|
||||
}
|
||||
|
||||
return version
|
||||
}
|
||||
|
Reference in New Issue
Block a user