Closed teddylear closed 3 years ago
I wonder who is going to remember to bump the version manually? And Git commit? Maybe it's a nice time to add goreleaser
to the project, and automate the build?
@butuzov As they way things are now it would have to be a manual bump prior to release. Ideally there would be a way to automate this (I can look into goreleaser). Also let me know about git commit, I can try to add that as well.
git commit is what @cweill was talking in https://github.com/cweill/gotests/issues/133#issuecomment-751405527
@butuzov I have added code to add the commit on this branch, however the issue is that it requires the following build to inject the git commit hash.
export GIT_COMMIT=$(git rev-parse HEAD) && \
go build -ldflags "-X github.com/cweill/gotests/gotests/process.GitCommit=$GIT_COMMIT"
As I'm new to golang, is there a way to set a default build script/build options when calling go build? I attempted searching for something like this but came up empty-handed. I'll keep looking but if you have any ideas of a better way to implement this/ build this let me know!
process.go
. its quite short and independent to be passed down to the stream. maybe it's better to locate in some file let's call it version.go
under gotests
alongside main.go
.from git build
or go install
). I have mention goreleaser
above, it can be added to CI and run automatically once software tagged. Here is a small example of how goreleser config.so work plan is next:
1) add version.go
, and way to show version + including git hash it was built (testing it with manual builds).
2) test default case (devel)
3) add Makefile to automate git/version injecting
4) add CI step.
@cweill can maybe add anything he would like to see in the implementation of this feature, as an author and maintainer.
@butuzov Ok I can look into this, but because go install
needs to be supported then I cannot use the flags I mentioned? Else this will not work with go get
correct?
@butuzov Ok I can look into this, but because
go install
needs to be supported then I cannot use the flags I mentioned? Else this will not work withgo get
correct?
Good that you asked! I learned this recently and haven't tested it yet. Usually, version should support "devel builds", with a fallback to something like v0.0.0-devel (git commit if possible)
@teddylear Thanks for this PR. I agree with @butuzov, we should aim to automate the version number increasing. I'm not familiar with the best way to do this in Go, but there must be some precedence out there.
Let me keep working on this, but I'll close this PR for now while implementing these changes.
Adding version command to show current version of gotests installed.
NOTE Had issue with tests failing intermittently locally (even on develop). Not sure what the issue, please let me know if this is a known issue or something I should make another ticket for. This only appears to be happening for the 1.16.x build.
133