|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "v*.*.*" |
| 7 | + |
| 8 | +jobs: |
| 9 | + update-homebrew: |
| 10 | + name: Update Homebrew tap formula |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - name: Check out Focal repository |
| 14 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 |
| 15 | + |
| 16 | + - name: Check out Homebrew Tap |
| 17 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 |
| 18 | + with: |
| 19 | + repository: JacksonFergusonDev/homebrew-tap |
| 20 | + token: ${{ secrets.TAP_GITHUB_TOKEN }} |
| 21 | + path: homebrew-tap |
| 22 | + |
| 23 | + - name: Set up Homebrew |
| 24 | + uses: Homebrew/actions/setup-homebrew@9926e3be887aa6c9523a027099bf5e882056f5c1 |
| 25 | + |
| 26 | + - name: Tap the repository |
| 27 | + run: brew tap JacksonFergusonDev/homebrew-tap ./homebrew-tap |
| 28 | + |
| 29 | + - name: Bump formula URL and SHA |
| 30 | + working-directory: homebrew-tap |
| 31 | + env: |
| 32 | + TAG: ${{ github.ref_name }} |
| 33 | + run: | |
| 34 | + set -euo pipefail |
| 35 | +
|
| 36 | + FORMULA="Formula/focal.rb" |
| 37 | + BREW_TAP_DIR="$(brew --repository jacksonfergusondev/homebrew-tap)" |
| 38 | + BREW_FORMULA="$BREW_TAP_DIR/$FORMULA" |
| 39 | +
|
| 40 | + # 1. Construct the GitHub release tarball URL |
| 41 | + NEW_URL="https://github.com/JacksonFergusonDev/focal/archive/refs/tags/${TAG}.tar.gz" |
| 42 | +
|
| 43 | + # 2. Download the tarball and compute the SHA256 |
| 44 | + echo "Fetching ${NEW_URL}..." |
| 45 | + curl -sL "$NEW_URL" -o release.tar.gz |
| 46 | + NEW_SHA="$(sha256sum release.tar.gz | awk '{print $1}')" |
| 47 | + rm release.tar.gz |
| 48 | +
|
| 49 | + if [ -z "$NEW_SHA" ]; then |
| 50 | + echo "Failed to compute SHA256 for the release tarball." |
| 51 | + exit 1 |
| 52 | + fi |
| 53 | +
|
| 54 | + echo "New Version: $TAG" |
| 55 | + echo "New SHA256: $NEW_SHA" |
| 56 | +
|
| 57 | + # 3. Update formula in HOMEBREW'S internal directory |
| 58 | + sed -i "s|^ url \".*\"| url \"${NEW_URL}\"|" "$BREW_FORMULA" |
| 59 | + sed -i "s|^ sha256 \".*\"| sha256 \"${NEW_SHA}\"|" "$BREW_FORMULA" |
| 60 | +
|
| 61 | + # 4. Copy the fully updated formula back to the local GitHub Action workspace |
| 62 | + cp "$BREW_FORMULA" "$FORMULA" |
| 63 | +
|
| 64 | + # 5. Commit + push if anything changed |
| 65 | + git config user.name "github-actions[bot]" |
| 66 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 67 | + git add "$FORMULA" |
| 68 | +
|
| 69 | + if git diff --cached --quiet; then |
| 70 | + echo "No formula changes to commit." |
| 71 | + exit 0 |
| 72 | + fi |
| 73 | +
|
| 74 | + # 6. Audit the formula to ensure no syntax errors were introduced |
| 75 | + brew audit --strict --online jacksonfergusondev/homebrew-tap/focal |
| 76 | +
|
| 77 | + git commit -m "chore: bump focal to ${TAG}" |
| 78 | + git push |
0 commit comments