mirror of
https://github.com/mas-cli/mas
synced 2024-12-05 01:39:11 +00:00
56 lines
1.2 KiB
Bash
Executable file
56 lines
1.2 KiB
Bash
Executable file
#!/bin/bash -e
|
|
#
|
|
# script/version_bump
|
|
# mas
|
|
#
|
|
# Increments the marketing version of mas.
|
|
#
|
|
|
|
PROJECT_PATH="$(git rev-parse --show-toplevel)"
|
|
LOCAL_MAS_FORMULA_PATH="${PROJECT_PATH}/Homebrew/mas.rb"
|
|
LOCAL_TAP_FORMULA_PATH="${PROJECT_PATH}/Homebrew/mas-tap.rb"
|
|
SWIFT_PACKAGE="${PROJECT_PATH}/Sources/MasKit/Package.swift"
|
|
|
|
function usage {
|
|
echo "Usage: version_bump v0.0 [sha1_hash]"
|
|
echo "- existing tag name"
|
|
echo "- sha will be inferred from the given tag if not provided"
|
|
exit 1
|
|
}
|
|
|
|
if [[ $# -lt 1 ]]; then
|
|
usage
|
|
fi
|
|
|
|
# arg 1 - version tag
|
|
if test -n "${1}"; then
|
|
MAS_VERSION="${1}"
|
|
fi
|
|
|
|
# arg 2 - revision (commit hash)
|
|
if test -n "${2}"; then
|
|
REVISION="${2}"
|
|
else
|
|
REVISION=$(git rev-parse "${MAS_VERSION}")
|
|
fi
|
|
|
|
echo "MAS_VERSION: ${MAS_VERSION}"
|
|
echo "REVISION: ${REVISION}"
|
|
|
|
# Write new version into swift package
|
|
cat <<EOF >"${SWIFT_PACKAGE}"
|
|
// Generated by: script/version
|
|
enum Package {
|
|
static let version = "${MAS_VERSION#v}"
|
|
}
|
|
EOF
|
|
|
|
echo
|
|
cat "${SWIFT_PACKAGE}"
|
|
|
|
# Write new version into brew formulae
|
|
for file in ${LOCAL_MAS_FORMULA_PATH} ${LOCAL_TAP_FORMULA_PATH}; do
|
|
echo "${file}"
|
|
sd '( +tag: +)"[^"]+"' "\$1\"${MAS_VERSION}\"" "${file}"
|
|
sd '( +revision: +)"[^"]+"' "\$1\"${REVISION}\"" "${file}"
|
|
done
|