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
How does semantic-release integrate with Trunk-based development? #1529
Comments
|
Following. I'm in the same boat. |
|
my English is poor,after I read the document of semantic-release, I am confused whether semantic-release always trigger I am a fans of TBD, when implementing CD combined with TBD branch model, I have found that semver 2.0 specification makes me hard to acheive the goal : I suppose there is something like that :
alought semver does not fit what I need, I want to know whether the semantic-release project supports my idea and is willing to implement. |
|
Hello everyone, You might eventually go for a semantic-release trigger for This kind of approach would take into account two aspects of both guidelines:
Also on this road and building bits by bits. Hope these thoughts can nurture your own. |
|
Wonderful question that is not fully answered yet ! |
|
tl;dr version:
disclaimer: I'm not using semantic-release directly but I am working with repository managed with lerna which seems to be pretty close, so here's my experience:
when we cut mater branch for release we immediately increase version in master. for next minor version (by default). so if current master is "1.0.0-alpha.0" when we cut "release/1.0" all code in there is considered as release candidate, while master becomes "1.1.0-alpha.0"
we're releasing every week and haven't run into any issues
we name release branches after "major.minor": "release/1.0", "release/1.1" etc
it really does depend on specific situation imo: we do not version packages independently and we're always pinning versions of between internal libraries within same monorepo hope this helps :) |
|
After trying it in a real work life context, I sadly must report that the hypothesis we had won't work. Semantic-release works on a few conventions that requires absolutely that you release on master. So basically the only possibility is to strictly follow the current wiki recommendations: So basically yes the different comments before are good reminders on how we'd do trunk based development. But it's not what semantic-release can do. If you want to avoid yourself a few headaches, do not try to customize much the branch naming and so on. You might manage to release the first version fine, but the subsequent increments (the major ones being the worst) won't work because of the logic behind semantic-release. The only way to achieve semantic release (the concept, not the tool) to trunk based development would be to write your own tool. |
|
Can somebody here point me to a semantic-release config file based on trunk based development? |
|
apologies for neglecting this thread for so long. i have been meaning to respond but get lost each time in attempt to relate the questions in this thread to my understanding of trunk-based development. my high-level answer is that until this thread came up, this was the only flavor of trunk-based development that i was aware of. it sounds like the questions in this thread are asking about a separate variant of trunk-based development that i dont think i fully have my head around. i think the key difference may come from this point from the list of caveats on the website:
i use the latter approach and that is the one that i suggest is compatible with semantic-release. i dont understand what the value of creating the (temporary since it is mentioned that "those branches are deleted some time after release") release branches over releasing from trunk and tagging the commit where the release happened. i don't understand what hardening practices would be done from the branch that dont result in commits to the branch. if no commits are made to the branch, why branch at all? |
|
One use case I'm thinking of right now is when your customers actually aren't expecting 1 feature but a set of features. It's not a matter of "the best way to do it" because there is none (otherwise we would all do that by now) but how trunk based and its flavors can easily provide a way to answer a specific need. |
if this is the goal you are after, semantic-release may not be the tool for you. semantic-release is opinionated and is not intended to be a general workflow tool. as mentioned earlier, a core goal of semantic-release is to encourage immediate release of features that are ready for consumption. keeping the trunk always deployable is a key aspect of this and we do not want to introduce delay in making those consumable features available. if a consumer wants to wait and batch what they bring in, they can choose to update later, but there is no reason to avoid making them available. the closest to making feature batches like this work that is supported by semantic-release is to batch the changes in a larger feature branch and only merge that branch into the trunk when you are ready for release. i don't recommend this approach since i would rather encourage the separate release of each individual feature, especially to avoid blocking some behind other things in a long-lived feature branch. |
|
Yes exactly. Hence to me the answer to this issue would be that semantic-release as a tool is not fit for trunk based as it is described in the original website but fit only one of its flavor. |
i think it is worth calling out that
|
@Gyomu This is the approach I would like to follow but I can't find a way to get the config right. e.g. My goal would be to have |
|
@mowies it is basically the use case I needed too but in the end it did not work out because of the opinionated naming convention detected by the inner code of Note that you could implement such a behaviour without |
|
Aha thanks for the insights :) Currently, I am looking into the usefulness of using inner |
|
Hi, Pretty sure this could help: https://github.com/abstracter-io/atomic-release |
|
Hi 👋🏻 Let me share my take on how to version each build artefact & branching strategies. Library workflowA build which produces a library artefact is the ideal candidate for semantic versioning, it conveys meaning to us programmers.
The branching strategy i recommend, is to have a branch for each release channel which allows non In other words:
Applications workflowA build which produces an application artefact can have any version you want, it can use the git hash, the date
The branching strategy I recommend, is to have a single branch (aka trunk-based development) and using The problem with using semantic-release and trunk-based development is that versions will Not to step on anyones toes, This is exactly why atomic-release was created. An application strategy can be created where each release does not create a tag, the version is the GIT hash (or the date, whatever floats your boat), and last but not least: A failure during the release rolls back any actions taken. There is also a built in strategy to release NPM packages, similar to what the (much appreciated) semantic-release tool does. Disclaimer: I'm the author of atomic-release |
|
I found this thread from Google and it's very insightful - I believe some clarification or discussion around terms may be useful From my perspective, one of the primary goals of trunk-based development (or releasing from trunk) is that you are typically intending to decouple the actual 'release' (e.g. when PMs or Marketing get involved) from the merging of code. Branching, merges, and conflict resolution is the enemy of velocity, and so by continuously integrating into the trunk a lot of that pain is dealt with up front. Bringing branching back into the matter afterwards seems like a step back from CI, especially as mentioned above, if you're ending up with additional commits into these release branches. I believe one of the core tenets of trunk based development is feature flagging, dark shipping, or whatever you want to call it. Specifically, the ability to land code into the trunk that doesn't break the build, and, more importantly, doesn't run codepaths for new or breaking features by default. So when mentioned above, "how do you hold back multiple features from the release before they're ready" and it being incompatible with a "release every commit" strategy. I would argue that you can have the best of both worlds, and that is by ensuring you've got a toggle system of some sort so that features aren't defaulted on (where they could break users) until it's explicit. This effectively allows you to have a single release-from-trunk pipeline, while maintaining a feature strategy which allows you to dynamically choose how the code acts at any time. Power users or testers can be enabling the Then some day it's decided that Either way, these strategies is one way to accomplish the goal of decoupling these product/feature release decisions from the actual code merge, compilation, and package process. Which is why I would argue perhaps this is a terminology issue: Release from trunk doesn't always mean release a new feature, often it just means release a new build (with some new hidden feature work included). You see this in many modern packages today, the one off the top of my head is something like VSCode where the internal configuration file often allows users to opt into or select from upcoming feature changes which are "default dark" but still living inside the shipped end-user codebase. So in many cases, "release" could instead be interpreted as "publish code", while the "feature release" is an independent action (or at least, loosely coupled to the underlying codebase) The question then remains is, how does a dark-shipping trunk released app use semantic-release when it comes to commit messages? If you're queueing up feature or will-be-breaking work dark inside the codebase as you stream commits, you don't necessarily want the version number changing to reflect those changes yet. So do you use the breaking tag when you change the defaults? What do others think? |
|
Then every commit becomes a release, no? We don't have to deploy every release, either. |
|
This might help some folks. Trunk based automatic version versioning on every merge, powered by the branch naming scheme. https://github.com/marketplace/actions/gitops-automatic-versioning |
So I stumbled across this CI tool and wanted to integrate it in my new monorepo project ever since. Going through already closed "issues" asking about workflow-specific details, I've seen the recommendation to use GitHub Flow, but there also were mentions of Trunk-based development (which I prefer) being semantic-release compatible. However, I'm not sure where to start with it and how I should go about versioning, the docs are very scarce regarding information on this.
release/X.X.X)?feature/Xbranches in semantic-release?@latest?I'm eager to hear from more experienced developers at this topic!
The text was updated successfully, but these errors were encountered: