Skip to content

Commit

Permalink
Run homebrew tap update from its own directory (avoid local git config)
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Hallgren <thomas@tada.se>
  • Loading branch information
thallgren committed Oct 9, 2024
1 parent 4394aba commit 5494799
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions packaging/homebrew-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,22 @@ GITHUB_TOKEN="${5}"
ARCH=(amd64 arm64)
OS=(darwin linux)

MY_PATH=`dirname "$0"`
MY_PATH=`( cd "$MY_PATH" && pwd )`

WORK_DIR="$(mktemp -d)"
cd "${WORK_DIR}"
echo "Working in ${WORK_DIR}"

BUILD_HOMEBREW_DIR=${WORK_DIR}/homebrew
BUILD_HOMEBREW_DIR=homebrew
if [ "${PACKAGE_NAME}" == 'tel2' ]; then
FORMULA_NAME="Telepresence"
FORMULA_FILE="packaging/homebrew-formula.rb"
FORMULA="${BUILD_HOMEBREW_DIR}/Formula/telepresence.rb"
FORMULA_FILE="${MY_PATH}/homebrew-formula.rb"
FORMULA="Formula/telepresence.rb"
elif [ "${PACKAGE_NAME}" == 'tel2oss' ]; then
FORMULA_NAME="TelepresenceOss"
FORMULA_FILE="packaging/homebrew-oss-formula.rb"
FORMULA="${BUILD_HOMEBREW_DIR}/Formula/telepresence-oss.rb"
FORMULA_FILE="${MY_PATH}/homebrew-oss-formula.rb"
FORMULA="Formula/telepresence-oss.rb"
fi

for this_os in "${OS[@]}"; do
Expand Down Expand Up @@ -89,7 +93,7 @@ if [ "${GITHUB_TOKEN}" == "" ]; then
else
git clone "https://${GITHUB_TOKEN}@github.com/telepresenceio/homebrew-telepresence.git" "${BUILD_HOMEBREW_DIR}"
fi

cd "${BUILD_HOMEBREW_DIR}"

# Update recipe
mkdir -p "$(dirname "${FORMULA}")"
Expand All @@ -111,10 +115,8 @@ for this_os in "${OS[@]}"; do
done

chmod 644 "${FORMULA}"
cd "${BUILD_HOMEBREW_DIR}"

# Use the correct machine user for committing
git config --unset-all http.https://github.com/.extraheader
git config user.email "${GITHUB_EMAIL}"
git config user.name "${GITHUB_USER}"

Expand All @@ -126,7 +128,7 @@ git commit -m "Release ${VERSION}"
# the change. Once we know the automation is working, we can
# remove it.
cat "${FORMULA}"
git push origin main
# git push origin main

# Clean up the working directory
rm -rf "${WORK_DIR}"

0 comments on commit 5494799

Please sign in to comment.