Some checks failed
CI / build (push) Failing after 12s
GitOrigin-RevId: 6370f6ea785709295b6abcf9c60717cacf3ac432
157 lines
6 KiB
YAML
157 lines
6 KiB
YAML
name: Publish Homebrew Packages
|
|
on:
|
|
schedule:
|
|
- cron: '0 2 * * *' # Run at 2 AM
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
packages: write
|
|
|
|
jobs:
|
|
build-and-publish:
|
|
runs-on: docker
|
|
container:
|
|
image: forgejo.csbx.dev/acmcarther/coder-dev-base-image:4
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- package: tts-client
|
|
target: //experimental/users/acmcarther/llm/tts_grpc:tts_client_go
|
|
binary_name: tts-client-darwin-arm64
|
|
- package: litellm-client
|
|
target: //experimental/users/acmcarther/llm/litellm_grpc:client_go
|
|
binary_name: litellm-client-darwin-arm64
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Install bazelisk
|
|
run: |
|
|
curl -fLO "http://bin-cache-http.dev.svc.cluster.local/bazelisk/v1.27.0/bazelisk-linux-amd64"
|
|
mkdir -p "${GITHUB_WORKSPACE}/bin/"
|
|
mv bazelisk-linux-amd64 "${GITHUB_WORKSPACE}/bin/bazel"
|
|
chmod +x "${GITHUB_WORKSPACE}/bin/bazel"
|
|
echo "${GITHUB_WORKSPACE}/bin" >> $GITHUB_PATH
|
|
|
|
- name: Build Binary (Darwin ARM64)
|
|
env:
|
|
BAZELISK_BASE_URL: "http://bin-cache-http.dev.svc.cluster.local/bazel"
|
|
run: |
|
|
bazel build --config=remote --platforms=@rules_go//go/toolchain:darwin_arm64 ${{ matrix.target }}
|
|
|
|
- name: Publish Artifact
|
|
env:
|
|
YESOD_PACKAGE_TOKEN: ${{ secrets.YESOD_PACKAGE_TOKEN }}
|
|
PACKAGE_NAME: ${{ matrix.package }}
|
|
BINARY_NAME: ${{ matrix.binary_name }}
|
|
TARGET: ${{ matrix.target }}
|
|
run: |
|
|
# Calculate Version
|
|
SHORT_SHA=$(git rev-parse --short HEAD)
|
|
VERSION="0.0.2-${SHORT_SHA}"
|
|
PACKAGE_URL="https://forgejo.csbx.dev/api/packages/acmcarther/generic/${PACKAGE_NAME}/${VERSION}/${BINARY_NAME}"
|
|
|
|
echo "Publishing ${PACKAGE_NAME} version ${VERSION}"
|
|
|
|
# Locate the binary using cquery for precision
|
|
BINARY_PATH=$(bazel cquery --config=remote --platforms=@rules_go//go/toolchain:darwin_arm64 --output=files ${TARGET} 2>/dev/null)
|
|
|
|
if [ -z "$BINARY_PATH" ]; then
|
|
echo "cquery failed to find the binary path for ${TARGET}"
|
|
exit 1
|
|
fi
|
|
|
|
# Upload
|
|
echo "Uploading to ${PACKAGE_URL}..."
|
|
curl -v --fail \
|
|
-H "Authorization: token $YESOD_PACKAGE_TOKEN" \
|
|
-X PUT \
|
|
"${PACKAGE_URL}" \
|
|
-T "$BINARY_PATH"
|
|
|
|
update-homebrew:
|
|
needs: build-and-publish
|
|
runs-on: docker
|
|
container:
|
|
image: forgejo.csbx.dev/acmcarther/coder-dev-base-image:4
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Install bazelisk
|
|
run: |
|
|
curl -fLO "http://bin-cache-http.dev.svc.cluster.local/bazelisk/v1.27.0/bazelisk-linux-amd64"
|
|
mkdir -p "${GITHUB_WORKSPACE}/bin/"
|
|
mv bazelisk-linux-amd64 "${GITHUB_WORKSPACE}/bin/bazel"
|
|
chmod +x "${GITHUB_WORKSPACE}/bin/bazel"
|
|
echo "${GITHUB_WORKSPACE}/bin" >> $GITHUB_PATH
|
|
|
|
- name: Generate and Update Formulas
|
|
env:
|
|
BAZELISK_BASE_URL: "http://bin-cache-http.dev.svc.cluster.local/bazel"
|
|
PACKAGES: "tts-client litellm-client"
|
|
run: |
|
|
SHORT_SHA=$(git rev-parse --short HEAD)
|
|
VERSION="0.0.2-${SHORT_SHA}"
|
|
|
|
for PACKAGE in $PACKAGES; do
|
|
echo "Processing $PACKAGE..."
|
|
|
|
# Convert hyphen to underscore for bazel target name convention
|
|
TARGET_NAME="generate_${PACKAGE//-/_}_rb"
|
|
BAZEL_TARGET="//homebrew:${TARGET_NAME}"
|
|
BINARY_NAME="${PACKAGE}-darwin-arm64"
|
|
PACKAGE_URL="https://forgejo.csbx.dev/api/packages/acmcarther/generic/${PACKAGE}/${VERSION}/${BINARY_NAME}"
|
|
|
|
echo "Building formula target: $BAZEL_TARGET"
|
|
bazel build --config=remote --platforms=@rules_go//go/toolchain:darwin_arm64 $BAZEL_TARGET
|
|
|
|
FORMULA_PATH=$(bazel cquery --config=remote --platforms=@rules_go//go/toolchain:darwin_arm64 --output=files $BAZEL_TARGET 2>/dev/null)
|
|
|
|
if [ -z "$FORMULA_PATH" ]; then
|
|
echo "Failed to find generated formula for $PACKAGE"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Generated formula at: $FORMULA_PATH"
|
|
|
|
# Inject Version and URL
|
|
sed -e "s|{VERSION}|${VERSION}|g" \
|
|
-e "s|{URL}|${PACKAGE_URL}|g" \
|
|
"$FORMULA_PATH" > homebrew/${PACKAGE}.rb
|
|
|
|
echo "Updated homebrew/${PACKAGE}.rb"
|
|
done
|
|
|
|
- name: Configure Git
|
|
run: |
|
|
git config --global user.name "Copybara"
|
|
git config --global user.email "copybara@csbx.dev"
|
|
git config --global url."https://acmcarther:${{ secrets.HOMEBREW_REPO_TOKEN }}@forgejo.csbx.dev/acmcarther/yesod-homebrew-tools.git".insteadOf "https://forgejo.csbx.dev/acmcarther/yesod-homebrew-tools.git"
|
|
|
|
- name: Run Copybara
|
|
env:
|
|
BAZELISK_BASE_URL: "http://bin-cache-http.dev.svc.cluster.local/bazel"
|
|
run: |
|
|
# Stage the new formulas
|
|
git add homebrew/*.rb
|
|
|
|
# Check if there are changes
|
|
if git diff --cached --quiet; then
|
|
echo "No changes to commit."
|
|
else
|
|
SHORT_SHA=$(git rev-parse --short HEAD)
|
|
VERSION="0.0.2-${SHORT_SHA}"
|
|
git commit -m "Update homebrew formulas to ${VERSION} [skip ci]"
|
|
|
|
# Patch copy.bara.sky to use local origin
|
|
sed -i "s|sourceUrl = .*|sourceUrl = \"file://${GITHUB_WORKSPACE}\"|" "${GITHUB_WORKSPACE}/tools/copybara/homebrew/copy.bara.sky"
|
|
|
|
# Run Copybara
|
|
bazel run //tools/copybara:copybara --config=remote --java_runtime_version=remotejdk_21 -- \
|
|
migrate \
|
|
"${GITHUB_WORKSPACE}/tools/copybara/homebrew/copy.bara.sky" \
|
|
--force
|
|
fi
|