Skip to content

Commit 0bf41f4

Browse files
chore(distribution): add homebrew tap automation
1 parent f567004 commit 0bf41f4

2 files changed

Lines changed: 149 additions & 0 deletions

File tree

.github/workflows/homebrew-tap.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Update Homebrew Tap
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
tag:
9+
description: "Release tag (e.g. v0.1.1)"
10+
required: true
11+
type: string
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
update-tap:
18+
name: Update Homebrew Cask
19+
runs-on: ubuntu-latest
20+
if: ${{ vars.HOMEBREW_TAP_REPO != '' }}
21+
steps:
22+
- name: Resolve tag
23+
id: tag
24+
run: |
25+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
26+
echo "value=${{ inputs.tag }}" >> "$GITHUB_OUTPUT"
27+
else
28+
echo "value=${{ github.event.release.tag_name }}" >> "$GITHUB_OUTPUT"
29+
fi
30+
31+
- name: Fetch release metadata
32+
id: release
33+
env:
34+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35+
run: |
36+
TAG="${{ steps.tag.outputs.value }}"
37+
gh api "repos/${{ github.repository }}/releases/tags/${TAG}" > release.json
38+
39+
# Prefer universal dmg, fallback to first dmg.
40+
ASSET_URL=$(jq -r '
41+
(
42+
.assets[]
43+
| select(.name | test("(?i)universal.*\\.dmg$"))
44+
| .browser_download_url
45+
) // (
46+
.assets[]
47+
| select(.name | test("\\.dmg$"))
48+
| .browser_download_url
49+
)' release.json | head -n1)
50+
51+
ASSET_NAME=$(basename "$ASSET_URL")
52+
if [ -z "$ASSET_URL" ] || [ "$ASSET_URL" = "null" ]; then
53+
echo "No .dmg asset found for tag ${TAG}" >&2
54+
exit 1
55+
fi
56+
57+
curl -L "$ASSET_URL" -o "$ASSET_NAME"
58+
SHA256=$(sha256sum "$ASSET_NAME" | awk '{print $1}')
59+
VERSION="${TAG#v}"
60+
61+
echo "asset_url=$ASSET_URL" >> "$GITHUB_OUTPUT"
62+
echo "asset_name=$ASSET_NAME" >> "$GITHUB_OUTPUT"
63+
echo "sha256=$SHA256" >> "$GITHUB_OUTPUT"
64+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
65+
66+
- name: Checkout tap repository
67+
uses: actions/checkout@v4
68+
with:
69+
repository: ${{ vars.HOMEBREW_TAP_REPO }}
70+
token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
71+
path: tap
72+
73+
- name: Update Cask
74+
run: |
75+
mkdir -p tap/Casks
76+
cat > tap/Casks/kore.rb <<'EOF'
77+
cask "kore" do
78+
version "${{ steps.release.outputs.version }}"
79+
sha256 "${{ steps.release.outputs.sha256 }}"
80+
81+
url "${{ steps.release.outputs.asset_url }}"
82+
name "Kore"
83+
desc "Kubernetes Orchestration and Resource Explorer"
84+
homepage "https://github.com/${{ github.repository }}"
85+
86+
app "Kore.app"
87+
88+
caveats <<~EOS
89+
If macOS blocks launch, remove quarantine and reopen:
90+
xattr -dr com.apple.quarantine /Applications/Kore.app
91+
EOS
92+
end
93+
EOF
94+
95+
- name: Commit and push tap update
96+
run: |
97+
cd tap
98+
git config user.name "github-actions[bot]"
99+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
100+
git add Casks/kore.rb
101+
git commit -m "kore ${{ steps.release.outputs.version }}" || echo "No changes to commit"
102+
git push

docs/distribution/homebrew.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Homebrew Distribution
2+
3+
This project can publish a cask to a custom Homebrew tap on each GitHub release tag.
4+
5+
## 1) Create a tap repo
6+
7+
Create a repository like:
8+
9+
- `DEVtheOPS/homebrew-kore`
10+
11+
Expected cask path:
12+
13+
- `Casks/kore.rb`
14+
15+
## 2) Configure this repo
16+
17+
In this repo's GitHub settings, set:
18+
19+
- Repository variable: `HOMEBREW_TAP_REPO`
20+
- Example: `DEVtheOPS/homebrew-kore`
21+
- Repository secret: `HOMEBREW_TAP_TOKEN`
22+
- Fine-grained PAT with `Contents: Read and write` on the tap repo.
23+
24+
Workflow file:
25+
26+
- `.github/workflows/homebrew-tap.yml`
27+
28+
It triggers when a release is published (`v*` tags from the release workflow).
29+
30+
## 3) User install command
31+
32+
Without Apple notarization, quarantine can block launch. Prefer:
33+
34+
```bash
35+
brew install --cask --no-quarantine devtheops/kore/kore
36+
```
37+
38+
If already installed and blocked:
39+
40+
```bash
41+
xattr -dr com.apple.quarantine /Applications/Kore.app
42+
```
43+
44+
## Notes
45+
46+
- The workflow picks a `.dmg` asset from the release (prefers `universal` if present).
47+
- It computes `sha256` and updates `Casks/kore.rb` automatically.

0 commit comments

Comments
 (0)