forked from influxdata/telegraf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add FileVersion and icon to Win exe (influxdata#10487)
- Loading branch information
Showing
6 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,5 @@ process.yml | |
/.vscode | ||
/*.toml | ||
/*.conf | ||
resource.syso | ||
versioninfo.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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/[email protected]; \ | ||
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |