name: Release CLI
on:
push:
tags:
- "v*.*.*"
permissions:
contents: write
jobs:
build:
strategy:
matrix:
include:
- target: aarch64-apple-darwin
platform: darwin-arm64
runner: macos-latest
- target: x86_64-apple-darwin
platform: darwin-x86_64
runner: macos-latest
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4
- name: Extract version from tag
id: version
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Build
working-directory: cli
run: cargo build --release --target ${{ matrix.target }}
- name: Package
run: |
ARCHIVE="claude-in-mobile-${{ steps.version.outputs.version }}-${{ matrix.platform }}.tar.gz"
tar -czf "$ARCHIVE" -C cli/target/${{ matrix.target }}/release claude-in-mobile
shasum -a 256 "$ARCHIVE" > "$ARCHIVE.sha256"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: build-${{ matrix.platform }}
path: |
claude-in-mobile-*.tar.gz
claude-in-mobile-*.tar.gz.sha256
release:
needs: build
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
merge-multiple: true
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: "*.tar.gz"
update-homebrew:
needs: release
runs-on: ubuntu-latest
steps:
- name: Extract version from tag
id: version
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
- name: Download artifacts
uses: actions/download-artifact@v4
with:
merge-multiple: true
- name: Read SHA256 values
id: sha
run: |
ARM64_SHA=$(awk '{print $1}' claude-in-mobile-*-darwin-arm64.tar.gz.sha256)
X86_SHA=$(awk '{print $1}' claude-in-mobile-*-darwin-x86_64.tar.gz.sha256)
echo "arm64=$ARM64_SHA" >> "$GITHUB_OUTPUT"
echo "x86_64=$X86_SHA" >> "$GITHUB_OUTPUT"
- name: Checkout Homebrew tap
uses: actions/checkout@v4
with:
repository: AlexGladkov/homebrew-claude-in-mobile
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
path: homebrew-tap
- name: Update formula
working-directory: homebrew-tap
run: |
python3 - "${{ steps.version.outputs.version }}" "${{ steps.sha.outputs.arm64 }}" "${{ steps.sha.outputs.x86_64 }}" <<'PYTHON'
import sys, re
version, arm_sha, x86_sha = sys.argv[1], sys.argv[2], sys.argv[3]
path = "Formula/claude-in-mobile.rb"
with open(path) as f:
content = f.read()
content = re.sub(r'version ".*?"', f'version "{version}"', content)
sha_iter = iter([arm_sha, x86_sha])
def replace_sha(m):
try:
return f'sha256 "{next(sha_iter)}"'
except StopIteration:
return m.group(0)
content = re.sub(r'sha256 "[a-f0-9]{64}"', replace_sha, content)
with open(path, "w") as f:
f.write(content)
PYTHON
- name: Commit and push
working-directory: homebrew-tap
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Formula/claude-in-mobile.rb
git diff --cached --quiet && exit 0
git commit -m "Update claude-in-mobile to ${{ steps.version.outputs.version }}"
git push