mirror of
https://github.com/mas-cli/mas
synced 2024-11-22 03:23:08 +00:00
🔨 Trigger version_bump, create branch, commit in brew_formula_update
This commit is contained in:
parent
a0e941799d
commit
da8142dc99
3 changed files with 150 additions and 22 deletions
|
@ -11,7 +11,7 @@
|
|||
|
||||
CORE_TAP_PATH="$(brew --repository homebrew/core)"
|
||||
CORE_FORMULA_PATH="${CORE_TAP_PATH}/Formula"
|
||||
MAS_FORMULA_PATH="${CORE_FORMULA_PATH}/m/mas.rb"
|
||||
CORE_MAS_FORMULA_PATH="${CORE_FORMULA_PATH}/m/mas.rb"
|
||||
|
||||
function usage {
|
||||
echo "Usage: brew_formula_update [0.0] [sha1_hash]"
|
||||
|
@ -26,7 +26,7 @@ fi
|
|||
|
||||
# arg 1 - version tag
|
||||
if test -n "$1"; then
|
||||
MAS_VERSION="v$1"
|
||||
MAS_VERSION="$1"
|
||||
else
|
||||
MAS_VERSION="v$(script/version)"
|
||||
fi
|
||||
|
@ -42,38 +42,162 @@ fi
|
|||
|
||||
echo "REVISION: $REVISION"
|
||||
|
||||
# Force brew to use the local repository instead of the API.
|
||||
# Disable API before any install, reinstall or upgrade commands.
|
||||
export HOMEBREW_NO_INSTALL_FROM_API=1
|
||||
################################################################################
|
||||
#
|
||||
# Update Version
|
||||
#
|
||||
|
||||
script/version_bump "$MAS_VERSION" "$REVISION"
|
||||
|
||||
PROJECT_PATH="$(git rev-parse --show-toplevel)"
|
||||
LOCAL_MAS_FORMULA_PATH="${PROJECT_PATH}/Homebrew/mas.rb"
|
||||
|
||||
git branch "releases/release-$MAS_VERSION"
|
||||
|
||||
git add \
|
||||
"${PROJECT_PATH}/Sources/MasKit/Package.swift" \
|
||||
"${LOCAL_MAS_FORMULA_PATH}" \
|
||||
"${PROJECT_PATH}/Homebrew/mas-tap.rb"
|
||||
|
||||
git commit --message="🔖 Version $MAS_VERSION"
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Preflight checks
|
||||
#
|
||||
|
||||
# Uninstall if necessary
|
||||
brew remove mas 2>/dev/null || true
|
||||
brew remove mas-cli/tap/mas 2>/dev/null || true
|
||||
|
||||
# Uninstall if still found on path
|
||||
if command -v mas >/dev/null; then
|
||||
script/uninstall || true
|
||||
fi
|
||||
|
||||
# Ensure core is tapped
|
||||
if ! test -d "${CORE_TAP_PATH}"; then
|
||||
brew tap homebrew/core
|
||||
fi
|
||||
|
||||
if ! test -f "${MAS_FORMULA_PATH}"; then
|
||||
brew install mas
|
||||
fi
|
||||
brew update
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Build the formula for the current macOS version and architecture.
|
||||
#
|
||||
|
||||
# Force brew to use the local repository instead of the API.
|
||||
# Disable API before any install, reinstall or upgrade commands.
|
||||
export HOMEBREW_NO_INSTALL_FROM_API=1
|
||||
|
||||
# Install mas from source
|
||||
brew reinstall mas
|
||||
|
||||
# Audit formula
|
||||
brew audit --strict mas-cli/tap/mas
|
||||
brew style mas-cli/tap/mas
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Update Homebrew
|
||||
#
|
||||
echo "Checking to see if this update can be a simple bump."
|
||||
diff "Homebrew/mas.rb" "${MAS_FORMULA_PATH}"
|
||||
diff "${LOCAL_MAS_FORMULA_PATH}" "${CORE_MAS_FORMULA_PATH}"
|
||||
|
||||
# diff exit status
|
||||
status=$?
|
||||
formula_revisions=0
|
||||
if test $status -ne 0; then
|
||||
echo "There are changes in the local formula (Homebrew/mas.rb) that haven't been released yet."
|
||||
#exit $status
|
||||
formula_revisions=1
|
||||
fi
|
||||
# status=$?
|
||||
# formula_revisions=0
|
||||
# if test $status -ne 0; then
|
||||
# echo "There are changes in the local formula (Homebrew/mas.rb) that haven't been released yet."
|
||||
# #exit $status
|
||||
# formula_revisions=1
|
||||
# fi
|
||||
|
||||
echo "==> 🧪 Updating homebrew-core formula mas ($MAS_VERSION, $REVISION)"
|
||||
|
||||
# brew bump-formula-pr --help
|
||||
# Usage: brew bump-formula-pr [options] [formula]
|
||||
|
||||
# Create a pull request to update formula with a new URL or a new tag.
|
||||
|
||||
# If a URL is specified, the SHA-256 checksum of the new download should also
|
||||
# be specified. A best effort to determine the SHA-256 will be made if not
|
||||
# supplied by the user.
|
||||
|
||||
# If a tag is specified, the Git commit revision corresponding to that tag
|
||||
# should also be specified. A best effort to determine the revision will be made
|
||||
# if the value is not supplied by the user.
|
||||
|
||||
# If a version is specified, a best effort to determine the URL and SHA-256
|
||||
# or the tag and revision will be made if both values are not supplied by the
|
||||
# user.
|
||||
|
||||
# Note: this command cannot be used to transition a formula from a
|
||||
# URL-and-SHA-256 style specification into a tag-and-revision style specification,
|
||||
# nor vice versa. It must use whichever style specification the formula already
|
||||
# uses.
|
||||
|
||||
# -n, --dry-run Print what would be done rather than doing
|
||||
# it.
|
||||
# --write-only Make the expected file modifications without
|
||||
# taking any Git actions.
|
||||
# --commit When passed with --write-only, generate a
|
||||
# new commit after writing changes to the
|
||||
# formula file.
|
||||
# --no-audit Don't run brew audit before opening the PR.
|
||||
# --strict Run brew audit --strict before opening the
|
||||
# PR.
|
||||
# --online Run brew audit --online before opening the
|
||||
# PR.
|
||||
# --no-browse Print the pull request URL instead of opening
|
||||
# in a browser.
|
||||
# --no-fork Don't try to fork the repository.
|
||||
# --mirror Use the specified URL as a mirror URL. If
|
||||
# URL is a comma-separated list of URLs,
|
||||
# multiple mirrors will be added.
|
||||
# --fork-org Use the specified GitHub organization for
|
||||
# forking.
|
||||
# --version Use the specified version to override the
|
||||
# value parsed from the URL or tag. Note that
|
||||
# --version=0 can be used to delete an
|
||||
# existing version override from a formula if
|
||||
# it has become redundant.
|
||||
# --message Prepend message to the default pull request
|
||||
# message.
|
||||
# --url Specify the URL for the new download. If a
|
||||
# URL is specified, the SHA-256 checksum of
|
||||
# the new download should also be specified.
|
||||
# --sha256 Specify the SHA-256 checksum of the new
|
||||
# download.
|
||||
# --tag Specify the new git commit tag for the
|
||||
# formula.
|
||||
# --revision Specify the new commit revision
|
||||
# corresponding to the specified git tag or
|
||||
# specified version.
|
||||
# -f, --force Remove all mirrors if --mirror was not
|
||||
# specified.
|
||||
# --install-dependencies Install missing dependencies required to
|
||||
# update resources.
|
||||
# --python-package-name Use the specified package-name when finding
|
||||
# Python resources for formula. If no package
|
||||
# name is specified, it will be inferred from
|
||||
# the formula's stable URL.
|
||||
# --python-extra-packages Include these additional Python packages when
|
||||
# finding resources.
|
||||
# --python-exclude-packages Exclude these Python packages when finding
|
||||
# resources.
|
||||
# -d, --debug Display any debugging information.
|
||||
# -q, --quiet Make some output more quiet.
|
||||
# -v, --verbose Make some output more verbose.
|
||||
# -h, --help Show this message.
|
||||
|
||||
echo "Validating formula"
|
||||
brew bump-formula-pr \
|
||||
--tag="$MAS_VERSION" \
|
||||
--revision="$REVISION" \
|
||||
--strict \
|
||||
--verbose \
|
||||
mas
|
||||
|
||||
# brew exit status
|
||||
|
@ -85,15 +209,19 @@ fi
|
|||
|
||||
pushd "$CORE_FORMULA_PATH" || exit 2
|
||||
|
||||
dry_run=''
|
||||
echo "Updating formula"
|
||||
if test $formula_revisions -eq 1; then
|
||||
# Options to
|
||||
dry_run="--dry-run --write"
|
||||
fi
|
||||
# if test $formula_revisions -eq 1; then
|
||||
# # Options to
|
||||
# dry_run="--dry-run --write"
|
||||
# fi
|
||||
|
||||
brew bump-formula-pr \
|
||||
--tag="$MAS_VERSION" \
|
||||
--revision="$REVISION" \
|
||||
--commit \
|
||||
--fork-org mas-cli \
|
||||
--online \
|
||||
--strict \
|
||||
--verbose \
|
||||
"$dry_run" \
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash -e
|
||||
#!/bin/bash -ue
|
||||
#
|
||||
# script/version
|
||||
# mas
|
||||
|
|
|
@ -46,7 +46,7 @@ echo "REVISION: $REVISION"
|
|||
cat <<EOF >"${PACKAGE_MANIFEST}"
|
||||
// Generated by: script/version
|
||||
enum Package {
|
||||
static let version = "${MAS_VERSION}"
|
||||
static let version = "${MAS_VERSION#v}"
|
||||
}
|
||||
EOF
|
||||
|
||||
|
|
Loading…
Reference in a new issue