Skip to content

Apache DataFusion SQL Query Engine

Fix homebrew publish script (#5044)

Ian Alexander Joinerb5d90b6cb936
diff --git a/dev/release/README.md b/dev/release/README.md
index 07dd3c4c60..ce9467fec3 100644
--- a/dev/release/README.md
+++ b/dev/release/README.md
@@ -317,13 +317,45 @@ The CLI needs a `--no-verify` argument because `build.rs` generates source into
### Publish datafusion-cli on Homebrew
-Run `publish_homebrew.sh` to publish `datafusion-cli` on Homebrew.
+Run `publish_homebrew.sh` to publish `datafusion-cli` on Homebrew. In order to do so it is necessary to
+fork the `homebrew-core` repo https://github.com/Homebrew/homebrew-core/, have Homebrew installed on your
+macOS/Linux/WSL2 and properly configured and have a Github Personal Access Token that has permission to file pull requests in the `homebrew-core` repo.
+#### Fork the `homebrew-core` repo
+
+Go to https://github.com/Homebrew/homebrew-core/ and fork the repo.
+
+#### Install and configure Homebrew
+
+Please visit https://brew.sh/ to obtain Homebrew. In addition to that please check out https://docs.brew.sh/Homebrew-on-Linux if you are on Linux or WSL2.
+
+Before running the script make sure that you can run the following command in your bash to make sure
+that `brew` has been installed and configured properly:
+
+```bash
+brew --version
```
+
+#### Create a Github Personal Access Token
+
+To create a Github Personal Access Token, please visit https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token for instructions.
+
+- Make sure to select either **All repositories** or **Only selected repositories** so that you have access to **Repository permissions**.
+- If you only use the token for selected repos make sure you include your
+ fork of `homebrew-core` in the list of repos under **Selected repositories**.
+- Make sure to have **Read and write** access enabled for pull requests in your **Repository permissions**.
+
+After all of the above is complete execute the following command:
+
+```bash
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
+Note that sometimes someone else has already submitted a PR to update the datafusion formula in homebrew.
+In this case you will get an error with a message that your PR is a duplicate of an existing one. In this
+case no further action is required.
+
+Alternatively manually submit 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.
diff --git a/dev/release/publish_homebrew.sh b/dev/release/publish_homebrew.sh
index 876a974e90..1cf7160d42 100644
--- a/dev/release/publish_homebrew.sh
+++ b/dev/release/publish_homebrew.sh
@@ -19,7 +19,7 @@
set -ue
-if [ "$#" -ne 3 ]; then
+if [ "$#" -ne 4 ]; then
echo "Usage: $0 <version> <github-user> <github-token> <homebrew-default-branch-name>"
exit 1
fi
@@ -30,6 +30,15 @@ github_token=$3
# Prepare for possible renaming of the default branch on Homebrew
homebrew_default_branch_name=$4
+# Git parallel fetch
+if sysctl -n hw.ncpu 2>/dev/null; then # macOS
+ num_processing_units=$(sysctl -n hw.ncpu)
+elif [ -x "$(command -v nproc)" ]; then # Linux
+ num_processing_units=$(nproc)
+else # Fallback
+ num_processing_units=1
+fi
+
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)"
@@ -41,7 +50,7 @@ if ! git remote | grep -q --fixed-strings ${github_user}; then
fi
echo "Updating working copy"
-git fetch --all --prune --tags --force -j$(nproc)
+git fetch --all --prune --tags --force -j$num_processing_units
branch=apache-arrow-datafusion-${version}
echo "Creating branch: ${branch}"