native macOS codings agent orchestrator
6
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #73 from onevcat/feat/homebrew-cask-release-flow

ci: automate homebrew cask update from Prowl releases

authored by

Wei Wang and committed by
GitHub
3ed02a21 218c0909

+142
+142
.github/workflows/release-homebrew-cask.yml
··· 1 + name: Update Homebrew cask 2 + 3 + on: 4 + release: 5 + types: [published] 6 + workflow_dispatch: 7 + inputs: 8 + tag: 9 + description: "Release tag to sync (e.g. v2026.3.25)" 10 + required: true 11 + type: string 12 + 13 + jobs: 14 + update-tap: 15 + runs-on: ubuntu-22.04 16 + environment: homebrew-release 17 + permissions: 18 + contents: read 19 + steps: 20 + - name: Resolve release metadata 21 + id: metadata 22 + shell: bash 23 + run: | 24 + set -euo pipefail 25 + if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then 26 + TAG="${{ inputs.tag }}" 27 + else 28 + TAG="${{ github.event.release.tag_name }}" 29 + fi 30 + 31 + if [[ -z "$TAG" ]]; then 32 + echo "Tag is required." 33 + exit 1 34 + fi 35 + 36 + VERSION="${TAG#v}" 37 + URL="https://github.com/${{ github.repository }}/releases/download/${TAG}/Prowl.dmg" 38 + SHA=$(curl -fL -s "$URL" | shasum -a 256 | awk '{print $1}') 39 + 40 + echo "tag=$TAG" >> "$GITHUB_OUTPUT" 41 + echo "version=$VERSION" >> "$GITHUB_OUTPUT" 42 + echo "url=$URL" >> "$GITHUB_OUTPUT" 43 + echo "sha=$SHA" >> "$GITHUB_OUTPUT" 44 + 45 + - name: Checkout tap 46 + uses: actions/checkout@v4 47 + with: 48 + repository: onevcat/homebrew-tap 49 + token: ${{ secrets.TAP_GITHUB_TOKEN }} 50 + path: tap 51 + 52 + - name: Update cask 53 + env: 54 + TAP_VERSION: ${{ steps.metadata.outputs.version }} 55 + TAP_SHA: ${{ steps.metadata.outputs.sha }} 56 + run: | 57 + python - <<'PY' 58 + import os 59 + import pathlib 60 + import re 61 + import textwrap 62 + 63 + path = pathlib.Path("tap/Casks/prowl.rb") 64 + version = os.environ["TAP_VERSION"] 65 + sha = os.environ["TAP_SHA"] 66 + 67 + template = textwrap.dedent( 68 + f""" 69 + cask \"prowl\" do 70 + version \"{version}\" 71 + sha256 \"{sha}\" 72 + 73 + url \"https://github.com/onevcat/Prowl/releases/download/v#{{version}}/Prowl.dmg\" 74 + name \"Prowl\" 75 + desc \"Native macOS coding agent orchestrator\" 76 + homepage \"https://github.com/onevcat/Prowl\" 77 + 78 + auto_updates true 79 + app \"Prowl.app\" 80 + 81 + zap trash: [ 82 + \"~/Library/Application Support/com.onevcat.prowl\", 83 + \"~/Library/Caches/com.onevcat.prowl\", 84 + \"~/Library/Preferences/com.onevcat.prowl.plist\", 85 + \"~/Library/Saved Application State/com.onevcat.prowl.savedState\", 86 + ] 87 + end 88 + """ 89 + ).lstrip() 90 + 91 + if not path.exists(): 92 + path.parent.mkdir(parents=True, exist_ok=True) 93 + path.write_text(template) 94 + print("Created tap/Casks/prowl.rb") 95 + else: 96 + text = path.read_text() 97 + text = re.sub(r'^\s*version\s+\".*\"\s*$', f' version \"{version}\"', text, flags=re.M) 98 + text = re.sub(r'^\s*sha256\s+\".*\"\s*$', f' sha256 \"{sha}\"', text, flags=re.M) 99 + path.write_text(text) 100 + print("Updated tap/Casks/prowl.rb") 101 + PY 102 + 103 + - name: Open pull request 104 + env: 105 + GH_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }} 106 + TAG: ${{ steps.metadata.outputs.tag }} 107 + run: | 108 + set -euo pipefail 109 + cd tap 110 + 111 + BRANCH="prowl-${TAG#v}" 112 + 113 + if gh pr view --repo onevcat/homebrew-tap --head "onevcat:${BRANCH}" >/dev/null 2>&1; then 114 + echo "PR already exists for ${BRANCH}." 115 + exit 0 116 + fi 117 + 118 + git checkout -b "$BRANCH" 119 + git add Casks/prowl.rb 120 + 121 + if git diff --cached --quiet; then 122 + echo "No cask changes detected." 123 + exit 0 124 + fi 125 + 126 + git -c user.name="github-actions[bot]" \ 127 + -c user.email="41898282+github-actions[bot]@users.noreply.github.com" \ 128 + commit -m "Update prowl cask to ${TAG}" 129 + 130 + git push origin "$BRANCH" 131 + 132 + gh pr create \ 133 + --repo onevcat/homebrew-tap \ 134 + --title "Update prowl cask to ${TAG}" \ 135 + --body-file - <<EOF 136 + Automated update from Prowl release ${TAG}. 137 + 138 + - Updated \ 139 + - version 140 + - sha256 141 + - Target cask: Casks/prowl.rb 142 + EOF