|
17 | 17 |
|
18 | 18 | set -eo pipefail |
19 | 19 |
|
20 | | -# echo "Installing shtdlib" |
| 20 | +echo "Installing shtdlib" |
21 | 21 | shtdlib_local_path="/usr/local/bin/shtdlib.sh" |
22 | 22 | sudo curl -s -L -o "${shtdlib_local_path}" https://github.com/sdelements/shtdlib/raw/master/shtdlib.sh |
23 | 23 | sudo chmod 775 "${shtdlib_local_path}" |
24 | 24 | # shellcheck disable=SC1091,SC1090 |
25 | 25 | source "${shtdlib_local_path}" |
26 | 26 | color_echo green "shtdlib.sh installed successfully" |
27 | 27 |
|
| 28 | +version_pattern='v\d+\.\d+\.\d+(?:qa)?' |
| 29 | +version_pattern_line="^${version_pattern}$" |
| 30 | + |
28 | 31 | # Get the latest tag from GitHub |
29 | 32 | latest_tag="$(git fetch -t && git tag -l | sort --version-sort | tail -n1)" |
30 | | -color_echo green "Latest Git tag: '${latest_tag}'" |
| 33 | +color_echo green "Latest Git tag from repo: '${latest_tag}'" |
31 | 34 |
|
32 | 35 | # Get the latest tag from the CHANGELOG |
33 | | -changelog_ver="$(grep -oP '\[v\d\.\d\.\d\]' CHANGELOG.md | tr -d '[]' | sort -nr | head -n1)" |
| 36 | +changelog_ver="$(grep -oP "\[${version_pattern}\]" CHANGELOG.md | tr -d '[]' | sort --version-sort -r | head -n1)" |
34 | 37 | color_echo green "CHANGELOG version: '${changelog_ver}'" |
35 | 38 |
|
36 | 39 | # 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 |
| 40 | +echo "${latest_tag}" | grep -qP "${version_pattern_line}" || ( color_echo red "Invalid tag from repo: '${latest_tag}'" && exit 1 ) |
| 41 | +echo "${changelog_ver}" | grep -qP "${version_pattern_line}" || ( color_echo red "Invalid tag from CHANGELOG: '${changelog_ver}'" && exit 1 ) |
| 42 | + |
| 43 | +# Check if a tag triggered the build |
| 44 | +if [[ -z "${TRAVIS_TAG}" ]]; then |
| 45 | + # Ensure tags in CHANGELOG and iteration are greater than highest repo tag |
| 46 | + if [ "${latest_tag}" = "${changelog_ver}" ] \ |
| 47 | + || ! compare_versions "${latest_tag}" "${changelog_ver}"; then |
| 48 | + color_echo red "Error: Incorrect version update. CHANGELOG.md (${changelog_ver}) not updated" |
| 49 | + exit 1 |
| 50 | + else |
| 51 | + color_echo green "Version bumps PASS!" |
| 52 | + fi |
46 | 53 | else |
47 | | - color_echo green "Version bumps PASS!" |
| 54 | + color_echo green "Newly created tag: '${TRAVIS_TAG}'" |
| 55 | + # Validate version strings |
| 56 | + echo "${TRAVIS_TAG}" | grep -qP "${version_pattern_line}" || ( color_echo red "Invalid tag name created: '${TRAVIS_TAG}'" && exit 1 ) |
| 57 | + |
| 58 | + # Ensure all the tags match up |
| 59 | + if [ ! "${TRAVIS_TAG}" = "${changelog_ver}" ]; then |
| 60 | + color_echo red "Error: tag version (${TRAVIS_TAG}) should match CHANGELOG.md (${changelog_ver})" |
| 61 | + exit 1 |
| 62 | + else |
| 63 | + color_echo green "Version bumps PASS!" |
| 64 | + fi |
48 | 65 | fi |
0 commit comments