From da8142dc99a25f0b596c26b778dc2fcc1b2462d4 Mon Sep 17 00:00:00 2001 From: Ben Chatelain Date: Sun, 10 Mar 2024 09:03:03 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20Trigger=20version=5Fbump,=20crea?= =?UTF-8?q?te=20branch,=20commit=20in=20brew=5Fformula=5Fupdate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/brew_formula_update | 168 ++++++++++++++++++++++++++++++++----- script/version | 2 +- script/version_bump | 2 +- 3 files changed, 150 insertions(+), 22 deletions(-) diff --git a/script/brew_formula_update b/script/brew_formula_update index 56b3f93..61f502f 100755 --- a/script/brew_formula_update +++ b/script/brew_formula_update @@ -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" \ diff --git a/script/version b/script/version index d954703..561b9e3 100755 --- a/script/version +++ b/script/version @@ -1,4 +1,4 @@ -#!/bin/bash -e +#!/bin/bash -ue # # script/version # mas diff --git a/script/version_bump b/script/version_bump index 84e725a..1c09ddb 100755 --- a/script/version_bump +++ b/script/version_bump @@ -46,7 +46,7 @@ echo "REVISION: $REVISION" cat <"${PACKAGE_MANIFEST}" // Generated by: script/version enum Package { - static let version = "${MAS_VERSION}" + static let version = "${MAS_VERSION#v}" } EOF