buster/.github/workflows/update-brew-tap.yml

229 lines
8.1 KiB
YAML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: Update Homebrew Tap
on:
workflow_call:
inputs:
tag:
required: true
type: string
description: 'The release tag (e.g., v0.3.0)'
version:
required: true
type: string
description: 'The version number (e.g., 0.3.0)'
secrets:
HOMEBREW_TAP_TOKEN:
required: true
description: 'Token with write access to the Homebrew tap repository'
workflow_dispatch:
inputs:
tag:
description: 'The release tag to use (e.g., v0.3.0)'
required: true
type: string
version:
description: 'The version number (e.g., 0.3.0)'
required: true
type: string
permissions:
contents: read
actions: read
jobs:
update-tap:
runs-on: blacksmith-2vcpu-ubuntu-2404
steps:
- name: Validate inputs
run: |
echo "📋 Validating inputs..."
echo "Tag: ${{ inputs.tag }}"
echo "Version: ${{ inputs.version }}"
if [[ -z "${{ inputs.tag }}" || -z "${{ inputs.version }}" ]]; then
echo "❌ Error: Both tag and version are required"
exit 1
fi
- name: Set up GitHub CLI
run: |
echo "🔧 GitHub CLI is pre-installed on runners"
gh --version
- name: Download SHA256 sums from GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
run: |
echo "📥 Downloading SHA256 checksums for release ${{ inputs.tag }}..."
# Download all SHA256 files
gh release download ${{ inputs.tag }} --pattern '*.sha256' -R $GH_REPO --clobber || {
echo "❌ Failed to download SHA256 files. Checking if release exists..."
gh release view ${{ inputs.tag }} -R $GH_REPO || {
echo "❌ Release ${{ inputs.tag }} not found!"
exit 1
}
}
echo "Downloaded SHA256 files:"
ls -la *.sha256
# Extract SHA256 hashes
SHA_ARM64=$(cat buster-cli-darwin-arm64.tar.gz.sha256 | awk '{print $1}')
SHA_INTEL=$(cat buster-cli-darwin-x86_64.tar.gz.sha256 | awk '{print $1}')
SHA_LINUX=$(cat buster-cli-linux-x86_64.tar.gz.sha256 | awk '{print $1}')
SHA_WINDOWS=$(cat buster-cli-windows-x86_64.zip.sha256 | awk '{print $1}')
# Export for later steps
echo "SHA_ARM64=$SHA_ARM64" >> $GITHUB_ENV
echo "SHA_INTEL=$SHA_INTEL" >> $GITHUB_ENV
echo "SHA_LINUX=$SHA_LINUX" >> $GITHUB_ENV
echo "SHA_WINDOWS=$SHA_WINDOWS" >> $GITHUB_ENV
echo "✅ SHA256 checksums extracted:"
echo " ARM64: $SHA_ARM64"
echo " Intel: $SHA_INTEL"
echo " Linux: $SHA_LINUX"
echo " Windows: $SHA_WINDOWS"
- name: Checkout Homebrew tap repository
uses: actions/checkout@v4
with:
repository: buster-so/buster-homebrew
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
path: buster-homebrew
- name: Configure Git
working-directory: ./buster-homebrew
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Update Homebrew Formula
working-directory: ./buster-homebrew
env:
VERSION: ${{ inputs.version }}
TAG: ${{ inputs.tag }}
SHA_ARM64: ${{ env.SHA_ARM64 }}
SHA_INTEL: ${{ env.SHA_INTEL }}
SHA_LINUX: ${{ env.SHA_LINUX }}
REPO_OWNER: ${{ github.repository_owner }}
run: |
echo "📝 Updating Homebrew formula for version $VERSION..."
FORMULA_FILE="Formula/buster.rb"
# Create or update the formula file
cat > "$FORMULA_FILE" << 'FORMULA'
# typed: false
# frozen_string_literal: true
class Buster < Formula
desc "Command-line interface for Buster AI data platform"
homepage "https://github.com/buster-so/buster"
version "VERSION_PLACEHOLDER"
license "MIT"
livecheck do
url :stable
strategy :github_latest
regex(/^v?(\d+(?:\.\d+)+)$/i)
end
on_macos do
on_arm do
url "https://github.com/REPO_OWNER/buster/releases/download/TAG_PLACEHOLDER/buster-cli-darwin-arm64.tar.gz"
sha256 "SHA_ARM64_PLACEHOLDER"
end
on_intel do
url "https://github.com/REPO_OWNER/buster/releases/download/TAG_PLACEHOLDER/buster-cli-darwin-x86_64.tar.gz"
sha256 "SHA_INTEL_PLACEHOLDER"
end
end
on_linux do
on_intel do
url "https://github.com/REPO_OWNER/buster/releases/download/TAG_PLACEHOLDER/buster-cli-linux-x86_64.tar.gz"
sha256 "SHA_LINUX_PLACEHOLDER"
end
end
def install
bin.install "buster"
end
test do
assert_match version.to_s, shell_output("#{bin}/buster --version 2>&1", 0)
end
end
FORMULA
# Replace placeholders
sed -i "s/VERSION_PLACEHOLDER/$VERSION/g" "$FORMULA_FILE"
sed -i "s/TAG_PLACEHOLDER/$TAG/g" "$FORMULA_FILE"
sed -i "s/REPO_OWNER/$REPO_OWNER/g" "$FORMULA_FILE"
sed -i "s/SHA_ARM64_PLACEHOLDER/$SHA_ARM64/g" "$FORMULA_FILE"
sed -i "s/SHA_INTEL_PLACEHOLDER/$SHA_INTEL/g" "$FORMULA_FILE"
sed -i "s/SHA_LINUX_PLACEHOLDER/$SHA_LINUX/g" "$FORMULA_FILE"
echo "--- Updated Formula ---"
cat "$FORMULA_FILE"
echo "--- End of Formula ---"
- name: Test formula syntax
working-directory: ./buster-homebrew
run: |
echo "🧪 Testing formula syntax..."
# Basic Ruby syntax check
ruby -c Formula/buster.rb || {
echo "❌ Formula has syntax errors!"
exit 1
}
echo "✅ Formula syntax is valid"
- name: Commit and push changes to Homebrew tap
working-directory: ./buster-homebrew
run: |
git add Formula/buster.rb
if git diff --staged --quiet; then
echo " No changes to commit - formula is already up to date"
else
echo "💾 Committing changes..."
git commit -m "Update Buster CLI to version ${{ inputs.version }}
Release: ${{ inputs.tag }}
Source: ${{ github.server_url }}/${{ github.repository }}
[skip ci]"
echo "📤 Pushing to Homebrew tap..."
git push
echo "✅ Successfully updated Homebrew tap!"
fi
- name: Create summary
if: always()
run: |
echo "## 🍺 Homebrew Tap Update" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Version:** ${{ inputs.version }}" >> $GITHUB_STEP_SUMMARY
echo "- **Tag:** ${{ inputs.tag }}" >> $GITHUB_STEP_SUMMARY
echo "- **Repository:** buster-so/buster-homebrew" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [[ "${{ job.status }}" == "success" ]]; then
echo "✅ **Status:** Successfully updated" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Installation" >> $GITHUB_STEP_SUMMARY
echo '```bash' >> $GITHUB_STEP_SUMMARY
echo 'brew tap buster-so/buster-homebrew' >> $GITHUB_STEP_SUMMARY
echo 'brew install buster' >> $GITHUB_STEP_SUMMARY
echo '# or to upgrade:' >> $GITHUB_STEP_SUMMARY
echo 'brew upgrade buster' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
else
echo "❌ **Status:** Update failed" >> $GITHUB_STEP_SUMMARY
echo "Check the logs above for details." >> $GITHUB_STEP_SUMMARY
fi