|
11 | 11 | required: true |
12 | 12 | type: string |
13 | 13 |
|
| 14 | +env: |
| 15 | + TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }} |
| 16 | + |
14 | 17 | jobs: |
15 | 18 | create_release: |
16 | 19 | name: Create Release |
|
24 | 27 | id: create_release |
25 | 28 | uses: "softprops/action-gh-release@v2" |
26 | 29 | with: |
27 | | - tag_name: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }} |
| 30 | + tag_name: ${{ env.TAG }} |
28 | 31 | draft: true |
29 | 32 | generate_release_notes: true |
30 | 33 |
|
|
35 | 38 | matrix: |
36 | 39 | include: |
37 | 40 | - os: 'ubuntu-latest' |
38 | | - label: 'linux' |
| 41 | + label: 'linux-amd64' |
39 | 42 | - os: 'macos-latest' |
40 | | - label: 'mac' |
| 43 | + label: 'macos-arm64' |
41 | 44 | runs-on: ${{matrix.os}} |
42 | 45 | steps: |
43 | 46 | - uses: actions/checkout@v6 |
|
61 | 64 | GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} |
62 | 65 | with: |
63 | 66 | upload_url: ${{ needs.create_release.outputs.upload_url }} |
64 | | - asset_name: 'git-jaspr-${{matrix.label}}' |
65 | | - asset_path: 'git-jaspr/build/native/nativeCompile/git-jaspr' |
| 67 | + asset_name: 'jaspr-${{matrix.label}}' |
| 68 | + asset_path: 'git-jaspr/build/native/nativeCompile/jaspr' |
66 | 69 | asset_content_type: application/octet-stream |
67 | 70 |
|
68 | 71 | publish_release: |
|
75 | 78 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
76 | 79 | with: |
77 | 80 | release_id: ${{ needs.create_release.outputs.release_id }} |
| 81 | + |
| 82 | + update_homebrew: |
| 83 | + name: Update Homebrew Formula |
| 84 | + needs: ['publish_release'] |
| 85 | + runs-on: 'ubuntu-latest' |
| 86 | + steps: |
| 87 | + - name: 'Download release assets' |
| 88 | + env: |
| 89 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 90 | + run: gh release download "$TAG" --repo "${{ github.repository }}" --pattern 'jaspr-*' |
| 91 | + |
| 92 | + - name: 'Compute checksums' |
| 93 | + id: checksums |
| 94 | + run: | |
| 95 | + echo "linux_amd64=$(sha256sum jaspr-linux-amd64 | awk '{print $1}')" >> "$GITHUB_OUTPUT" |
| 96 | + echo "macos_arm64=$(sha256sum jaspr-macos-arm64 | awk '{print $1}')" >> "$GITHUB_OUTPUT" |
| 97 | +
|
| 98 | + - name: 'Generate formula' |
| 99 | + env: |
| 100 | + LINUX_AMD64_SHA256: ${{ steps.checksums.outputs.linux_amd64 }} |
| 101 | + MACOS_ARM64_SHA256: ${{ steps.checksums.outputs.macos_arm64 }} |
| 102 | + run: | |
| 103 | + cat > jaspr.rb << FORMULA |
| 104 | + class Jaspr < Formula |
| 105 | + desc "Stacked pull requests on GitHub" |
| 106 | + homepage "https://github.com/MichaelSims/git-jaspr" |
| 107 | + version "${TAG#v}" |
| 108 | + license "Apache-2.0" |
| 109 | +
|
| 110 | + on_macos do |
| 111 | + if Hardware::CPU.arm? |
| 112 | + url "https://github.com/MichaelSims/git-jaspr/releases/download/${TAG}/jaspr-macos-arm64" |
| 113 | + sha256 "${MACOS_ARM64_SHA256}" |
| 114 | +
|
| 115 | + def install |
| 116 | + bin.install "jaspr-macos-arm64" => "jaspr" |
| 117 | + end |
| 118 | + end |
| 119 | + end |
| 120 | +
|
| 121 | + on_linux do |
| 122 | + if Hardware::CPU.intel? |
| 123 | + url "https://github.com/MichaelSims/git-jaspr/releases/download/${TAG}/jaspr-linux-amd64" |
| 124 | + sha256 "${LINUX_AMD64_SHA256}" |
| 125 | +
|
| 126 | + def install |
| 127 | + bin.install "jaspr-linux-amd64" => "jaspr" |
| 128 | + end |
| 129 | + end |
| 130 | + end |
| 131 | +
|
| 132 | + test do |
| 133 | + system "#{bin}/jaspr", "--version" |
| 134 | + end |
| 135 | + end |
| 136 | + FORMULA |
| 137 | +
|
| 138 | + - name: 'Setup SSH for tap repo' |
| 139 | + uses: webfactory/ssh-agent@v0.9.0 |
| 140 | + with: |
| 141 | + ssh-private-key: ${{ secrets.HOMEBREW_TAP_DEPLOY_KEY }} |
| 142 | + |
| 143 | + - name: 'Clone tap repo' |
| 144 | + run: git clone git@github.com:MichaelSims/homebrew-tap.git |
| 145 | + |
| 146 | + - name: 'Update formula' |
| 147 | + run: | |
| 148 | + cp jaspr.rb homebrew-tap/jaspr.rb |
| 149 | + cd homebrew-tap |
| 150 | + git config user.name "github-actions[bot]" |
| 151 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 152 | + git add jaspr.rb |
| 153 | + git commit -m "Update jaspr to ${TAG}" |
| 154 | + git push |
0 commit comments