diff --git a/.gitignore b/.gitignore index b6f0762..59766e3 100644 --- a/.gitignore +++ b/.gitignore @@ -57,6 +57,11 @@ /lib/** !/lib/*.sh +## Script +!/script/ +/script/** +!/script/*.sh + ## Test !/spec/ /spec/** diff --git a/.shellspec b/.shellspec index f731fd0..509f53c 100644 --- a/.shellspec +++ b/.shellspec @@ -8,6 +8,6 @@ ## kcov (coverage) --covdir _coverage/ ---kcov-options "--exclude-pattern=/_coverage/,/_report/,/spec/,/.shellcheckrc,/.shellspec" +--kcov-options "--exclude-pattern=/_coverage/,/_report/,/script/,/spec/,/.shellcheckrc,/.shellspec" --kcov-options "--include-path=. --path-strip-level=1" --kcov-options "--include-pattern=.sh" diff --git a/RELEASE.md b/RELEASE.md index 5a9968a..c861598 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -18,8 +18,13 @@ found in this file (using v0.1.2 as an example): git clone git@github.com:ericcornelissen/tool-versions-update-action.git ``` -1. Update the version number in the `.version` file following [Semantic - Versioning]: +1. Update the version number following [Semantic Versioning]: + + ```shell + ./script/version-bump.sh [major|minor|patch] + ``` + + Or edit the `.version` file manually: ```diff - 0.1.1 diff --git a/script/version-bump.sh b/script/version-bump.sh new file mode 100755 index 0000000..007ccca --- /dev/null +++ b/script/version-bump.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# SPDX-License-Identifier: MIT-0 + +# --- Setup ------------------------------------------------------------------ # + +set -eo pipefail + +type="$1" + +version=$(grep -o '[^-]*$' <.version) +major=$(echo "${version}" | cut -d. -f1) +minor=$(echo "${version}" | cut -d. -f2) +patch=$(echo "${version}" | cut -d. -f3) + +# --- Script ----------------------------------------------------------------- # + +if [[ "${type}" == "patch" ]]; then + patch=$((patch + 1)) +elif [[ "${type}" == "minor" ]]; then + minor=$((minor + 1)) + patch=0 +elif [[ "${type}" == "major" ]]; then + major=$((major + 1)) + minor=0 + patch=0 +elif [[ -z "${type}" ]]; then + echo "Provide an update type, one of 'major', 'minor', or 'patch'" + exit 1 +else + echo "Unknown update type '${type}'" + exit 1 +fi + +echo "${major}.${minor}.${patch}" >.version