1

I am trying to understand trunk based development with semantic versioning for a Python project. Has anyone had any experience of adopting a trunk based development with semantic versioning for packages?

I store the semantic version in version.py:__version__

On the trunk (main) version.py:__version__ would be 1.0.0-SNAPSHOT and on the CI server each build would append the build number, e.g. 1.0.0.1234-SNAPSHOT. A change log would initially be empty for the semantic version number on the trunk (main).

When ready to release, a release branch would be created release-1.0.x and any bug fixes, would be cherry-picked from trunk(main). A gitlab CI job would still run tests for commits on branches named release-. The release branch may be tagged, e.g. 1.0.1, 1.0.2 etc. until the release stabilises. This would bump the version number in version.py.

The change log could be finalised on the release-branch, however this would mean that it would have to be merged back to trunk (main). File version.py would also presumably have to be merged back to trunk after it is has been bumped following hot fixes on the release branch. Is a merge from release to trunk(main) acceptable in trunk based development for change log and version files only?

The problem would be if a new release, e.g. 1.1.0-SNAPSHOT, was then prepared for, while release branch 1.0.x was still active. Then the version number would be out of synch between trunk and release.

How is this managed with trunk based development approach?

  • you cant cherry pick features – Ewan Apr 11 at 17:21
  • Done, thanks @Ewan. Any advice on achieving semantic versioning with trunk based development? Is it possible? – dcs3spp Apr 12 at 8:39
  • you cant cherry pick fixes either – Ewan Apr 12 at 8:59
  • Hi @Ewan According to TBD: Branch For Release - section "Fix Production Bugs on Trunk", the model suggests that it is ok to fix and test on the trunk(main) and cherry pick these to a release branch, but not vice versa? – dcs3spp Apr 12 at 9:04
  • yes they are very wrong indeed – Ewan Apr 12 at 9:19
0

I would do it as follows with Semantic versioning Major.Minor.Patch.Build where {buildnumber} is replaced out by the CI with a ever increasing build number for the project as a whole and the CI build adds "-snapshot" or "-alpha" or whatever to distinguish non release builds.

Trunk
  program features
  v1.0.0.{buildnumber}
  program features
  v1.1.0.{buildnumber}
Release_1_1_x
  v1.1.0.{buildnumber}
  a fix is applied
  v1.1.1.{buildnumber}
  etc
Trunk
  v1.2.0.{buildnumber}
  program features and fixes
Release_1_2_x
  v1.2.0.{buildnumber}
  a fix is applied
  v1.2.1.{buildnumber}
  etc
Trunk
  v1.3.0.{buildnumber}
  ....

No merges, no cherry picking

  • Thanks for responding @Ewan, appreciated. Ok, I think I understand... so version held in version.py file would be patch bumped on each release branch and not merged back to trunk. On the trunk, version.py would be bumped for major/minor changes. Trying to understand the cherry-picking issue though....what happens if fix needs to be available on trunk and future releases also? – dcs3spp Apr 12 at 10:22
  • you have to do it twice – Ewan Apr 12 at 10:36
  • Thanks @Ewan, will try out versioning approach and accept answer..... – dcs3spp Apr 12 at 11:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.