mirror of
https://github.com/mas-cli/mas
synced 2024-11-24 20:43:10 +00:00
f9ce4136e4
Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
30 lines
752 B
Bash
Executable file
30 lines
752 B
Bash
Executable file
#!/bin/bash -eu
|
|
#
|
|
# script/version
|
|
# mas
|
|
#
|
|
# Displays the current marketing version of mas.
|
|
#
|
|
|
|
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
|
|
|
|
if [[ -z "${MAS_VERSION:-}" ]] && git describe >/dev/null 2>&1; then
|
|
# 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}"
|
|
|
|
if [[ "${#}" -ge 1 && "${1}" == '--write' ]]; then
|
|
# Write new version into swift package
|
|
cat <<EOF >Sources/mas/Package.swift
|
|
/// Generated by \`script/version\`.
|
|
enum Package {
|
|
static let version = "${MAS_VERSION#v}"
|
|
}
|
|
EOF
|
|
fi
|