>_ IzzyLab

Hands-on task

This task is step 1 of the course “Shipping a release”

Bump the release's minor version

medium~10 min

Release day starts with a version bump. /srv/billing/VERSION contains the current version in the X.Y.Z format. Write an executable script /usr/local/bin/bump-minor that increments minor (the middle number) by 1, resets patch to 0 and writes the result back to the same file. For example 2.3.7 → 2.4.0, 0.9.12 → 0.10.0.

What you'll practise:
  • bash
  • semver
  • ifs
  • arithmetic
  • version bump

Topic breakdown

Under semantic versioning MAJOR.MINOR.PATCH, new functionality that doesn't break compatibility bumps minor, and patch is reset to zero: 2.3.7 is followed by 2.4.0, not 2.4.7. A bump script splits the string into three numbers, changes the ones it needs and puts them back together. In bash you don't need external tools for parsing: read with the separator IFS=. splits the string into variables, and $(( )) does integer arithmetic — so 9 becomes 10, not 91 as with string concatenation. The result overwrites the file (>), otherwise the version gets duplicated.

What's checked

  1. bump-minor script is executable
  2. 2.3.7 → 2.4.0
  3. 0.9.12 → 0.10.0
  4. 3.0.0: major doesn't change

What it looks like