feat: add FileVersion and icon to Win exe (#10487)
This commit is contained in:
parent
4394f0baff
commit
deda716a15
|
|
@ -129,6 +129,11 @@ commands:
|
|||
- check-changed-files-or-halt
|
||||
- attach_workspace:
|
||||
at: '/go'
|
||||
- when:
|
||||
condition:
|
||||
equal: [ windows, << parameters.type >> ]
|
||||
steps:
|
||||
- run: make versioninfo
|
||||
- when:
|
||||
condition: << parameters.nightly >>
|
||||
steps:
|
||||
|
|
|
|||
|
|
@ -9,3 +9,5 @@ process.yml
|
|||
/.vscode
|
||||
/*.toml
|
||||
/*.conf
|
||||
resource.syso
|
||||
versioninfo.json
|
||||
|
|
|
|||
11
Makefile
11
Makefile
|
|
@ -99,6 +99,16 @@ help:
|
|||
deps:
|
||||
go mod download -x
|
||||
|
||||
.PHONY: version
|
||||
version:
|
||||
@echo $(version)-$(commit)
|
||||
|
||||
.PHONY: versioninfo
|
||||
versioninfo:
|
||||
go install github.com/josephspurrier/goversioninfo/cmd/goversioninfo@v1.4.0; \
|
||||
go run scripts/generate_versioninfo/main.go; \
|
||||
go generate cmd/telegraf/telegraf_windows.go; \
|
||||
|
||||
.PHONY: telegraf
|
||||
telegraf:
|
||||
go build -ldflags "$(LDFLAGS)" ./cmd/telegraf
|
||||
|
|
@ -235,6 +245,7 @@ install: $(buildbin)
|
|||
# the bin between deb/rpm/tar packages over building directly into the package
|
||||
# directory.
|
||||
$(buildbin):
|
||||
echo $(GOOS)
|
||||
@mkdir -pv $(dir $@)
|
||||
go build -o $(dir $@) -ldflags "$(LDFLAGS)" ./cmd/telegraf
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
|
|
@ -1,6 +1,8 @@
|
|||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
//go:generate goversioninfo -icon=../../assets/tiger.ico
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
// Generate the versioninfo.json with the current build version from the makefile
|
||||
// The file versioninfo.json is used by the goversioninfo package to add version info into a windows binary
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"log" //nolint:revive
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type VersionInfo struct {
|
||||
StringFileInfo StringFileInfo
|
||||
}
|
||||
|
||||
type StringFileInfo struct {
|
||||
ProductName string
|
||||
ProductVersion string
|
||||
}
|
||||
|
||||
func main() {
|
||||
e := exec.Command("make", "version")
|
||||
var out bytes.Buffer
|
||||
e.Stdout = &out
|
||||
if err := e.Run(); err != nil {
|
||||
log.Fatalf("Failed to get version from makefile: %v", err)
|
||||
}
|
||||
version := strings.TrimSuffix(out.String(), "\n")
|
||||
|
||||
v := VersionInfo{
|
||||
StringFileInfo: StringFileInfo{
|
||||
ProductName: "Telegraf",
|
||||
ProductVersion: version,
|
||||
},
|
||||
}
|
||||
|
||||
file, err := json.MarshalIndent(v, "", " ")
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to marshal json: %v", err)
|
||||
}
|
||||
if err := ioutil.WriteFile("cmd/telegraf/versioninfo.json", file, 0644); err != nil {
|
||||
log.Fatalf("Failed to write versioninfo.json: %v", err)
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue