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

Fix reported version in --version output #87

Merged
merged 3 commits into from
Jun 19, 2024

Conversation

mmlb
Copy link
Member

@mmlb mmlb commented Jun 19, 2024

We were not using gorleaser correctly before. First it was updating a set of values that do not exist in our dep tree and isn't used. Secondly it wasn't a setting a very useful value .Version is only the commit (with -next appended if we aren't building off of the tag). .Summary gives equivalent output if building off of the tag but additional details if not (example below). Finally, I got rid of the hard coded/outdated version number and replaced with "devel" so that its less misleading/confusing.

Here's an example of how things will look:

[13:53:26]-[~/p/g/m/vogelkop]-[manny@c3mv18nix]
git describe --tags 
v0.3.1-3-g8311843
[13:53:32]-[~/p/g/m/vogelkop]-[manny@c3mv18nix]
goreleaser build --snapshot --clean
  • starting build...
  • loading                                          path=.goreleaser.yml
  • skipping validate...
  • loading environment variables
  • getting and validating git state
    • git state                                      commit=8311843274235ab157c22ed21daeca54b83f27fd branch=fix-reported-version current_tag=v0.3.1 previous_tag=v0.3.0 dirty=false
    • pipe skipped                                   reason=disabled during snapshot mode
  • parsing tag
  • setting defaults
  • snapshotting
    • building snapshot...                           version=v0.3.1-next
  • running before hooks
    • running                                        hook=go mod download
  • checking distribution directory
    • cleaning dist
  • setting up metadata
  • storing release metadata
    • writing                                        file=dist/metadata.json
  • loading go mod information
  • build prerequisites
  • writing effective config file
    • writing                                        config=dist/config.yaml
  • building binaries
    • building                                       binary=dist/vogelkop_linux_arm64/vogelkop
    • building                                       binary=dist/vogelkop_linux_amd64_v1/vogelkop
  • storing artifacts metadata
    • writing                                        file=dist/artifacts.json
  • build succeeded after 0s
  • thanks for using goreleaser!
[13:53:34]-[~/p/g/m/vogelkop]-[manny@c3mv18nix]
./dist/vogelkop_linux_amd64_v1/vogelkop --version
vogelkop version v0.3.1-3-g8311843
[13:53:46]-[~/p/g/m/vogelkop]-[manny@c3mv18nix]
git tag -m v0.3.424242 v0.3.424242
[13:53:50]-[~/p/g/m/vogelkop]-[manny@c3mv18nix]
goreleaser build --snapshot --clean
  • starting build...
  • loading                                          path=.goreleaser.yml
  • skipping validate...
  • loading environment variables
  • getting and validating git state
    • git state                                      commit=8311843274235ab157c22ed21daeca54b83f27fd branch=fix-reported-version current_tag=v0.3.424242 previous_tag=v0.3.1 dirty=false
    • pipe skipped                                   reason=disabled during snapshot mode
  • parsing tag
  • setting defaults
  • snapshotting
    • building snapshot...                           version=v0.3.424242-next
  • running before hooks
    • running                                        hook=go mod download
  • checking distribution directory
    • cleaning dist
  • setting up metadata
  • storing release metadata
    • writing                                        file=dist/metadata.json
  • loading go mod information
  • build prerequisites
  • writing effective config file
    • writing                                        config=dist/config.yaml
  • building binaries
    • building                                       binary=dist/vogelkop_linux_arm64/vogelkop
    • building                                       binary=dist/vogelkop_linux_amd64_v1/vogelkop
  • storing artifacts metadata
    • writing                                        file=dist/artifacts.json
  • build succeeded after 0s
  • thanks for using goreleaser!
[13:53:52]-[~/p/g/m/vogelkop]-[manny@c3mv18nix]
./dist/vogelkop_linux_amd64_v1/vogelkop --version
vogelkop version v0.3.424242

mmlb added 3 commits June 19, 2024 13:58
.Version shows -next for non-tag builds, .Summary shows git describe
like output ({Tag}-$N-{CommitSHA}) so is more useful
We do not use github.com/metal-toolbox/version, instead we have a simple
internal package.
@mmlb mmlb force-pushed the fix-reported-version branch from 8311843 to b9e3497 Compare June 19, 2024 17:58
@@ -2,7 +2,7 @@ package version

var (
name = "vogelkop"
version = "0.2.5"
version = "devel"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally we'd be updating this with each 'release'

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn't documented and I missed it and I assumed goreleaser was taking care of it. goreleaser built binaries will have the right values and go build ones won't which should be a big red flag so is also pretty nice I think.

@mmlb mmlb merged commit 21126b7 into metal-toolbox:main Jun 19, 2024
2 checks passed
@mmlb mmlb deleted the fix-reported-version branch June 19, 2024 18:02
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