2024-09-30 15:28:25 +00:00
|
|
|
#!/bin/bash -eu
|
2019-01-13 07:18:35 +00:00
|
|
|
#
|
|
|
|
# script/version
|
|
|
|
# mas
|
|
|
|
#
|
2019-01-19 04:37:51 +00:00
|
|
|
# Displays the current marketing version of mas.
|
2019-01-13 07:18:35 +00:00
|
|
|
#
|
|
|
|
|
2024-09-30 15:28:25 +00:00
|
|
|
mas_dir="$(readlink -fn "$(dirname "${BASH_SOURCE:-"${0}"}")/..")"
|
|
|
|
|
|
|
|
if ! cd -- "${mas_dir}"; then
|
|
|
|
printf $'Error: Could not cd into mas directory: %s\n' "${mas_dir}" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-10-27 11:26:46 +00:00
|
|
|
if [[ -z "${MAS_VERSION:-}" ]] && git describe >/dev/null 2>&1; then
|
2024-10-27 03:48:05 +00:00
|
|
|
# Use last tag if MAS_VERSION environment variable is unset or empty
|
|
|
|
MAS_VERSION=$(git describe --abbrev=0 --tags 2>/dev/null || true)
|
|
|
|
fi
|
|
|
|
echo "${MAS_VERSION#v}"
|
2021-04-28 19:20:40 +00:00
|
|
|
|
2024-10-27 03:48:05 +00:00
|
|
|
if [[ "${#}" -ge 1 && "${1}" == '--write' ]]; then
|
|
|
|
# Write new version into swift package
|
|
|
|
cat <<EOF >Sources/mas/Package.swift
|
2024-10-21 11:10:31 +00:00
|
|
|
/// Generated by \`script/version\`.
|
2021-04-28 19:20:40 +00:00
|
|
|
enum Package {
|
2024-10-27 03:48:05 +00:00
|
|
|
static let version = "${MAS_VERSION#v}"
|
2021-04-28 19:20:40 +00:00
|
|
|
}
|
|
|
|
EOF
|
2024-02-18 17:46:53 +00:00
|
|
|
fi
|