Automatic version updates in manifest.json

I have a few browser plugins and when making a release, I often forget to change the version. The plugin repositories don't allow a push for an existing version, so I get an error. As I only ever change the minor version, I wrote a small shell script that uses jq and bash to update the last field of the version automatically.

#!/usr/bin/env bash

MANIFEST=plugin/manifest.json

# get current version and split the fields into an array
IFS='.' read -r -a fields <<< $(jq -r .version $MANIFEST)

# extract the last field of the version and increment 
last=$((${fields[-1]}+1))

# remove last field from array
unset fields[-1]

# append updated last field
fields+=($last)

# join everything into a string
version=$(IFS=. ; echo "${fields[*]}")

# create JSON manifest with new version
jq --arg version $version '.version=$version' $MANIFEST > $MANIFEST.tmp
mv $MANIFEST.tmp $MANIFEST

This means I'll never run into an error regarding the version again.