|
| 1 | +#!/bin/bash |
| 2 | +# |
| 3 | +# Copyright (c) 2018 SD Elements Inc. |
| 4 | +# |
| 5 | +# All Rights Reserved. |
| 6 | +# |
| 7 | +# NOTICE: All information contained herein is, and remains |
| 8 | +# the property of SD Elements Incorporated and its suppliers, |
| 9 | +# if any. The intellectual and technical concepts contained |
| 10 | +# herein are proprietary to SD Elements Incorporated |
| 11 | +# and its suppliers and may be covered by U.S., Canadian and other Patents, |
| 12 | +# patents in process, and are protected by trade secret or copyright law. |
| 13 | +# Dissemination of this information or reproduction of this material |
| 14 | +# is strictly forbidden unless prior written permission is obtained |
| 15 | +# from SD Elements Inc.. |
| 16 | +# Version |
| 17 | + |
| 18 | +set -eo pipefail |
| 19 | + |
| 20 | +# echo "Installing shtdlib" |
| 21 | +shtdlib_local_path="/usr/local/bin/shtdlib.sh" |
| 22 | +sudo curl -s -L -o "${shtdlib_local_path}" https://github.com/sdelements/shtdlib/raw/master/shtdlib.sh |
| 23 | +sudo chmod 775 "${shtdlib_local_path}" |
| 24 | +# shellcheck disable=SC1091,SC1090 |
| 25 | +source "${shtdlib_local_path}" |
| 26 | +color_echo green "shtdlib.sh installed successfully" |
| 27 | + |
| 28 | +# Get the latest tag from GitHub |
| 29 | +latest_tag="$(git fetch -t && git tag -l | sort --version-sort | tail -n1)" |
| 30 | +color_echo green "Latest Git tag: '${latest_tag}'" |
| 31 | + |
| 32 | +# Get the latest tag from the CHANGELOG |
| 33 | +changelog_ver="$(grep -oP '\[v\d\.\d\.\d\]' CHANGELOG.md | tr -d '[]' | sort -nr | head -n1)" |
| 34 | +color_echo green "CHANGELOG version: '${changelog_ver}'" |
| 35 | + |
| 36 | +# Validate version strings |
| 37 | +version_pattern='^v\d\.\d\.\d$' |
| 38 | +echo "${latest_tag}" | grep -qP ${version_pattern} || ( color_echo red "Invalid tag from repo: '${latest_tag}'" && exit 1 ) |
| 39 | +echo "${changelog_ver}" | grep -qP ${version_pattern} || ( color_echo red "Invalid tag from CHANGELOG: '${changelog_ver}'" && exit 1 ) |
| 40 | + |
| 41 | +# Ensure tags in CHANGELOG and iteration are greater than highest repo tag |
| 42 | +if [ "${latest_tag}" = "${changelog_ver}" ] \ |
| 43 | + || ! compare_versions "${latest_tag}" "${changelog_ver}"; then |
| 44 | + color_echo red "Error: Version in CHANGELOG.md not updated" |
| 45 | + exit 1 |
| 46 | +else |
| 47 | + color_echo green "Version bumps PASS!" |
| 48 | +fi |
0 commit comments