Version bumping with Uplift

May 23, 2024·
Mani Soundararajan
Mani Soundararajan
· 3 min read

Making a software release involves a bunch of boring routine tasks - with Uplift you can automate all of it.

Uplift

With Uplift, you can do three things at once:

  1. Bump the version number
  2. Update your changelog
  3. Tag and push

And all it takes is to run:

$ uplift release

Uplift installation instructions

Conventional commits

Before you can leverage Uplift, you should ensure all your git commit messages are following the Official Conventional Commits standard. You can also refer to my post on conventional commits.

When you write commit messages like feat: add payment module or fix: update payment flow, Uplift is able to parse those messages and determine whether the number needs to be bumped at major, minor or patch version.

If all your changes are fix type commits, Uplift will bump the patch version.

If one your changes is a feat type commit, Uplift will bump the minor version.

If any of your commits have breaking change, like fix! or feat!, Uplift will bump the major version.

Other than this, Uplift is also able to parse commit messages and come up with a Changelog for the current release. This will be automatically updated in a Changelog.md file.

Configuration

Uplift expects the configuration to be stored in a file like .uplift.yaml (there are some other file name patterns that are supported). This file will contain configuration related to which file version needs to be bumped and so on.

Let’s look at an example:

# uplift.yaml
# see https://upliftci.dev/
bumps:
  - file: main.go
    regex:
      - pattern: 'const appVersion = "$VERSION"'
        semver: true
annotatedTags: true
changelog:
  exclude:
    - "chore"
    - "refactor"
    - "style"
    - "test"
    - "wip"
commitMessage: "chore(release): $VERSION"

This file instructs Uplift to bump the version in main.go in a line that matches the regex pattern const appVersion = "$VERSION". For example:

package main

import "log"

const appVersion = "v0.1.0"

func main() {
  log.Println("Helloworld", appVersion)
}

To this, you add a bug fix and change Helloworld into two words Hello world. Make sure the commit messages says something like fix: split helloworld into two words. Now if you run uplift release, you would get:

package main

import "log"

const appVersion = "v0.1.1"

func main() {
  log.Println("Helloworld", appVersion)
}

Uplift has bumped the patch version. It has also added a section to the Changelog.md file:

## [v0.1.1]

- fix: split helloworld into two words

And lastly, Uplift has created a git tag v0.1.1 and pushed it to the git remote origin.

Demo

I have created a repo to demonstrate conventional commits and uplift:

Github repo

Commit created by uplift

Tag created by uplift

References