Open evansd opened 1 year ago
I really like this proposal. A question: If we didn't tag a version on merge to main
, then the version that could be computed from the trailers could differ from the tagged version, couldn't it? For example, consider the following sequence:
v0.0.1
Bump-Version: major
main
Bump-Version: major
main
The version that could be computed from the trailers is v2.0.0
. However, the tagged version is v0.0.1
.
I think it's fine that the computed version could differ from the tagged version, because a user wouldn't be affected; they would be working with a published version (of a Python package, of a Docker image, etc.). However, I had to remind myself that this proposal decouples the nature of a PR from tagging a version.
Yes, that's right. You could think of the computed version (as you called it) as being "what the version would be if we decided to release this as yet unreleased code".
Below is a description of how I'd like our automatic versioning/publishing system to work. I've added it as an issue here for lack of a better place to record these thoughts. A couple of preliminary remarks:
Bump-Version: major
just to have something concrete to talk about. I have no real opinions on the naming of things here.I envision the workflow as consisting of three actions.
1. Check the PR is annotated correctly
To be run whenever a PR is created or its body (aka description) is edited.
The key points are:
The PR body should be thing that gets annotated with magic strings to bump versions:
We should use the
git-trailer
format for our magic strings:Bump-Version: major
The action should fail the PR if it doesn't have a trailer with a valid value.
If the action doesn't find a matching trailer at all, it should insert a placeholder:
Bump-Version:
. If the action doesn't find such a trailer in the PR body it should insert into the PR body something like:Bump-Version: major/minor/patch/none (choose one)
Bump-Version
trailer) but it should be immediately obvious to the PR author how to fix it without having to remember the syntax.2. Tag new versions
This could be run on every merge to main, as we currently do. Or for some projects (opensafely-cli perhaps?) we might want to make it a manually dispatched workflow so we can control when we cut a new release.
This would need to:
3. Ensure latest version is published
The key thing here (especially given the flakiness of Github's CI) is to make this an idempotent ratchet, rather than anything stateful. It's job is:
We'll obviously want to run this whenever we tag a new version. But there's no real harm in running it more often (e.g. every merge) as it's safe by design. It should also be manually dispatchable to allow us to retry following inevitable flakiness.