From a80d04fe53e8f9da2f4294b3edc164792548e7d5 Mon Sep 17 00:00:00 2001 From: Alex Zamai Date: Mon, 7 Sep 2026 09:31:49 +0200 Subject: [PATCH 1/2] feat: add Homebrew installation --- .github/workflows/release.yml | 7 ++++++- .goreleaser.yaml | 19 ++++++++++++++++++- README.md | 17 +++++++++++++++-- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3a78040..4f1b8ca 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,7 +5,8 @@ on: tags: - '*' -# Least privilege: goreleaser only needs to create the release / upload assets. +# Least privilege for the release repository. Publishing to the separate +# Homebrew tap uses HOMEBREW_TAP_GITHUB_TOKEN below. permissions: contents: write @@ -29,10 +30,12 @@ jobs: env: APP_ID: ${{ secrets.APP_ID }} APP_HASH: ${{ secrets.APP_HASH }} + HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }} run: | missing= [ -n "$APP_ID" ] || missing="$missing APP_ID" [ -n "$APP_HASH" ] || missing="$missing APP_HASH" + [ -n "$HOMEBREW_TAP_GITHUB_TOKEN" ] || missing="$missing HOMEBREW_TAP_GITHUB_TOKEN" if [ -n "$missing" ]; then echo "::error::Missing required release secret(s):$missing. Set them with: gh secret set " exit 1 @@ -53,6 +56,8 @@ jobs: # tdesktop fallback. APP_ID: ${{ secrets.APP_ID }} APP_HASH: ${{ secrets.APP_HASH }} + # Cross-repository publishing cannot use GITHUB_TOKEN. + HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }} - name: Upload assets uses: actions/upload-artifact@v7.0.2 diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 784be52..0df5fe4 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -53,4 +53,21 @@ nfpms: formats: - apk - deb - - rpm \ No newline at end of file + - rpm +homebrew_casks: + - name: tg + binaries: + - tg + homepage: https://github.com/gotd/cli + description: Telegram CLI for humans and agents + hooks: + post: + install: | + if OS.mac? + system_command "/usr/bin/xattr", args: ["-dr", "com.apple.quarantine", "#{staged_path}/tg"] + end + repository: + owner: gotd + name: homebrew-tap + branch: main + token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}" diff --git a/README.md b/README.md index d45d008..38a5112 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,21 @@ Built on [`gotd/td`](https://github.com/gotd/td). ## Installation -Download a prebuilt binary or package (`.deb`/`.rpm`/`.apk`) for your platform from -the [latest release](https://github.com/gotd/cli/releases/latest). +Install with Homebrew: + +```console +$ brew install --cask gotd/tap/tg +``` + +GoReleaser updates the tap when a new version is published, so future updates +use the regular Homebrew flow: + +```console +$ brew upgrade tg +``` + +Alternatively, download a prebuilt binary or package (`.deb`/`.rpm`/`.apk`) for +your platform from the [latest release](https://github.com/gotd/cli/releases/latest). ## Quick start From aeec2ad36bc1f1e9f4228ec8123e28d9b30b8e72 Mon Sep 17 00:00:00 2001 From: Aleksandr Razumov Date: Mon, 16 Nov 2026 15:31:24 +0300 Subject: [PATCH 2/2] fix(release): use cask install_steps and a deploy key for the tap Homebrew 7 deprecates the postflight stanza that the install hook renders; install_steps (GoReleaser v2.19+) renders postflight_steps. Publish to gotd/homebrew-tap over SSH with a write deploy key (HOMEBREW_TAP_DEPLOY_KEY) instead of a personal access token. --- .github/workflows/release.yml | 11 ++++++----- .goreleaser.yaml | 14 ++++++++++---- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4f1b8ca..d363ca9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,7 +6,7 @@ on: - '*' # Least privilege for the release repository. Publishing to the separate -# Homebrew tap uses HOMEBREW_TAP_GITHUB_TOKEN below. +# Homebrew tap uses HOMEBREW_TAP_DEPLOY_KEY below. permissions: contents: write @@ -30,12 +30,12 @@ jobs: env: APP_ID: ${{ secrets.APP_ID }} APP_HASH: ${{ secrets.APP_HASH }} - HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }} + HOMEBREW_TAP_DEPLOY_KEY: ${{ secrets.HOMEBREW_TAP_DEPLOY_KEY }} run: | missing= [ -n "$APP_ID" ] || missing="$missing APP_ID" [ -n "$APP_HASH" ] || missing="$missing APP_HASH" - [ -n "$HOMEBREW_TAP_GITHUB_TOKEN" ] || missing="$missing HOMEBREW_TAP_GITHUB_TOKEN" + [ -n "$HOMEBREW_TAP_DEPLOY_KEY" ] || missing="$missing HOMEBREW_TAP_DEPLOY_KEY" if [ -n "$missing" ]; then echo "::error::Missing required release secret(s):$missing. Set them with: gh secret set " exit 1 @@ -56,8 +56,9 @@ jobs: # tdesktop fallback. APP_ID: ${{ secrets.APP_ID }} APP_HASH: ${{ secrets.APP_HASH }} - # Cross-repository publishing cannot use GITHUB_TOKEN. - HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }} + # Write deploy key of gotd/homebrew-tap: cross-repository publishing + # cannot use GITHUB_TOKEN. + HOMEBREW_TAP_DEPLOY_KEY: ${{ secrets.HOMEBREW_TAP_DEPLOY_KEY }} - name: Upload assets uses: actions/upload-artifact@v7.0.2 diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 0df5fe4..9aa270a 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -62,12 +62,18 @@ homebrew_casks: description: Telegram CLI for humans and agents hooks: post: - install: | - if OS.mac? - system_command "/usr/bin/xattr", args: ["-dr", "com.apple.quarantine", "#{staged_path}/tg"] + # install_steps needs GoReleaser v2.19+; the older `install` hook + # renders the `postflight` stanza that Homebrew 7 deprecates. + install_steps: | + on_macos do + run "/usr/bin/xattr", args: ["-dr", "com.apple.quarantine", "{{ .StagedPath }}/tg"] end + # Pushed over SSH with a write deploy key that is scoped to the tap + # repository only (GITHUB_TOKEN cannot write to another repository). repository: owner: gotd name: homebrew-tap branch: main - token: "{{ .Env.HOMEBREW_TAP_GITHUB_TOKEN }}" + git: + url: git@github.com:gotd/homebrew-tap.git + private_key: "{{ .Env.HOMEBREW_TAP_DEPLOY_KEY }}"