Question

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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
scroll top