Automating Git

Automating Git

By Stephen Darlington |  Jun 19, 2022  | automation

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:

  1. You branch from main to do your work.
  2. You work on your feature.
  3. You submit a PR back to main.
  4. Once the PR is approved, you merge your changes to main.
  5. 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:

  1. You tag your commit with the version number.
  2. You also tag the commit with a qa tag.
  3. Your Jenkins server notices the qa tag has moved, kicks off a build, and deploys the artifacts to your qa environment.
  4. You take these artifacts and deploy them to Staging and Production.

If you need to hotfix,

  1. You create a branch from the current production version.
  2. You commit changes to the hotfix branch.
  3. 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!