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

feat(version): append commit hash on build via ldflags #342

Closed
wants to merge 1 commit into from

Conversation

khos2ow
Copy link

@khos2ow khos2ow commented May 29, 2024

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 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.

Two manual intervention is needed for this workflow:

  1. At the beginning of a release cycle:
    • bump coreVersion in internal/version/version.go to next logical release
    • set prerelease to alpha (or dev, or similar) in internal/version/version.go
  2. At the end of a release cycle (beta, RC, GA):
    • set prerlease to "" in internal/version/version.go for GA, or just leave it as is for the rest

The rest will be calculated, or generated on the fly.

Fixes: #298

@khos2ow
Copy link
Author

khos2ow commented May 29, 2024

@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.

@khos2ow khos2ow force-pushed the version-cmd branch 2 times, most recently from d3a0d22 to 264019d Compare May 29, 2024 17:10
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}"
Copy link
Author

@khos2ow khos2ow May 29, 2024

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)"
Copy link
Contributor

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;
Copy link
Contributor

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 😄)

@lucperkins
Copy link
Contributor

@khos2ow I've been helping out with the Nix stuff. I left two quick comments that should hopefully get you over the hump here.

@fuadnafiz98 fuadnafiz98 mentioned this pull request Dec 19, 2024
2 tasks
@dfarr
Copy link
Member

dfarr commented Dec 19, 2024

Sorry @khos2ow, I'm going to close this PR for being stale. We can keep the conversation going in #298

@dfarr dfarr closed this Dec 19, 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.

Add version command
3 participants