Skip to content

Commit

Permalink
build homebrew bottles for Mac (arm64 and amd64)
Browse files Browse the repository at this point in the history
  • Loading branch information
hangxie committed Sep 9, 2024
1 parent 784402b commit 2bb6993
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ release-build: deps ## Build release binaries
@mkdir -p $(BUILD_DIR)/release/
@package/scripts/build-bin.sh

@echo "==> build homebrew bottles"
@package/scripts/build-brew.sh

@echo "==> generate RPM and deb packages"
@package/scripts/build-rpm.sh
@package/scripts/build-deb.sh
Expand Down
43 changes: 43 additions & 0 deletions package/scripts/build-brew.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

set -euo pipefail

# this script builds brew bottles but for Mac only (arm64 and amd64)
# tarball name is like go-parquet-tools-1.22.0.arm64_monterey.bottle.tar.gz,
# with content:
# go-parquet-tools
# └── 1.22.0
# ├── LICENSE
# ├── README.md
# └── bin
# └── parquet-tools
#

SOURCE_DIR=${BUILD_DIR}/../
for ARCH in arm64 amd64; do
ARCH_DIR=${BUILD_DIR}/brew/${ARCH}/
BOTTLE_DIR=${ARCH_DIR}/go-parquet-tools/${VERSION:1}/
mkdir -p ${BOTTLE_DIR}/bin

# rebuild just in case we need any special setting for homebrew
GOOS=darwin GOARCH=${ARCH} \
${GO} build ${GOFLAGS} -tags "${TAGS}" -ldflags "${LDFLAGS}" \
-o ${BOTTLE_DIR}/bin/parquet-tools ${SOURCE_DIR}

# nice-to-have files
cp ${SOURCE_DIR}/LICENSE ${BOTTLE_DIR}/
cp ${SOURCE_DIR}/README.md ${BOTTLE_DIR}/

# tarball
tar zcf ${BUILD_DIR}/brew/${ARCH}.tar.gz -C ${ARCH_DIR} go-parquet-tools/
done

for OSX in monterey sequoia sonoma ventura; do
# for Apple Silicon
cp ${BUILD_DIR}/brew/arm64.tar.gz \
${BUILD_DIR}/release/go-parquet-tools-${VERSION:1}.arm64_${OSX}.bottle.tar.gz

# for Intel
cp ${BUILD_DIR}/brew/amd64.tar.gz \
${BUILD_DIR}/release/go-parquet-tools-${VERSION:1}.${OSX}.bottle.tar.gz
done

0 comments on commit 2bb6993

Please sign in to comment.