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

cmd: Add 'version' option #220

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

daissi
Copy link

@daissi daissi commented Oct 30, 2024

This 'version' option prints the fakemachine version. Fix #200

@obbardc
Copy link
Member

obbardc commented Oct 30, 2024

CI fails because of #218

@@ -11,6 +11,8 @@ import (
"strings"
)

const Version = "0.0.10"
Copy link
Member

Choose a reason for hiding this comment

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

Hardcoding is somewhat likely to break unfortunately; I wonder if golang has some good ways to generate the version from e.g. git or a package release? Would also be good to include the git version if it's not a specific release

Copy link
Member

Choose a reason for hiding this comment

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

Untested but pretty sure we can inject the version at build time with go build -ldflags "-X main.Version=$VERSION".

How do you feel about

  1. injecting the version in the GitHub action based on git commit
  2. injecting the same version in the Debian packaging

I looked for existing libraries to do this, like in rust, but couldn't find anything.

(Also the same will be true for debos)

Copy link
Member

Choose a reason for hiding this comment

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

Is that what's typical in the go space (surely others do this as well)? But yeah in principle that sounds fine, my main concern is really that it's too easy to forget to update :)

Copy link
Author

Choose a reason for hiding this comment

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

Now, the version is injected at build time based on git describe --tags HEAD. Is that better?

This 'version' option prints the fakemachine version

Signed-off-by: Dylan Aïssi <[email protected]>
@daissi daissi force-pushed the wip/daissi/version branch from 019ca7f to 2f17226 Compare January 28, 2025 11:42
@daissi daissi marked this pull request as draft January 28, 2025 11:42
@daissi daissi marked this pull request as ready for review January 28, 2025 12:13
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 flag which prints version
3 participants