Skip to content

Conversation

naveenOnarayanan
Copy link
Contributor

@naveenOnarayanan naveenOnarayanan commented Jun 27, 2024

  • 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.
> git tag -a 7.1.1 -m "Version bump" 

> bazel-out/darwin_arm64-fastbuild/bin/cli/bazel-diff --version
7.1.1


# If built off master (no tags)
> bazel-out/darwin_arm64-fastbuild/bin/cli/bazel-diff --version                                                                                ✔
acd415a165d8515d9d94be18f14dcd62d0c1bf1c

@CLAassistant
Copy link

CLAassistant commented Jun 27, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Collaborator

@tinder-maxwellelliott tinder-maxwellelliott left a 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
kt_jvm_library(
name = "cli-lib",
srcs = glob(["src/main/kotlin/**/*.kt"]),
resources = ["//:.bazelversion"],
Copy link
Collaborator

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

Copy link
Contributor Author

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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
Copy link
Collaborator

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?

Copy link
Collaborator

@tinder-maxwellelliott tinder-maxwellelliott left a 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

@tinder-maxwellelliott tinder-maxwellelliott merged commit eedaeba into Tinder:master Jul 4, 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.

3 participants