Update Homebrew Tap #121
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update Homebrew Tap | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: 'Version to update (e.g., v1.0.0)' | |
| required: true | |
| type: string | |
| jobs: | |
| update-tap: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout main repository | |
| uses: actions/checkout@v4 | |
| - name: Checkout tap repository | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: JAManfredi/homebrew-cascade-cli | |
| path: homebrew-tap | |
| token: ${{ secrets.TAP_GITHUB_TOKEN }} | |
| ref: master # Explicitly checkout master branch | |
| fetch-depth: 0 # Fetch full history to avoid detached HEAD issues | |
| - name: Configure git in tap repository | |
| run: | | |
| cd homebrew-tap | |
| git config user.name "GitHub Actions" | |
| git config user.email "actions@github.com" | |
| # Ensure we're on master branch and not detached | |
| git checkout master | |
| git pull origin master | |
| # Verify we're on a branch | |
| echo "Current branch: $(git branch --show-current)" | |
| echo "Git status:" | |
| git status | |
| - name: Get release info | |
| id: release_info | |
| run: | | |
| # Get version from release or input | |
| if [ "${{ github.event_name }}" = "release" ]; then | |
| VERSION="${{ github.event.release.tag_name }}" | |
| else | |
| VERSION="${{ github.event.inputs.version }}" | |
| fi | |
| # Ensure version has 'v' prefix for downloads (GitHub releases use v-prefixed tags) | |
| if [[ ! "$VERSION" =~ ^v ]]; then | |
| VERSION="v${VERSION}" | |
| fi | |
| # Strip 'v' prefix for version number in formula | |
| VERSION_NO_V="${VERSION#v}" | |
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| echo "VERSION_NO_V=$VERSION_NO_V" >> $GITHUB_OUTPUT | |
| echo "Using version: $VERSION (numeric: $VERSION_NO_V)" | |
| - name: Download and compute checksums | |
| run: | | |
| VERSION="${{ steps.release_info.outputs.VERSION }}" | |
| # Download macOS binaries | |
| curl -L -o ca-macos-arm64.tar.gz \ | |
| "https://github.com/JAManfredi/cascade-cli/releases/download/${VERSION}/ca-macos-arm64.tar.gz" | |
| curl -L -o ca-macos-x64.tar.gz \ | |
| "https://github.com/JAManfredi/cascade-cli/releases/download/${VERSION}/ca-macos-x64.tar.gz" | |
| # Compute checksums | |
| ARM64_SHA=$(shasum -a 256 ca-macos-arm64.tar.gz | cut -d' ' -f1) | |
| X64_SHA=$(shasum -a 256 ca-macos-x64.tar.gz | cut -d' ' -f1) | |
| echo "ARM64_SHA=$ARM64_SHA" >> $GITHUB_ENV | |
| echo "X64_SHA=$X64_SHA" >> $GITHUB_ENV | |
| echo "Computed checksums: ARM64=$ARM64_SHA, X64=$X64_SHA" | |
| - name: Update Homebrew formula | |
| run: | | |
| VERSION="${{ steps.release_info.outputs.VERSION }}" | |
| VERSION_NO_V="${{ steps.release_info.outputs.VERSION_NO_V }}" | |
| echo "Updating formula to version $VERSION (numeric: $VERSION_NO_V)" | |
| # Update the formula in the tap repository | |
| cd homebrew-tap | |
| # Double-check we're on the right branch | |
| echo "Current branch before update: $(git branch --show-current)" | |
| # Update URLs (use $VERSION which includes 'v' prefix) | |
| sed -i "s|https://github.com/JAManfredi/cascade-cli/releases/download/v[^/]*/ca-macos-arm64.tar.gz|https://github.com/JAManfredi/cascade-cli/releases/download/${VERSION}/ca-macos-arm64.tar.gz|g" Formula/cascade-cli.rb | |
| sed -i "s|https://github.com/JAManfredi/cascade-cli/releases/download/v[^/]*/ca-macos-x64.tar.gz|https://github.com/JAManfredi/cascade-cli/releases/download/${VERSION}/ca-macos-x64.tar.gz|g" Formula/cascade-cli.rb | |
| # Update version (use VERSION_NO_V without 'v' prefix) | |
| sed -i "s/version \"[^\"]*\"/version \"${VERSION_NO_V}\"/g" Formula/cascade-cli.rb | |
| # Update checksums - update first and second SHA256 lines | |
| echo "Current formula before SHA256 update:" | |
| grep -A 2 -B 2 "sha256" Formula/cascade-cli.rb || true | |
| # Update first SHA256 line (ARM64 - in the if block) | |
| sed -i "0,/sha256 \"[^\"]*\"/{s/sha256 \"[^\"]*\"/sha256 \"${ARM64_SHA}\"/}" Formula/cascade-cli.rb | |
| # Update second SHA256 line (x64 - in the else block) | |
| sed -i "0,/sha256 \"[^\"]*\"/b; s/sha256 \"[^\"]*\"/sha256 \"${X64_SHA}\"/" Formula/cascade-cli.rb | |
| echo "Formula after SHA256 update:" | |
| grep -A 2 -B 2 "sha256" Formula/cascade-cli.rb || true | |
| # Show what was updated | |
| echo "Updated formula content:" | |
| cat Formula/cascade-cli.rb | |
| # Verify git status after changes | |
| echo "Git status after formula update:" | |
| git status | |
| - name: Test formula syntax | |
| run: | | |
| # Simple syntax check | |
| cd homebrew-tap | |
| ruby -c Formula/cascade-cli.rb | |
| echo "✅ Formula syntax is valid" | |
| - name: Create Pull Request | |
| uses: peter-evans/create-pull-request@v6 | |
| with: | |
| path: homebrew-tap | |
| token: ${{ secrets.TAP_GITHUB_TOKEN }} | |
| commit-message: "Update Cascade CLI to ${{ steps.release_info.outputs.VERSION }}" | |
| title: "Update Cascade CLI to ${{ steps.release_info.outputs.VERSION }}" | |
| body: | | |
| Updates Homebrew formula for Cascade CLI ${{ steps.release_info.outputs.VERSION }} | |
| Changes: | |
| - Updated download URLs to point to ${{ steps.release_info.outputs.VERSION }} release | |
| - Updated SHA256 checksums for macOS binaries (ARM64: ${{ env.ARM64_SHA }}, x64: ${{ env.X64_SHA }}) | |
| - Updated version number to ${{ steps.release_info.outputs.VERSION_NO_V }} | |
| This PR was auto-generated by the update-homebrew-tap workflow. | |
| branch: update-homebrew-${{ steps.release_info.outputs.VERSION }} | |
| delete-branch: true | |
| author: "GitHub Actions <actions@github.com>" | |
| committer: "GitHub Actions <actions@github.com>" | |
| base: master # Explicitly set base branch |