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

Add build version option to prefix git hash with custom version property #7222

Merged
merged 4 commits into from
Jun 21, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,9 @@ def calculateVersion() {

if (project.hasProperty('version') && (project.version =~ calVerPattern)) {
return "${project.version}"
} else if (project.hasProperty('versionprefix') && (project.versionprefix =~ calVerPattern)) {
def gitDetails = getGitCommitDetails(7) // Adjust length as needed
return "${project.versionprefix}-${gitDetails.hash}"
Copy link
Contributor

@garyschulte garyschulte Jun 13, 2024

Choose a reason for hiding this comment

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

instead of introducing versionprefix, could we instead add a 'force githash suffix' property? The behavior would be more intuitive imo, instead of having version and versionprefix

perhaps a boolean appendcommitversion or similar...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I think that would be a good way of achieving the same thing. I'm on vacation tomorrow but I'll update the PR on Monday.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've refactored along the lines you suggested @garyschult. I've also included commented-out examples of using them.

The example version field I've put in the file includes an example vendor name: 24.5.6-acme. That's how we'll probably use the field, and I think other vendors might want to set it in a similar way if they package Besu into their own offerings, so their users can check that they're running a version from their vendor. Obviously just setting 24.5.6 works fine as well.

} else {
// If no version is supplied or it doesn't match the semantic versioning, calculate from git
println("Generating project version as supplied is version not semver: ${project.version}")
Expand Down
Loading