|
| 1 | +name: Bump Homebrew formula |
| 2 | + |
| 3 | +# Updates the `ronyup` formula in clubpay/homebrew-tap whenever a new |
| 4 | +# `ronyup/vX.Y.Z` tag is pushed (created by scripts/bump-workspace.sh). |
| 5 | +# |
| 6 | +# Requires a repository secret HOMEBREW_TAP_TOKEN: a PAT (or fine-grained token) |
| 7 | +# with `contents:write` on clubpay/homebrew-tap. The default GITHUB_TOKEN cannot |
| 8 | +# push to another repository. |
| 9 | + |
| 10 | +on: |
| 11 | + push: |
| 12 | + tags: |
| 13 | + - "ronyup/v*" |
| 14 | + workflow_dispatch: |
| 15 | + inputs: |
| 16 | + tag: |
| 17 | + description: "ronyup tag to publish (e.g. ronyup/v0.4.7)" |
| 18 | + required: true |
| 19 | + |
| 20 | +jobs: |
| 21 | + bump: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + steps: |
| 24 | + - name: Resolve tag and version |
| 25 | + id: meta |
| 26 | + run: | |
| 27 | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then |
| 28 | + TAG="${{ github.event.inputs.tag }}" |
| 29 | + else |
| 30 | + TAG="${GITHUB_REF#refs/tags/}" |
| 31 | + fi |
| 32 | + # TAG looks like "ronyup/v0.4.7"; VERSION is "0.4.7". |
| 33 | + VERSION="${TAG##*/v}" |
| 34 | + echo "tag=$TAG" >> "$GITHUB_OUTPUT" |
| 35 | + echo "version=$VERSION" >> "$GITHUB_OUTPUT" |
| 36 | +
|
| 37 | + - name: Compute source tarball checksum |
| 38 | + id: sha |
| 39 | + run: | |
| 40 | + URL="https://github.com/${{ github.repository }}/archive/refs/tags/${{ steps.meta.outputs.tag }}.tar.gz" |
| 41 | + echo "url=$URL" >> "$GITHUB_OUTPUT" |
| 42 | + curl -fsSL "$URL" -o source.tar.gz |
| 43 | + SHA="$(sha256sum source.tar.gz | cut -d' ' -f1)" |
| 44 | + echo "sha256=$SHA" >> "$GITHUB_OUTPUT" |
| 45 | +
|
| 46 | + - name: Checkout tap |
| 47 | + uses: actions/checkout@v6 |
| 48 | + with: |
| 49 | + repository: clubpay/homebrew-tap |
| 50 | + token: ${{ secrets.HOMEBREW_TAP_TOKEN }} |
| 51 | + path: tap |
| 52 | + |
| 53 | + - name: Update formula |
| 54 | + run: | |
| 55 | + FORMULA="tap/Formula/ronyup.rb" |
| 56 | + sed -i -E "s|^ url \".*\"| url \"${{ steps.sha.outputs.url }}\"|" "$FORMULA" |
| 57 | + sed -i -E "s|^ sha256 \".*\"| sha256 \"${{ steps.sha.outputs.sha256 }}\"|" "$FORMULA" |
| 58 | + echo "----- updated formula -----" |
| 59 | + cat "$FORMULA" |
| 60 | +
|
| 61 | + - name: Commit and push |
| 62 | + run: | |
| 63 | + cd tap |
| 64 | + if git diff --quiet; then |
| 65 | + echo "Formula already up to date; nothing to do." |
| 66 | + exit 0 |
| 67 | + fi |
| 68 | + git config user.name "github-actions[bot]" |
| 69 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 70 | + git add Formula/ronyup.rb |
| 71 | + git commit -m "ronyup ${{ steps.meta.outputs.version }}" |
| 72 | + git push |
0 commit comments