|
| 1 | +name: Release & Update Homebrew Tap |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - "[0-9]+.[0-9]+.[0-9]+" |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + release: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + steps: |
| 15 | + - name: Extract version from tag |
| 16 | + id: version |
| 17 | + run: echo "version=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT" |
| 18 | + |
| 19 | + - name: Download source tarball |
| 20 | + run: | |
| 21 | + curl -sL -o spacehammer.tar.gz \ |
| 22 | + "https://github.com/agzam/spacehammer/archive/refs/tags/${{ steps.version.outputs.version }}.tar.gz" |
| 23 | +
|
| 24 | + - name: Compute SHA-256 |
| 25 | + id: sha |
| 26 | + run: | |
| 27 | + sha=$(shasum -a 256 spacehammer.tar.gz | awk '{print $1}') |
| 28 | + echo "sha256=${sha}" >> "$GITHUB_OUTPUT" |
| 29 | + echo "SHA-256: ${sha}" |
| 30 | +
|
| 31 | + - name: Create GitHub Release |
| 32 | + env: |
| 33 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 34 | + run: | |
| 35 | + gh release create "${{ steps.version.outputs.version }}" \ |
| 36 | + --repo agzam/spacehammer \ |
| 37 | + --title "v${{ steps.version.outputs.version }}" \ |
| 38 | + --generate-notes |
| 39 | +
|
| 40 | + - name: Update Homebrew tap |
| 41 | + env: |
| 42 | + TAP_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }} |
| 43 | + run: | |
| 44 | + git clone "https://x-access-token:${TAP_TOKEN}@github.com/agzam/homebrew-spacehammer.git" tap |
| 45 | + cd tap |
| 46 | +
|
| 47 | + VERSION="${{ steps.version.outputs.version }}" |
| 48 | + SHA="${{ steps.sha.outputs.sha256 }}" |
| 49 | +
|
| 50 | + sed -i "s/version \".*\"/version \"${VERSION}\"/" Casks/spacehammer.rb |
| 51 | + sed -i "s/sha256 \".*\"/sha256 \"${SHA}\"/" Casks/spacehammer.rb |
| 52 | +
|
| 53 | + git config user.name "github-actions[bot]" |
| 54 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 55 | + git add Casks/spacehammer.rb |
| 56 | + git commit -m "spacehammer ${VERSION}" |
| 57 | + git push |
0 commit comments