Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
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:
fail-fast: false
matrix:
runner: [macos-15, macos-15-intel, ubuntu-24.04, ubuntu-24.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
16 changes: 10 additions & 6 deletions README.jp.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -42,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` 上に必要です。

比較画面を開くと、原文と翻訳の両方で、最初に入力した検索パターンに一致する箇所が強調表示されます。

Expand Down
16 changes: 10 additions & 6 deletions README.kr.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -42,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에서 지원합니다.

비교 화면을 열면 원문과 번역에서 처음 입력한 검색 패턴에 일치하는 부분이 강조됩니다.

Expand Down
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -42,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.

Expand Down
Loading