Release the power of your code!
Releases are created to bundle and deliver iterations of a project;
they are based on Gittags, which mark a specific point in the repository’s history.
Creating a release
When the code on develop branch is stable and ready for a new release:
-
Update files like
CHANGELOG.mdand project configuration (package.jsonfor example) (if any, otherwise go to step 3):- In the
package.jsononly the version number changes (see Versioning) - the
changelogis filled by the list of all PR’s from the latest release till now; the list can be grouped by scope (fix, change, new feature).
Tip: Even if we are not actually going to release at this exact point, we can use the feature that
GitHubprovides on theRelease pageto generate our changelog: just give a temporary tag, put ourdevelopbranch as the target, and click onGenerate release notesbutton - In the
-
Pushthis small update with no business logic directly to develop branch, without any PR (usually with a commit message like:Bump version to v0.0.1).
We will make sure that thedev CI/CDpipeline won’t be triggered by this merge.(see CI/CD - wip not ready yet)Note: To perform direct push on a
long-lived branchsuch asdevelop, you must have the right role permissions or the branch must not have protection rules that do not allow direct push. Even if they are simple textual changes, we must always be careful making direct push on long-lived branches. -
Make a PR from
developtomasterbranch, naming it asRelease <tag name>(Release v0.0.1 for example). -
After the PR is merged to
masterbranch, create a gittaglocally:- Switch to
masterbranch (the long-lived branch used for the releases) and pull changes - Create an
annotated tagwithgit tag -a v0.0.1 -m "Release v0.0.1" - Now push the
local tagto remote withgit push origin v0.0.1
Pushing the
tagcan be useful to trigger the staging/testingCI/CD pipeline(see CI/CD - wip not ready yet) - Switch to
-
If tests passes (your smoke test, test suites, test by human tester, etc.) and no other bugfix are needed, from GitHub
Releasespage click on theCreate a new releasebutton:- select the previous created
tag - put the same tag name as title of the release
- use
Auto generate release notesto generate the release changelog from the list of PR’s Publishthe release 🏆
- select the previous created
-
At this point, switching to
developbranch we are behindmasterby 1 commit (the Release PR, remenber you?):
makegit merge origin/masterand thengit pushto realign both branches at the same commit (local and remote). (see the note below)
In this moment the
release(the tag),masteranddevelopbranches points exactly at the same commit in the history
Note: point 6 is needed because in the repo we have the branch develop set as the working branch (from where all new feture branches will start) while master is the release branch
Versioning
It’s a good practice to use a valid versioning convention.
One of the most widely used (and the one I prefer) is Semantic Versioning
So, given a version number MAJOR.MINOR.PATCH, increment the:
MAJORversion when you make incompatible API changes (breaking changes)MINORversion when you add functionality in a backwards compatible manner (new feature)PATCHversion when you make backwards compatible bug fixes (bugfix)