ovdashboard/deploy/chores/check_version

75 lines
2.3 KiB
Text
Raw Normal View History

2023-11-15 13:45:04 +00:00
#!/bin/sh
script="$( readlink -f "${0}" )"
script_dir="$( dirname "${script}" )"
[ "$( git rev-parse --abbrev-ref HEAD )" = "develop" ] \
&& git_status="developing"
git rev-parse --abbrev-ref HEAD | grep -E 'release|hotfix/' >/dev/null \
&& git_status="releasing"
2023-12-09 03:06:08 +00:00
git rev-parse --abbrev-ref HEAD | grep -E 'master' >/dev/null \
&& git_status="released"
if [ "${git_status}" = "developing" ]; then
2023-11-17 07:12:17 +00:00
echo "Status: Developing"
# => version from most recent tag
git_version="$( \
git describe --tags --abbrev=0 \
| sed -E 's/^v[^0-9]*((0|[1-9][0-9]*)[0-9\.]*[0-9]).*$/\1/'
)"
elif [ "${git_status}" = "releasing" ]; then
2023-11-17 07:12:17 +00:00
echo "Status: Releasing"
# => version from releasing branch
git_version="$( \
git rev-parse --abbrev-ref HEAD \
| cut -d '/' -f 2
)"
2023-12-09 03:06:08 +00:00
elif [ "${git_status}" = "released" ]; then
echo "Status: Released"
# => version from current tag
git_version="$( \
git describe --tags \
| sed -E 's/^v[^0-9]*((0|[1-9][0-9]*)[0-9\.]*[0-9])$/\1/'
)"
2023-11-17 07:12:17 +00:00
else
echo "ERROR: Invalid git branch"
echo "ERROR: Chores cannot be run on '$( git rev-parse --abbrev-ref HEAD )'!"
exit 2
fi
2023-11-15 13:45:04 +00:00
api_version="$( \
grep '^version' "${script_dir}/../../api/pyproject.toml" \
| sed -E 's/^version[^0-9]*((0|[1-9][0-9]*)[0-9\.]*[0-9]).*$/\1/'
)"
ui_version="$( \
2023-11-17 07:12:17 +00:00
grep '"version":' "${script_dir}/../../ui/package.json" \
| sed -E 's/.*"version":[^0-9]*((0|[1-9][0-9]*)[0-9\.]*[0-9]).*$/\1/'
2023-11-15 13:45:04 +00:00
)"
install_version="$( \
grep '^ovd_version' "${script_dir}/../install.sh" \
| sed -E 's/^ovd_version[^0-9]*((0|[1-9][0-9]*)[0-9\.]*[0-9]).*$/\1/'
)"
2023-11-15 14:28:03 +00:00
compose_version="$( \
grep 'image: code\.yavook\.de/oekzident\.de/ovdashboard' "${script_dir}/../docker-compose.yml" \
| sed -E 's/.*code\.yavook\.de\/oekzident\.de\/ovdashboard[^0-9]*((0|[1-9][0-9]*)[0-9\.]*[0-9]).*$/\1/'
)"
2023-11-15 13:45:04 +00:00
if [ "${git_version}" = "${api_version}" ] \
&& [ "${git_version}" = "${ui_version}" ] \
2023-11-15 14:28:03 +00:00
&& [ "${git_version}" = "${install_version}" ] \
&& [ "${git_version}" = "${compose_version}" ]; then
2023-11-15 13:45:04 +00:00
mark="✅️"
else
mark="❌️"
fi
2023-11-15 14:28:03 +00:00
echo "git: ${git_version}, api: ${api_version}, ui: ${ui_version}"
2023-11-15 22:25:32 +00:00
echo "installer: ${install_version}, compose: ${compose_version}"
echo ">>>>> RESULT: ${mark} <<<<<"
2023-11-15 14:15:31 +00:00
[ "${mark}" = "✅️" ] || exit 1