|
| 1 | +name: Update Homebrew Formula |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + version: |
| 10 | + description: "Version to test (without the v prefix)" |
| 11 | + required: true |
| 12 | + default: "0.8.0" |
| 13 | + |
| 14 | +permissions: |
| 15 | + contents: read |
| 16 | + |
| 17 | +jobs: |
| 18 | + update-formula: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - name: Checkout main repository |
| 22 | + uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Get release version |
| 25 | + id: get_version |
| 26 | + run: | |
| 27 | + if [ -n "${{ github.event.inputs.version }}" ]; then |
| 28 | + VERSION=${{ github.event.inputs.version }} |
| 29 | + else |
| 30 | + VERSION=${GITHUB_REF#refs/tags/v} |
| 31 | + fi |
| 32 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 33 | +
|
| 34 | + - name: Download ARM binary SHA |
| 35 | + id: arm |
| 36 | + run: | |
| 37 | + VERSION=${{ github.event.inputs.version || github.ref_name }} |
| 38 | + curl -L -o arm.sha256 \ |
| 39 | + https://github.com/joncrangle/sketchybar-system-stats/releases/download/${VERSION}/stats_provider-${VERSION}-aarch64-apple-darwin.tar.gz.sha256 |
| 40 | + ARM_SHA256=$(awk '{print $1}' arm.sha256) |
| 41 | + echo "arm_sha256=$ARM_SHA256" >> $GITHUB_OUTPUT |
| 42 | +
|
| 43 | + - name: Download Intel binary SHA |
| 44 | + id: intel |
| 45 | + run: | |
| 46 | + VERSION=${{ github.event.inputs.version || github.ref_name }} |
| 47 | + curl -L -o intel.sha256 \ |
| 48 | + https://github.com/joncrangle/sketchybar-system-stats/releases/download/${VERSION}/stats_provider-${VERSION}-x86_64-apple-darwin.tar.gz.sha256 |
| 49 | + INTEL_SHA256=$(awk '{print $1}' intel.sha256) |
| 50 | + echo "intel_sha256=$INTEL_SHA256" >> $GITHUB_OUTPUT |
| 51 | +
|
| 52 | + - name: Clone Homebrew tap |
| 53 | + uses: actions/checkout@v4 |
| 54 | + with: |
| 55 | + repository: joncrangle/homebrew-tap |
| 56 | + token: ${{ secrets.HOMEBREW_TAP_TOKEN }} |
| 57 | + path: tap |
| 58 | + |
| 59 | + - name: Update formula |
| 60 | + run: | |
| 61 | + FORMULA=tap/Formula/sketchybar-system-stats.rb |
| 62 | + VERSION=${{ steps.get_version.outputs.version }} |
| 63 | + ARM_SHA256=${{ steps.arm.outputs.arm_sha256 }} |
| 64 | + INTEL_SHA256=${{ steps.intel.outputs.intel_sha256 }} |
| 65 | + sed -i "s|stats_provider-[0-9.]\+-aarch64-apple-darwin.tar.gz|stats_provider-${VERSION}-aarch64-apple-darwin.tar.gz|g" $FORMULA |
| 66 | + sed -i "s|stats_provider-[0-9.]\+-x86_64-apple-darwin.tar.gz|stats_provider-${VERSION}-x86_64-apple-darwin.tar.gz|g" $FORMULA |
| 67 | + sed -i "/aarch64-apple-darwin.tar.gz/,/sha256/ s|sha256 \".*\"|sha256 \"${ARM_SHA256}\"|" $FORMULA |
| 68 | + sed -i "/x86_64-apple-darwin.tar.gz/,/sha256/ s|sha256 \".*\"|sha256 \"${INTEL_SHA256}\"|" $FORMULA |
| 69 | +
|
| 70 | + - name: Commit and push |
| 71 | + run: | |
| 72 | + cd tap |
| 73 | + git config user.name "github-actions[bot]" |
| 74 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 75 | + git add Formula/sketchybar-system-stats.rb |
| 76 | + git commit -m "Update sketchybar-system-stats to v${{ steps.get_version.outputs.version }}" |
| 77 | + git push |
0 commit comments