-
Notifications
You must be signed in to change notification settings - Fork 35
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
feat(version): append commit hash on build via ldflags #342
Conversation
@guergabo based on all the discussions on the other two PRs, IMO this will work. Although the nix part has to be checked as I'm not too familiar with nix syntax. |
d3a0d22
to
264019d
Compare
It standardize resonate binary version to: resonate version v<VERSION>[-<PRE_RELEASE>-<TIMESTAMP>][ COMMIT_HASH] <GOOS>/<GOARCH> where: - `VERSION`: the release version - `PRE_RELEASE`: can be any arbitrary string, e.g. `alpha`, `beta`, `rc.1`, etc - `TIMESTAMP`: the yyyymmdd of build IF this is not a GA release - `COMMIT_HASH`: short revision IF this is a GA release - `GOOS`: underlying OS this binary built on - `GOARCH`: underlying Architecture this binary built on This also adds a new `version` subcommand for convenience and to not give an error on `resonate version` for folks with muscle memory for it. Signed-off-by: Khosrow Moossavi <[email protected]>
@@ -34,7 +34,6 @@ jobs: | |||
run: | | |||
# Extract resonate version | |||
RESONATE_VERSION=$(./resonate -v | awk '{print $3}') | |||
RESONATE_VERSION="v${RESONATE_VERSION}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will solve the workflow, but I'm not aware of any other breaking change that this might introduce in the broader resonate landscape, if any. Because effectively resonate --version
will always have a leading v
and tailing <os>/<arch>
, if move forward with this PR.
@@ -88,6 +90,7 @@ | |||
ldflags = [ | |||
"-s" | |||
"-w" | |||
"-X github.com/resonatehq/resonate/internal/version.commit=$(shortRev)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case you'll need to use Nix string interpolation like this:
"-X github.com/resonatehq/resonate/internal/version.commit=${shortRev}"
@@ -77,6 +78,7 @@ | |||
# The Resonate server | |||
resonate = pkgs.buildGoApplication rec { | |||
pname = "resonate"; | |||
inherit shortRev; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove this line (you don't need to inherit this value into the derivation function to use it 😄)
@khos2ow I've been helping out with the Nix stuff. I left two quick comments that should hopefully get you over the hump here. |
This PR follows up the attempts on #301 and #302.
It standardize resonate binary version to:
resonate version v<VERSION>[-<PRE_RELEASE>-<TIMESTAMP>][ COMMIT_HASH] <GOOS>/<GOARCH>
where:
VERSION
: the release versionPRE_RELEASE
: can be any arbitrary string, e.g.alpha
,beta
,rc.1
, etcTIMESTAMP
: the yyyymmdd of build IF this is not a GA releaseCOMMIT_HASH
: short revision IF this is a GA releaseGOOS
: underlying OS this binary built onGOARCH
: underlying Architecture this binary built onThis also adds a new
version
subcommand for convenience and to not give an error onresonate version
for folks with muscle memory for it.Two manual intervention is needed for this workflow:
coreVersion
ininternal/version/version.go
to next logical releaseprerelease
toalpha
(ordev
, or similar) ininternal/version/version.go
prerlease
to""
ininternal/version/version.go
for GA, or just leave it as is for the restThe rest will be calculated, or generated on the fly.
Fixes: #298