mirror of
https://github.com/mas-cli/mas
synced 2024-11-22 03:23:08 +00:00
🔨 Write new version in brew formulae
This commit is contained in:
parent
6a80ac3702
commit
a0e941799d
1 changed files with 34 additions and 5 deletions
|
@ -6,23 +6,43 @@
|
|||
# Increments the marketing version of mas.
|
||||
#
|
||||
|
||||
|
||||
# SCRIPT_PATH=$(dirname "$(which "$0")")
|
||||
PROJECT_PATH="$(git rev-parse --show-toplevel)"
|
||||
PACKAGE_MANIFEST="${PROJECT_PATH}/Sources/MasKit/Package.swift"
|
||||
LOCAL_MAS_FORMULA_PATH="${PROJECT_PATH}/Homebrew/mas.rb"
|
||||
LOCAL_TAP_FORMULA_PATH="${PROJECT_PATH}/Homebrew/mas-tap.rb"
|
||||
|
||||
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
|
||||
|
||||
last_tag=$(script/version)
|
||||
echo "Last git tag: $last_tag"
|
||||
|
||||
# arg 1 - version tag
|
||||
if test -n "$1"; then
|
||||
# auto-increment
|
||||
MAS_VERSION=$1
|
||||
fi
|
||||
|
||||
# arg 2 - revision (commit hash)
|
||||
if test -n "$2"; then
|
||||
REVISION="$2"
|
||||
else
|
||||
next_tag=$last_tag
|
||||
MAS_VERSION=$next_tag
|
||||
REVISION=$(git rev-parse "$MAS_VERSION")
|
||||
fi
|
||||
|
||||
echo "MAS_VERSION: $MAS_VERSION"
|
||||
echo "REVISION: $REVISION"
|
||||
|
||||
# Write new version into swift package
|
||||
SCRIPT_PATH=$(dirname "$(which "$0")")
|
||||
PACKAGE_MANIFEST="${SCRIPT_PATH}/../Sources/MasKit/Package.swift"
|
||||
cat <<EOF >"${PACKAGE_MANIFEST}"
|
||||
// Generated by: script/version
|
||||
enum Package {
|
||||
|
@ -33,3 +53,12 @@ EOF
|
|||
echo
|
||||
cat "${PACKAGE_MANIFEST}"
|
||||
|
||||
# Write new version into brew formulae
|
||||
for file in $LOCAL_MAS_FORMULA_PATH $LOCAL_TAP_FORMULA_PATH; do
|
||||
echo "$file"
|
||||
# echo sed -i "5s/(\w+tag:\w+\"\)v[^\"]\",/$0$MAS_VERSION\"/" "$file"
|
||||
# sed -i '' -E "s/(\w+tag:\w+\")v,/\1$MAS_VERSION\"/" "$file"
|
||||
sd '( +tag: +)"[^"]+"' "\$1\"$MAS_VERSION\"" "$file"
|
||||
sd '( +revision: +)"[^"]+"' "\$1\"$REVISION\"" "$file"
|
||||
done
|
||||
|
||||
|
|
Loading…
Reference in a new issue