Automating Git
In software development, there are a lot of repetitive tasks. For example, creating releases in git, creating hotfix branches, etc. Because developers are lazy (read: efficient), we like to create scripts to automate things. To that end, I’ve created a couple small python scripts to help you automate this.
Your branching process may be different from this, but here’s an example workflow:
- You branch from
main
to do your work. - You work on your feature.
- You submit a PR back to
main
. - Once the PR is approved, you merge your changes to
main
. - Your Jenkins server (or other CI tool) notices a new commit to main, kicks off a build, and deploys the changes to your dev environment.
When it comes time to release:
- You tag your commit with the version number.
- You also tag the commit with a
qa
tag. - Your Jenkins server notices the
qa
tag has moved, kicks off a build, and deploys the artifacts to your qa environment. - You take these artifacts and deploy them to Staging and Production.
If you need to hotfix,
- You create a branch from the current production version.
- You commit changes to the hotfix branch.
- You build your artifacts off this hotfix branch.
If this is your workflow, you can simply take my python scripts directly from github.
The first script, release.py
, will take a version number, tag the commit, move the qa
tag, and push the tags to your remote repo.
The second script, hotfix.py
, will branch of a specified tag and push that branch to your remote repo.
Happy coding!