Skip to content

Commit fb3046a

Browse files
Publish a Homebrew cask to duneanalytics/homebrew-tap (#64)
* Publish a Homebrew cask to duneanalytics/homebrew-tap GoReleaser now generates the dune-cli cask on each release and opens a PR against the tap's main branch, which requires PRs. The cask clears the macOS quarantine bit since the binary is not notarized. Publishing is skipped until the HOMEBREW_TAP_GITHUB_TOKEN secret exists. Towards GRO-1380 Amp-Thread-ID: https://ampcode.com/threads/T-01a1ef85-b72d-741e-af78-85fff2e3f20d Co-authored-by: Amp <amp@ampcode.com> * Mint the Homebrew tap token from a GitHub App Use the homebrew-tap-writer app (DF-1897) via actions/create-github-app-token, matching the org pattern, instead of a long-lived token secret. The step and the cask are skipped until the app secrets exist. Towards GRO-1380 Amp-Thread-ID: https://ampcode.com/threads/T-01a1ef85-b72d-741e-af78-85fff2e3f20d Co-authored-by: Amp <amp@ampcode.com> * Skip the tap token while the app secret is a placeholder Towards GRO-1380 Amp-Thread-ID: https://ampcode.com/threads/T-01a1ef85-b72d-741e-af78-85fff2e3f20d Co-authored-by: Amp <amp@ampcode.com> --------- Co-authored-by: Amp <amp@ampcode.com>
1 parent f6a3b0b commit fb3046a

4 files changed

Lines changed: 61 additions & 0 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ permissions:
1111
jobs:
1212
release:
1313
runs-on: ubuntu-latest
14+
env:
15+
# infra creates repo secrets with the value PLACEHOLDER until set by hand.
16+
HAS_TAP_APP: ${{ secrets.HOMEBREW_TAP_WRITER_APP_CLIENT_ID != '' && secrets.HOMEBREW_TAP_WRITER_APP_CLIENT_ID != 'PLACEHOLDER' }}
1417
steps:
1518
- name: Checkout
1619
uses: actions/checkout@v4
@@ -22,6 +25,19 @@ jobs:
2225
with:
2326
go-version-file: go.mod
2427

28+
# Short-lived token for the homebrew-tap-writer GitHub App, which opens the
29+
# cask PR on duneanalytics/homebrew-tap. Skipped until the app secrets
30+
# exist; GoReleaser then skips the cask.
31+
- name: Generate token for homebrew-tap
32+
id: tap-token
33+
if: env.HAS_TAP_APP == 'true'
34+
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
35+
with:
36+
client-id: ${{ secrets.HOMEBREW_TAP_WRITER_APP_CLIENT_ID }}
37+
private-key: ${{ secrets.HOMEBREW_TAP_WRITER_APP_PRIVATE_KEY }}
38+
owner: duneanalytics
39+
repositories: homebrew-tap
40+
2541
- name: Run GoReleaser
2642
uses: goreleaser/goreleaser-action@v6
2743
with:
@@ -31,3 +47,4 @@ jobs:
3147
env:
3248
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3349
AMPLITUDE_KEY: ${{ secrets.AMPLITUDE_KEY }}
50+
HOMEBREW_TAP_GITHUB_TOKEN: ${{ steps.tap-token.outputs.token }}

‎.gitignore‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,6 @@
1616

1717
# CLI binary
1818
dune-cli
19+
20+
# GoReleaser output
21+
/dist/

‎.goreleaser.yml‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,39 @@ archives:
3838
formats:
3939
- zip
4040

41+
homebrew_casks:
42+
- name: dune-cli
43+
binaries:
44+
- dune
45+
homepage: https://github.com/duneanalytics/cli
46+
description: Command-line interface for the Dune API
47+
directory: Casks
48+
commit_msg_template: "Brew cask update for {{ .ProjectName }} version {{ .Tag }}"
49+
# Publishing stays off until the tap token secret exists, so releases
50+
# don't fail on it; prereleases are never published.
51+
skip_upload: '{{ if index .Env "HOMEBREW_TAP_GITHUB_TOKEN" }}auto{{ else }}true{{ end }}'
52+
# The binary is not signed or notarized, so clear the quarantine bit that
53+
# Homebrew sets on download; otherwise macOS refuses to run it.
54+
hooks:
55+
post:
56+
install_steps: |
57+
on_macos do
58+
run "/usr/bin/xattr", args: ["-dr", "com.apple.quarantine", "{{ .StagedPath }}/dune"]
59+
end
60+
# The tap's main branch requires pull requests, so push a release branch
61+
# and open a PR instead of committing to main.
62+
repository:
63+
owner: duneanalytics
64+
name: homebrew-tap
65+
branch: "dune-cli-{{ .Version }}"
66+
token: '{{ if index .Env "HOMEBREW_TAP_GITHUB_TOKEN" }}{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}{{ end }}'
67+
pull_request:
68+
enabled: true
69+
base:
70+
owner: duneanalytics
71+
name: homebrew-tap
72+
branch: main
73+
4174
checksum:
4275
name_template: "checksums.txt"
4376

‎README.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ A command-line interface for interacting with the [Dune](https://dune.com/) API
44

55
## Installation
66

7+
### Homebrew (macOS and Linux)
8+
9+
```bash
10+
brew install duneanalytics/tap/dune-cli
11+
```
12+
13+
### Install script
14+
715
```bash
816
curl -sSfL https://github.com/duneanalytics/cli/raw/main/install.sh | bash
917
```

0 commit comments

Comments
 (0)