Git Tagging & Releases
What is Git Tagging?
Why should Bitwise care?
This should be self-evident. More maintainable code makes our jobs easier! Tagging does the following things:
- Provides markers for points in our development cycle such as releases, patches, hotfixes, etc.
- Keeps in-development projects organized by allowing for pre-releases (ie. 0.1.0, 0.2.0) that can be mapped to specific milestones.
- Allows for quicker set-up time for new developers being added to your project.
- Helps us to avoid introducing major breaking changes unintentionally for enforcing the major/minor/patch methodology.
How do I do it?
Glad you asked! Because of our reliance on Git and GitHub.com, we have some pretty awesome out of the box tools we can use to implement SemVer right now!
Let’s go through our use cases:
I need to create my project’s first version
- Get your code to a place you’re happy with
i.e. no console.logs, errant code, everything works, etc.
- Create a Git tag using
git tag v0.1.0
or git tag -a v0.1.0
.
Your team will have to decide what minor version to start with if you’ve already begun development.
- Push your tag to GitHub.com using
git push origin <YOUR-TAG-NAME>
Note: < YOUR-TAG-NAME > would be replaced by v0.1.0
in our above example and *must* match.
- If this is a release (i.e. you are going to deploy this for the client to test, or it is an update to a production app that will go live) create a release on
GitHub.com
.
I need to increment my project’s patch version
- Be sure your hotfix or bugfix changes have been reviewed and approved by your project’s lead developer.
- Once the fix is approved and your Pull Request is merged, checkout to your base branch (develop or main, whatever you use as your source of truth) and pull your changes.
- Create your tag using
git tag v0.1.1
, remembering to increment from the last patch version, but keeping the major and minor versions the same.
- Push your tag to GitHub.com using
git push origin <YOUR-TAG-NAME>
Note: < YOUR-TAG-NAME > would be replaced by v0.1.1
in our above example and *must* match.
I need to increment my project’s minor version
- Be sure your feature branch changes have been reviewed and approved by your project’s lead developer.
- Checkout to your base branch (develop or main, whatever you use as your source of truth) and pull your changes.
- Create your tag using
git tag v0.2.0
, remembering to increment from the last minor version, keeping the major version the same and resetting the patch version to 0.
- Push your tag to GitHub.com using
git push origin <YOUR-TAG-NAME>
Note: < YOUR-TAG-NAME > would be replaced by v0.2.0
in our above example and *must* match.
I need to increment my project’s major version
- Be sure your reverse-incompatable, breaking changes have been reviewed and approved by your project’s lead developer.
- Make a plan for your rollout to users with your client and make sure your deployment follows that plan.
- Checkout to your base branch (develop or main, whatever you use as your source of truth) and pull your changes.
- Create your tag using
git tag v1.0.0
, remembering to increment from the last major version and resetting your minor and patch versions to 0.
- Push your tag to GitHub.com using
git push origin <YOUR-TAG-NAME>
Note: < YOUR-TAG-NAME > would be replaced by v1.0.0
in our above example and *must* match.
I need to create a Release
Releases are useful for marking a client-facing milestones in your code’s history. Your project lead should determine when and how often a tag should be marked as a release.
- Make sure that your tag has been pushed to GitHub.
- Click on
releases
on the code tab of your repository.
- Click the button labelled
Draft a new release
.
- Enter your tag’s name (must be exact) into the input to target your desired tag.
It is possible to target a branch’s current state as your release, but this is *not* advisable.
- Enter a title for your release that makes contextual sense for the release’s contained changes.
- Include any release notes that your team has deemed important or necessary for each release. Generally these notes should include:
- A brief summary of feature changes or hotfixes that are included.
- Additional notes for users of the code that are pertinent for the code base.
- If you want to, you can include a diff link (provided automatically by GitHub) to view the differences between any two tags in your code base. As long as you have two or more tags, this can be accomplished by including a standard markdown link with the following format:
https: //github .com /shift3/ < your-repository-name > /compare/< original-tag-name >…< new-tag-name >
_example: https://github.com/Shift3/ifg/compare/v0.4.0…v0.5.0
Resources
Git Tagging Docs
SemVer Main Docs
SemVer Breakdown
Convincing Argument for SemVer
Slides for Tagging at Bitwise