mirror of
https://github.com/mas-cli/mas
synced 2025-02-17 21:18:24 +00:00
Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com> # Manual Merge Cleanup: # .actrc # .github/workflows/pr-checks.yml # .github/workflows/release.yml # Brewfile # script/test # script/version_bump # Conflicts: # .github/workflows/build-test.yml # .gitignore # .swiftlint.yml # Brewfile.lock.json # Package.resolved # Sources/mas/Package.swift # Tests/masTests/.swiftlint.yml # script/bootstrap # script/build # script/format # script/lint # script/uninstall # script/version
61 lines
1.4 KiB
Bash
Executable file
61 lines
1.4 KiB
Bash
Executable file
#!/bin/bash -eu
|
|
#
|
|
# script/version_bump
|
|
# mas
|
|
#
|
|
# Increments the 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
|
|
|
|
LOCAL_MAS_FORMULA_PATH="Homebrew/mas.rb"
|
|
LOCAL_TAP_FORMULA_PATH="Homebrew/mas-tap.rb"
|
|
SWIFT_PACKAGE="Sources/mas/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
|
|
MAS_VERSION="${1}"
|
|
|
|
# arg 2 - revision (commit hash)
|
|
if [[ "${#}" -ge 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_bump\`.
|
|
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}"
|
|
sd '( +root_url "https://github.com/mas-cli/mas/releases/download/v).+' "\${1}${MAS_VERSION}\"" "${file}"
|
|
done
|