From aab0fea1d6ead644902c35ddaf4643431825dc4f Mon Sep 17 00:00:00 2001 From: jinil-ha Date: Mon, 30 Nov 2026 17:22:44 +0900 Subject: [PATCH 1/3] Package native tgrep releases for Homebrew --- .github/workflows/release.yml | 88 +++++++++++++++++++++++++++++++++++ README.jp.md | 14 ++++-- README.kr.md | 14 ++++-- README.md | 14 ++++-- 4 files changed, 115 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..3bedd40 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,88 @@ +name: Release + +on: + push: + tags: ['v[0-9]+.[0-9]+.[0-9]+'] + pull_request: + paths: ['.github/workflows/release.yml'] + +permissions: + contents: read + +jobs: + package: + strategy: + matrix: + runner: [macos-15, macos-15-intel, ubuntu-22.04, ubuntu-22.04-arm] + runs-on: ${{ matrix.runner }} + env: + CGO_ENABLED: '1' + MACOSX_DEPLOYMENT_TARGET: '13.0' + steps: + # A packaging PR rehearses a release of the current base commit. + # Pushing a version tag builds the exact commit that tag points to. + - uses: actions/checkout@v7 + with: + ref: ${{ github.event.pull_request.base.sha || github.sha }} + persist-credentials: false + - uses: actions/setup-go@v7 + with: + go-version: '1.27.x' + - run: go test ./... + - name: Build and package the native binary + shell: bash + run: | + package="$RUNNER_TEMP/package" + mkdir -p "$package/licenses" + go build -mod=readonly -trimpath -buildvcs=true -o "$package/tgrep" ./cmd/tgrep + cp LICENSE "$package/" + cp "$(go env GOROOT)/LICENSE" "$package/licenses/Go-LICENSE" + go mod vendor -o "$RUNNER_TEMP/vendor" + ( + cd "$RUNNER_TEMP/vendor" + find . -type f \( -iname 'license*' -o -iname 'notice*' -o -iname 'copying*' \) | + while IFS= read -r file; do + mkdir -p "$package/licenses/$(dirname "$file")" + cp "$file" "$package/licenses/$file" + done + ) + archive="tgrep-$(go env GOOS)-$(go env GOARCH).tar.gz" + tar -czf "$RUNNER_TEMP/$archive" -C "$package" tgrep LICENSE licenses + echo "ARCHIVE=$archive" >> "$GITHUB_ENV" + - name: Search with the packaged binary + shell: bash + run: | + mkdir -p "$RUNNER_TEMP/smoke"/{en,ko} + cd "$RUNNER_TEMP/smoke" + tar -xzf "$RUNNER_TEMP/$ARCHIVE" + echo "Sign in" > en/guide + echo "로그인" > ko/guide + export TGREP_ENTER_ACTION=print FZF_DEFAULT_OPTS=--filter=guide + test "$(./tgrep 'sign in')" = './en/guide:1:Sign in' + - uses: actions/upload-artifact@v7 + with: + name: ${{ matrix.runner }} + path: ${{ runner.temp }}/tgrep-*.tar.gz + if-no-files-found: error + compression-level: 0 + + publish: + if: github.event_name == 'push' + needs: package + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/download-artifact@v8 + with: + path: dist + merge-multiple: true + - name: Publish archives and checksums to the tagged release + working-directory: dist + env: + GH_TOKEN: ${{ github.token }} + run: | + sha256sum tgrep-{darwin,linux}-{amd64,arm64}.tar.gz > SHA256SUMS + gh release create "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" \ + --verify-tag --generate-notes --title "$GITHUB_REF_NAME" \ + SHA256SUMS tgrep-*.tar.gz diff --git a/README.jp.md b/README.jp.md index 19db74f..eadf6a7 100644 --- a/README.jp.md +++ b/README.jp.md @@ -7,15 +7,19 @@ [検索から翻訳ファイルを開くまでの GIF を見る](assets/tgrep-demo.gif) -## 必要なツール +## インストール -macOS と Linux でソースからビルドするには Go 1.23 以降と C コンパイラが必要です。バイナリには fzf が含まれ、検索と強調表示にはシステムの POSIX 正規表現ライブラリを使います。 +macOS と Linux では Homebrew でインストールできます。 -Git があれば作業ツリーの除外規則を適用します。左右比較には Vim、翻訳の編集には `$EDITOR`(既定は `vi`)を使います。 +```sh +brew install antfrog/tap/tgrep +``` -## インストール +Homebrew が Apple Silicon・Intel Mac または Linux の ARM64・x86_64 に対応するビルド済みバイナリをダウンロードします。 + +### ソースからインストールする -クローンしたリポジトリから、`PATH` の通ったディレクトリにバイナリをインストールします。 +リポジトリをクローンし、Go 1.23 以降と C コンパイラでビルドしてインストールします。 ```sh GOBIN="$HOME/.local/bin" go install ./cmd/tgrep diff --git a/README.kr.md b/README.kr.md index 2b544ed..fdbfdb6 100644 --- a/README.kr.md +++ b/README.kr.md @@ -7,15 +7,19 @@ [검색부터 번역 파일 열기까지 GIF로 보기](assets/tgrep-demo.gif) -## 필요한 도구 +## 설치 -macOS와 Linux에서 소스 빌드에 Go 1.23 이상과 C 컴파일러가 필요합니다. 빌드한 바이너리에는 fzf가 포함되며, 검색과 강조 표시에는 시스템의 POSIX 정규식 라이브러리를 사용합니다. +macOS와 Linux에서 Homebrew로 설치할 수 있습니다. -Git이 있으면 작업 트리의 제외 규칙을 적용합니다. 좌우 비교에는 Vim을, 번역 편집에는 `$EDITOR`(기본값 `vi`)를 사용합니다. +```sh +brew install antfrog/tap/tgrep +``` -## 설치 +Homebrew가 Apple Silicon·Intel Mac 또는 Linux ARM64·x86_64에 맞는 바이너리를 내려받습니다. + +### 소스에서 설치 -저장소를 복제한 뒤 `PATH`에 포함된 디렉터리에 바이너리를 설치합니다. +저장소를 복제한 뒤 Go 1.23 이상과 C 컴파일러로 빌드해 설치합니다. ```sh GOBIN="$HOME/.local/bin" go install ./cmd/tgrep diff --git a/README.md b/README.md index 5b923e0..4089794 100644 --- a/README.md +++ b/README.md @@ -7,15 +7,19 @@ I built `tgrep` while translating the [Kubernetes documentation](https://github. [Watch the search-to-editor demo (GIF)](assets/tgrep-demo.gif) -## Dependencies +## Install -Build from source on macOS or Linux with Go 1.23 or later and a C compiler. The binary includes fzf and uses the system POSIX regular expression library for search and highlighting. +Install with Homebrew on macOS or Linux. -Git supplies ignore rules in working trees when available. Side-by-side comparison uses Vim, and editing uses `$EDITOR` (default `vi`). +```sh +brew install antfrog/tap/tgrep +``` -## Install +Homebrew downloads a prebuilt binary for Apple Silicon, Intel Macs, or Linux on ARM64 and x86_64. + +### Build from source -From a clone of this repository, install the binary into a directory on your `PATH`. +From a clone of this repository, use Go 1.23 or later and a C compiler to build and install the binary. ```sh GOBIN="$HOME/.local/bin" go install ./cmd/tgrep From a3a488d316319cf338af514907bf040a67858d91 Mon Sep 17 00:00:00 2001 From: jinil-ha Date: Mon, 30 Nov 2026 17:24:33 +0900 Subject: [PATCH 2/3] Prepare the UTF-8 locale on Linux release runners --- .github/workflows/release.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3bedd40..ad9a5ff 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,6 +12,7 @@ permissions: jobs: package: strategy: + fail-fast: false matrix: runner: [macos-15, macos-15-intel, ubuntu-22.04, ubuntu-22.04-arm] runs-on: ${{ matrix.runner }} @@ -28,7 +29,16 @@ jobs: - uses: actions/setup-go@v7 with: go-version: '1.27.x' + - name: Generate the UTF-8 locale used by the Vim integration test + if: runner.os == 'Linux' + run: sudo locale-gen en_US.UTF-8 - run: go test ./... + - name: Diagnose headless Vim errors + if: failure() && runner.os == 'Linux' + run: | + vim --version + sed -i 's/ -es --cmd/ -V1 -es --cmd/' cmd/tgrep/main_test.go + go test -v ./cmd/tgrep -run '^TestComparisonInVim$' - name: Build and package the native binary shell: bash run: | From fc87b759e31dd571981284a94e10bdd75b77acb7 Mon Sep 17 00:00:00 2001 From: jinil-ha Date: Mon, 30 Nov 2026 17:26:47 +0900 Subject: [PATCH 3/3] Use the Homebrew Linux baseline and document optional Vim support --- .github/workflows/release.yml | 11 +---------- README.jp.md | 2 +- README.kr.md | 2 +- README.md | 2 +- 4 files changed, 4 insertions(+), 13 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ad9a5ff..8e4a58c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false matrix: - runner: [macos-15, macos-15-intel, ubuntu-22.04, ubuntu-22.04-arm] + runner: [macos-15, macos-15-intel, ubuntu-24.04, ubuntu-24.04-arm] runs-on: ${{ matrix.runner }} env: CGO_ENABLED: '1' @@ -29,16 +29,7 @@ jobs: - uses: actions/setup-go@v7 with: go-version: '1.27.x' - - name: Generate the UTF-8 locale used by the Vim integration test - if: runner.os == 'Linux' - run: sudo locale-gen en_US.UTF-8 - run: go test ./... - - name: Diagnose headless Vim errors - if: failure() && runner.os == 'Linux' - run: | - vim --version - sed -i 's/ -es --cmd/ -V1 -es --cmd/' cmd/tgrep/main_test.go - go test -v ./cmd/tgrep -run '^TestComparisonInVim$' - name: Build and package the native binary shell: bash run: | diff --git a/README.jp.md b/README.jp.md index eadf6a7..f2d4d27 100644 --- a/README.jp.md +++ b/README.jp.md @@ -46,7 +46,7 @@ tgrep 'sign in' ## 左右に並べて比較する -検索結果で **`F1`** を押すと、左に原文、右に最初の翻訳が開きます。**`F2`** は 2 番目の翻訳を開きます。たとえば `TGREP_TARGET_LANGS=ko,ja` なら `F1` は韓国語、`F2` は日本語です。この操作には `PATH` 上の `vim` が必要です。 +検索結果で **`F1`** を押すと、左に原文、右に最初の翻訳が開きます。**`F2`** は 2 番目の翻訳を開きます。たとえば `TGREP_TARGET_LANGS=ko,ja` なら `F1` は韓国語、`F2` は日本語です。この操作には `WinScrolled` イベントに対応した `vim`(Vim 9 など)が `PATH` 上に必要です。 比較画面を開くと、原文と翻訳の両方で、最初に入力した検索パターンに一致する箇所が強調表示されます。 diff --git a/README.kr.md b/README.kr.md index fdbfdb6..793f4c8 100644 --- a/README.kr.md +++ b/README.kr.md @@ -46,7 +46,7 @@ tgrep 'sign in' ## 비교하기 -검색 결과에서 **`F1`**을 누르면 왼쪽에 원문, 오른쪽에 첫 번째 번역이 열립니다. **`F2`**는 두 번째 번역을 엽니다. 예를 들어 `TGREP_TARGET_LANGS=ko,ja`이면 `F1`은 한국어, `F2`는 일본어입니다. 이 단축키는 `vim`이 설치되어 있을 때 사용할 수 있습니다. +검색 결과에서 **`F1`**을 누르면 왼쪽에 원문, 오른쪽에 첫 번째 번역이 열립니다. **`F2`**는 두 번째 번역을 엽니다. 예를 들어 `TGREP_TARGET_LANGS=ko,ja`이면 `F1`은 한국어, `F2`는 일본어입니다. 이 단축키는 `PATH`에 있는 Vim의 `WinScrolled` 이벤트를 사용합니다. Vim 9에서 지원합니다. 비교 화면을 열면 원문과 번역에서 처음 입력한 검색 패턴에 일치하는 부분이 강조됩니다. diff --git a/README.md b/README.md index 4089794..9fe33e5 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ Search skips code blocks fenced with three or more backticks. Matches after a bl ## Compare side by side -Press **`F1`** on a result to open the source on the left and the first target language on the right. **`F2`** opens the second target language. With `TGREP_TARGET_LANGS=ko,ja`, `F1` opens Korean and `F2` opens Japanese. These shortcuts require `vim` on your `PATH`. +Press **`F1`** on a result to open the source on the left and the first target language on the right. **`F2`** opens the second target language. With `TGREP_TARGET_LANGS=ko,ja`, `F1` opens Korean and `F2` opens Japanese. These shortcuts use `vim` on your `PATH` and require its `WinScrolled` event (available in Vim 9). When the comparison opens, matching text is highlighted in both panes using the original search pattern.