-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create script to automatically bump the version in
.version
(#147)
Initialize the `script/` directory dedicated to scripts used during development. The only script currently present automates the process of updating the `.version` file for a release based on the argument that is provided ('major', 'minor', or 'patch'). The Release Guidelines have been updated to prefer the use of this script when creating a release, maintaining the manual instructions in case the script doesn't work. The script is intentionally given the MIT-0 (aka 'no attribution') license identifier as the intent is for it to be easier to re-use, that is without requiring attribution upon re-use. The intend is that all homegrown scripts will use this less restrictive license.
- Loading branch information
1 parent
ed686a6
commit 74adf96
Showing
4 changed files
with
47 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,11 @@ | |
/lib/** | ||
!/lib/*.sh | ||
|
||
## Script | ||
!/script/ | ||
/script/** | ||
!/script/*.sh | ||
|
||
## Test | ||
!/spec/ | ||
/spec/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |