Skip to content

Commit

Permalink
Automate postrelease publishing to Homebrew (#3507)
Browse files Browse the repository at this point in the history
* Done

* Autofile PR

* fix readme

Co-authored-by: Ian Joiner <[email protected]>
  • Loading branch information
chloeandmargaret and iajoiner authored Oct 3, 2022
1 parent 6b282ec commit 010b352
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 1 deletion.
8 changes: 7 additions & 1 deletion dev/release/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,13 @@ The CLI needs a `--no-verify` argument because `build.rs` generates source into

### Publish datafusion-cli on Homebrew

For Homebrew, Send a simple PR to update tag and commit hash for the datafusion
Run `publish_homebrew.sh` to publish `datafusion-cli` on Homebrew.

```
dev/release/publish_homebrew.sh <version> <github-user> <github-token> <homebrew-default-branch-name>
```

Alternatively manually send a simple PR to update tag and commit hash for the datafusion
formula in homebrew-core. Here is an example PR:
https://github.com/Homebrew/homebrew-core/pull/89562.

Expand Down
83 changes: 83 additions & 0 deletions dev/release/publish_homebrew.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/env bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

set -ue

if [ "$#" -ne 3 ]; then
echo "Usage: $0 <version> <github-user> <github-token> <homebrew-default-branch-name>"
exit 1
fi

version=$1
github_user=$2
github_token=$3
# Prepare for possible renaming of the default branch on Homebrew
homebrew_default_branch_name=$4

url="https://www.apache.org/dyn/closer.lua?path=arrow/arrow-datafusion-${version}/apache-arrow-datafusion-${version}.tar.gz"
sha256="$(curl https://dist.apache.org/repos/dist/release/arrow/arrow-datafusion-${version}/apache-arrow-datafusion-${version}.tar.gz.sha256 | cut -d' ' -f1)"

pushd "$(brew --repository homebrew/core)"

if ! git remote | grep -q --fixed-strings ${github_user}; then
echo "Setting ''${github_user}' remote"
git remote add ${github_user} [email protected]:${github_user}/homebrew-core.git
fi

echo "Updating working copy"
git fetch --all --prune --tags --force -j$(nproc)

branch=apache-arrow-datafusion-${version}
echo "Creating branch: ${branch}"
git branch -D ${branch} || :
git checkout -b ${branch} origin/master

echo "Updating datafusion formulae"
brew bump-formula-pr \
--commit \
--no-audit \
--sha256="${sha256}" \
--url="${url}" \
--verbose \
--write-only \
datafusion

echo "Testing datafusion formulae"
brew uninstall datafusion || :
brew install --build-from-source datafusion
brew test datafusion
brew audit --strict datafusion

git push -u $github_user ${branch}

git checkout -

popd

echo "Create the pull request"
title="datafusion ${version}"
body="Created using \`bump-formula-pr\`"
data="{\"title\":\"$title\", \"body\":\"$body\", \"head\":\"$github_username:$branch\", \"base\":\"$homebrew_default_branch_name\"}"
curl -X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $github_token" \
https://api.github.com/repos/Homebrew/homebrew-core/pulls \
-d "$data"

echo "Complete!"

0 comments on commit 010b352

Please sign in to comment.