-
Notifications
You must be signed in to change notification settings - Fork 59
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
Read version from resource instead of hard-coding it #220
Conversation
naveenOnarayanan
commented
Jun 27, 2024
•
edited
Loading
edited
- Seems like the hard-coded version keeps drifting everytime a new release is made (current release 7.1.0, but code still shows 7.0.0).
- This uses resource jar approach to embed the version into the binary and read it at runtime. This ensures that the version is always up to sync with release.
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.
Thanks for doing this
cli/BUILD
Outdated
@@ -22,6 +22,7 @@ java_binary( | |||
kt_jvm_library( | |||
name = "cli-lib", | |||
srcs = glob(["src/main/kotlin/**/*.kt"]), | |||
resources = ["//:.bazelversion"], |
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 looks good. We need to use a different version file then this one since this one controls the version of Bazel that is running, not the version of bazel-diff
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.
Oh oops, currently when the binary is published, how is the version passed in? I see that since it follows semvar, it seems like it might be provided from the pipeline itself?
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.
ah looks like it picks it up from tags.
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.
@tinder-maxwellelliott correct my assumption above, updated the PR to utilize bazel stamping to embed the version tag and read it directly from the binary resources instead.
|
||
class VersionProvider : IVersionProvider { | ||
override fun getVersion(): Array<String> { | ||
return arrayOf("7.0.0") | ||
val classLoader = this::class.java.classLoader |
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.
Does it make more sense to simply make a bazel rule that can accept the stable-status path and code gen this entire file? Seems like there are a couple steps here that could be collapsed into one?
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.
Thanks for doing this