Skip to content

Commit 44213c3

Browse files
committed
Enable homebrew publishing
commit-id: I01c1f02b
1 parent 3f0fb15 commit 44213c3

1 file changed

Lines changed: 82 additions & 5 deletions

File tree

.github/workflows/build_and_release.yml

Lines changed: 82 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ on:
1111
required: true
1212
type: string
1313

14+
env:
15+
TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}
16+
1417
jobs:
1518
create_release:
1619
name: Create Release
@@ -24,7 +27,7 @@ jobs:
2427
id: create_release
2528
uses: "softprops/action-gh-release@v2"
2629
with:
27-
tag_name: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref_name }}
30+
tag_name: ${{ env.TAG }}
2831
draft: true
2932
generate_release_notes: true
3033

@@ -35,9 +38,9 @@ jobs:
3538
matrix:
3639
include:
3740
- os: 'ubuntu-latest'
38-
label: 'linux'
41+
label: 'linux-amd64'
3942
- os: 'macos-latest'
40-
label: 'mac'
43+
label: 'macos-arm64'
4144
runs-on: ${{matrix.os}}
4245
steps:
4346
- uses: actions/checkout@v6
@@ -61,8 +64,8 @@ jobs:
6164
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
6265
with:
6366
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'
6669
asset_content_type: application/octet-stream
6770

6871
publish_release:
@@ -75,3 +78,77 @@ jobs:
7578
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7679
with:
7780
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

Comments
 (0)