20 lines
650 B
Bash
20 lines
650 B
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
if (( $# > 1 )); then
|
|
echo "usage: version.sh [VERSION]" >&2
|
|
exit 1
|
|
fi
|
|
|
|
version_file="$(dirname "$0")/../../src/cloud/lunarsky/store/Version.java"
|
|
version="$(sed -nE 's/^[[:space:]]*static final String VALUE = "([^"]+)";[[:space:]]*$/\1/p' "$version_file")"
|
|
if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+([.-][A-Za-z0-9]+)*$ ]]; then
|
|
echo "Cannot determine the source version from Version.java" >&2
|
|
exit 1
|
|
fi
|
|
if [[ -n "${1:-}" && "$1" != "$version" ]]; then
|
|
echo "Requested version $1 does not match source version $version; build from the matching source tag" >&2
|
|
exit 1
|
|
fi
|
|
printf '%s\n' "$version"
|