Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update buildinfo to parse output of go list set on compile #56

Merged
merged 3 commits into from
Dec 21, 2024

Conversation

0pcom
Copy link
Contributor

@0pcom 0pcom commented Dec 15, 2024

skycoin/skywire#1908 (comment)

current method for setting buildinfo relies on 'git' and can only be done from the cloned repo sources; i.e,:

$ go build -mod=vendor -ldflags="-X 'github.com/skycoin/skywire-utilities/pkg/buildinfo.version=$(git describe)' -X 'github.com/skycoin/skywire-utilities/pkg/buildinfo.date=$(date -u "+%Y-%m-%dT%H:%M:%SZ")' -X 'github.com/skycoin/skywire-utilities/pkg/buildinfo.commit=$(git rev-list -1 HEAD)'" ...

this PR adds the golist variable to pkg/buildinfo which may be set to the output of go list on compile as follows:

go build -ldflags="-X 'github.com/skycoin/skywire-utilities/pkg/buildinfo.golist=$(go list -m -json -mod=mod github.com/skycoin/skywire@develop)' -X 'github.com/skycoin/skywire-utilities/pkg/buildinfo.date=$(date -u "+%Y-%m-%dT%H:%M:%SZ")'" cmd/skywire/skywire.go

The golist variable is parsed on init and will set version and commit hash - if these variables are set as the default value "unknown"

This permits building and installing properly versioned binaries - without needing to fetch the sources explicitly. So it will work with go run or go install as well as go build

Also included on this PR is an update of all the code dependencies via go get -u ./...

@mrpalide mrpalide merged commit 159ccb5 into skycoin:develop Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants