Skip to content

Commit

Permalink
stamp builds with git ref (which should be tag for releases)
Browse files Browse the repository at this point in the history
  • Loading branch information
legowerewolf committed Dec 16, 2024
1 parent ea0e3fd commit 548e943
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ jobs:
go-version-file: go.mod

- name: Build
run: go build -o release/
run: >
go build -o release/ -ldflags "-X
'github.com/legowerewolf/AO3fetch/buildinfo.RefName=$REFNAME'"
env:
GOOS: ${{ matrix.platform }}
GOARCH: ${{ matrix.arch }}
REFNAME: ${{ github.ref_name }}

- name: Upload binaries to release
run: |
Expand Down
4 changes: 4 additions & 0 deletions buildinfo/buildinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"strings"
)

var RefName string

func GetBuildSettings() (*map[string]string, error) {
buildInfo, ok := debug.ReadBuildInfo()
if !ok {
Expand All @@ -24,6 +26,8 @@ func GetBuildSettings() (*map[string]string, error) {
settings["vcs.revision.withModified"] += "+"
}

settings["vcs.revision.refName"] = RefName

settings["GOARCH.withVersion"] = settings["GOARCH"] + "/" + settings["GO"+strings.ToUpper(settings["GOARCH"])]

return &settings, nil
Expand Down
2 changes: 1 addition & 1 deletion scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func main() {
log.Fatal(err)
}

fmt.Printf("%s:%s built by %s %s-%s\n", (*settings)["vcs"], (*settings)["vcs.revision.withModified"], (*settings)["GOVERSION"], (*settings)["GOOS"], (*settings)["GOARCH.withVersion"])
fmt.Printf("%s (%s:%s) built by %s %s-%s\n", (*settings)["vcs.revision.refName"], (*settings)["vcs"], (*settings)["vcs.revision.withModified"], (*settings)["GOVERSION"], (*settings)["GOOS"], (*settings)["GOARCH.withVersion"])

return
}
Expand Down

0 comments on commit 548e943

Please sign in to comment.