Skip to content

Commit

Permalink
Revert brew bump-formula-pr --write-only in dry-runs of `brew bump-…
Browse files Browse the repository at this point in the history
…formula-pr`
  • Loading branch information
PawelLipski committed Mar 12, 2024
1 parent 5e78878 commit 4a3f9ae
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions ci/homebrew/ci-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ export HOMEBREW_NO_AUTO_UPDATE=1
NONINTERACTIVE=1 bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# https://stackoverflow.com/questions/54912857/how-do-i-install-old-version-of-homebrew-itself-not-the-formula
(cd /home/linuxbrew/.linuxbrew/Homebrew; git checkout $HOMEBREW_VERSION)
# The two lines below are added to avoid -> Warning: /home/linuxbrew/.linuxbrew/bin is not in your PATH
(echo; echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"') >> /home/circleci/.bash_profile
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
brew --version

Expand All @@ -23,19 +21,23 @@ else
fi

version=$(cut -d\' -f2 git_machete/__init__.py)
# Do not use https://*files.pythonhosted.org/... URLs, see https://github.com/orgs/Homebrew/discussions/5193
url="https://$pypi_host/packages/source/g/git-machete/git-machete-$version.tar.gz"
sha256=$(
curl -s https://$pypi_host/pypi/git-machete/"$version"/json \
| jq --raw-output '.urls | map(select(.packagetype == "sdist")) | .[0].digests.sha256')

# We need to run `brew tap homebrew/core` manually because:
# 1. the formula files need to be present at ~/.linuxbrew/Homebrew/Library/Taps/... - otherwise, `brew bump-formula-pr` will fail due to missing formula AND
# 1. the formula files need to be present at .../.linuxbrew/Homebrew/Library/Taps/... -
# otherwise, `brew bump-formula-pr` will fail due to missing formula AND
# 2. since Homebrew 4.0.0 it is no longer done by default when installing `brew`; see https://brew.sh/2023/02/16/homebrew-4.0.0/
# Also, we can't use `--shallow` here (even though it'd save us ~3 minutes), this option is no longer supported (see https://stackoverflow.com/a/65243764).
brew tap --force homebrew/core
brew developer on
brew config

echo "Bump Homebrew formula"
brew developer on
flags=(--no-browse --verbose --url "$url" --sha256 "$sha256")
if [[ $do_push == true ]]; then
# Relying on HOMEBREW_GITHUB_API_TOKEN, provided by the CI
# See https://docs.brew.sh/Manpage -> Ctrl+F HOMEBREW_GITHUB_API_TOKEN
Expand All @@ -49,18 +51,15 @@ if [[ $do_push == true ]]; then
# Error: These open pull requests may be duplicates:
# git-machete 3.15.1 https://github.com/Homebrew/homebrew-core/pull/123123
# Duplicate PRs should not be opened. Use --force to override this error.
brew bump-formula-pr --force --no-browse --verbose --url "$url" --sha256 "$sha256" git-machete
brew bump-formula-pr --force "${flags[@]}" git-machete
else
echo "Refraining from push since it's a dry run"
# homebrew-core has been fetched by `brew tap` above
formula_file=/home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/g/git-machete.rb
brew bump-formula-pr --write-only "${flags[@]}" git-machete

# TODO (#1198): run `brew bump-formula-pr --write-only` here, rather than patching with `sed`
sed -i "s!^ url .*\$! url \"$url\"!" $formula_file
sed -i "s!^ sha256 .*\$! sha256 \"$sha256\"!" $formula_file

brew config
brew install --build-from-source --formula $formula_file
# homebrew-core has been fetched by `brew tap` above
tap_repo=/home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-core
(cd $tap_repo; GIT_PAGER="cat" git diff)
brew install --build-from-source --formula $tap_repo/Formula/g/git-machete.rb

if [[ "$version" != "$(git machete version | cut -d' ' -f3)" ]]; then
echo "Something went wrong during brew installation: installed version does not match version from formula."
Expand Down

0 comments on commit 4a3f9ae

Please sign in to comment.