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

Use MinVer for versioning #1275

Merged
merged 1 commit into from
Jun 13, 2023
Merged

Use MinVer for versioning #1275

merged 1 commit into from
Jun 13, 2023

Conversation

martincostello
Copy link
Member

From investigating the build to ensure that tagging produces correctly packaged version, I found that the GitVersion tool added a lot of complexity that made it hard to reason about what versions would be produced in the build for a given tag (or lack of tag).

Having done some research, I feel that MinVer makes things a lot simpler and easy to reason about, so this PR drops GitVersion in favour of MinVer and its MSBuild integration.

I also propose using its default pre-release label convention, which roughly matches the versioning of .NET itself, so a.b.c-(alpha|beta).d, so our first alpha would be 8.0.0-alpha.1 and we can just increment that number when we tag as we go if there are further alphas.

The TL:DR effect of the tool change are:

  • The major.minor version is now controlled through the MinVerMinimumMajorMinor MSBuild property.
  • The patch version increments automatically based on the last tag.
  • The CI version now increments as a function of the commit height since the last tag.
  • The CI pre-release label is alpha.
  • The assembly version stays at x.0.0.0 where x is the major version.
  • The file version build number is the number of the GitHub workflow run.
  • NuGet packages created in PRs have a pre-release label of pr.{number}.{build}.
  • The package version for a tag is exactly the name of the tag.
    • Want to release 8.0.0-alpha.1? Create a release with a tag called that.
    • Want to release 8.0.0? Create a release with a tag called that.

Testing

I tested the changes in this PR by creating a new repository seeded from 59fd86b, and then tweaking the build to make the feedback loop faster by turning off the tests and non-Windows OSs and removing the signing and NuGet push steps (as they wouldn't work anyway).

I then made various changes to the repo to simulate development work, PRs etc, and created some releases. The Polly package versions created through the tests can be found here.

The version behaviour from the different activities are shown below:

Git Ref Package Version Assembly Version File Version Informational Version
main 8.0.0-alpha.0.265 8.0.0.0 8.0.0.10 8.0.0-alpha.0.265+10f11ecf5364d7ce2f5ba985619d347a5f31b5d0
PR from main 8.0.0-pr.3.11 8.0.0.0 8.0.0.11 8.0.0-alpha.0.266+d674a05ea15ecbdec7bbba4724a0898bdba6bcad
main after PR 8.0.0-alpha.0.266 8.0.0.0 8.0.0.12 8.0.0-alpha.0.266+2eb9f8c5041585ef29e215b15a47f641ab23dc3c
8.0.0-alpha.1 8.0.0-alpha.1 8.0.0.0 8.0.0.13 8.0.0-alpha.1+2eb9f8c5041585ef29e215b15a47f641ab23dc3c
main after tag 8.0.0-alpha.1.1 8.0.0.0 8.0.0.14 8.0.0-alpha.1.1+a2a2d5f1ea93c6656e9079b3751b0d8316d9eef9
8.0.0-alpha.2 8.0.0-alpha.2 8.0.0.0 8.0.0.15 8.0.0-alpha.2+a2a2d5f1ea93c6656e9079b3751b0d8316d9eef9
8.0.0 8.0.0 8.0.0.0 8.0.0.16 8.0.0+a2a2d5f1ea93c6656e9079b3751b0d8316d9eef9
PR from 8.0.0 8.0.1-pr.4.17 8.0.0.0 8.0.1.17 8.0.1-alpha.0.1+f7f511b2039b478778b5d18239b1db20618a027a
main after PR 8.0.1-alpha.0.1 8.0.0.0 8.0.1.18 8.0.1-alpha.0.1+3d872411247fa09d3717176ab492d4e159b6ad8f
8.0.1 8.0.1 8.0.0.0 8.0.1.19 8.0.1+3d872411247fa09d3717176ab492d4e159b6ad8f
main after tag 8.0.2-alpha.0.1 8.0.0.0 8.0.2.20 8.0.2-alpha.0.1+91e29c4b88b32dea15df7de93ae8d2c81d2bed80

Summary of changes

  • Switch to MinVer from GitVersion.
  • Fix incorrect condition for publishing to GitHub Packages for tags.
  • Refactor the build script to reduce repetition.
  • README tidy-up.

Resolves #1274.

- Switch to MinVer from GitVersion to make tag-based versioning simpler and reduce the build complexity.
- Fix incorrect condition for publishing to GitHub Packages for tags.
- Refactor the build script to reduce repetition.
- README tidy-up.
@martincostello martincostello added enhancement CI/build bug fix v8 Issues related to the new version 8 of the Polly library. labels Jun 10, 2023
@martincostello martincostello added this to the v8.0.0 milestone Jun 10, 2023
@codecov
Copy link

codecov bot commented Jun 10, 2023

Codecov Report

Merging #1275 (5900c20) into main (59fd86b) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main    #1275   +/-   ##
=======================================
  Coverage   83.33%   83.33%           
=======================================
  Files         270      270           
  Lines        6317     6317           
  Branches      981      981           
=======================================
  Hits         5264     5264           
  Misses        844      844           
  Partials      209      209           
Flag Coverage Δ
linux 83.33% <ø> (ø)
macos 83.33% <ø> (ø)
windows 83.33% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

@martincostello martincostello marked this pull request as ready for review June 11, 2023 11:23
Copy link
Contributor

@martintmk martintmk left a comment

Choose a reason for hiding this comment

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

Looks great! I like the simplicity of MinVer tool, will try it internally too :)

@martincostello martincostello requested a review from joelhulen June 12, 2023 08:16
@joelhulen
Copy link
Member

I'm with @martintmk on the simplicity of MinVer vs. GitVersion. I wish we did this a long time ago! Looks great, thanks!

@martincostello
Copy link
Member Author

Thanks both - I'll merge and then start on a branch for publishing 7.2.4 tomorrow using the workflow and signing setup.

@martincostello martincostello merged commit 53e01a8 into main Jun 13, 2023
@martincostello martincostello deleted the use-minver branch June 13, 2023 06:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fix CI/build enhancement v8 Issues related to the new version 8 of the Polly library.
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Fix release workflow
3 participants