Skip to content

Commit bc7026f

Browse files
committed
fix tab list/ update ci yaml
1 parent 5f31f75 commit bc7026f

8 files changed

Lines changed: 1179 additions & 373 deletions

File tree

.github/workflows/brew.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Homebrew Tap
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
brew:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
18+
- name: Update Homebrew tap formula
19+
env:
20+
TAG: ${{ github.ref_name }}
21+
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
22+
run: |
23+
curl -fsSL -o /tmp/ko-browser-src.tar.gz "https://github.com/libi/ko-browser/archive/refs/tags/${TAG}.tar.gz"
24+
SHA256=$(shasum -a 256 /tmp/ko-browser-src.tar.gz | awk '{print $1}')
25+
26+
git clone "https://x-access-token:${HOMEBREW_TAP_GITHUB_TOKEN}@github.com/libi/homebrew-tap.git" /tmp/homebrew-tap
27+
mkdir -p /tmp/homebrew-tap/Formula
28+
29+
./scripts/render-homebrew-formula.sh "${TAG}" "${SHA256}" > /tmp/homebrew-tap/Formula/ko-browser.rb
30+
31+
cd /tmp/homebrew-tap
32+
git config user.name "github-actions[bot]"
33+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
34+
git add Formula/ko-browser.rb
35+
git commit -m "brew: update ko-browser to ${TAG}" || exit 0
36+
git push

.github/workflows/release.yml

Lines changed: 67 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
name: Release
1+
name: GitHub Release
22

33
on:
44
push:
5-
tags: ["v*"]
5+
tags:
6+
- "v*"
7+
workflow_dispatch:
68

79
permissions:
810
contents: write
911

1012
env:
11-
BINARY_NAME: ko-browser
13+
BINARY_NAME: kbr
1214

1315
jobs:
14-
# ---------------------------------------------------------------------------
15-
# Linux amd64 — native build on Ubuntu runner
16-
# ---------------------------------------------------------------------------
1716
build-linux-amd64:
1817
runs-on: ubuntu-latest
1918
steps:
@@ -23,35 +22,34 @@ jobs:
2322
with:
2423
go-version-file: go.mod
2524

26-
- name: Install Tesseract OCR dev libraries
25+
- name: Install OCR build dependencies
2726
run: |
2827
sudo apt-get update
29-
sudo apt-get install -y libtesseract-dev libleptonica-dev tesseract-ocr
28+
sudo apt-get install -y pkg-config libtesseract-dev libleptonica-dev tesseract-ocr
3029
31-
- name: Build
30+
- name: Build OCR binary
3231
env:
3332
CGO_ENABLED: "1"
3433
GOOS: linux
3534
GOARCH: amd64
3635
run: |
37-
go build -trimpath \
36+
mkdir -p dist/linux-amd64
37+
go build -trimpath -tags=ocr \
3838
-ldflags "-s -w \
3939
-X github.com/libi/ko-browser/cmd.version=${{ github.ref_name }} \
4040
-X github.com/libi/ko-browser/cmd.commit=${{ github.sha }} \
4141
-X github.com/libi/ko-browser/cmd.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
42-
-o ${BINARY_NAME}-linux-amd64 .
42+
-o dist/linux-amd64/${BINARY_NAME} ./cmd/kbr
4343
4444
- name: Package
45-
run: tar czf ${BINARY_NAME}-linux-amd64.tar.gz ${BINARY_NAME}-linux-amd64
45+
run: |
46+
tar czf ko-browser-linux-amd64.tar.gz -C dist/linux-amd64 ${BINARY_NAME}
4647
4748
- uses: actions/upload-artifact@v4
4849
with:
49-
name: ${{ env.BINARY_NAME }}-linux-amd64
50-
path: ${{ env.BINARY_NAME }}-linux-amd64.tar.gz
50+
name: ko-browser-linux-amd64
51+
path: ko-browser-linux-amd64.tar.gz
5152

52-
# ---------------------------------------------------------------------------
53-
# Linux arm64 — build inside Docker with QEMU emulation
54-
# ---------------------------------------------------------------------------
5553
build-linux-arm64:
5654
runs-on: ubuntu-latest
5755
steps:
@@ -61,35 +59,31 @@ jobs:
6159
with:
6260
platforms: arm64
6361

64-
- name: Build in ARM64 container
62+
- name: Build OCR binary in ARM64 container
6563
run: |
6664
docker run --rm --platform linux/arm64 \
6765
-v "${{ github.workspace }}:/workspace" \
6866
-w /workspace \
69-
-e CGO_ENABLED=1 \
7067
golang:1.26-bookworm \
71-
bash -c "
72-
apt-get update && \
73-
apt-get install -y libtesseract-dev libleptonica-dev && \
74-
go build -trimpath \
75-
-ldflags \"-s -w \
68+
bash -lc '
69+
apt-get update &&
70+
apt-get install -y pkg-config libtesseract-dev libleptonica-dev tesseract-ocr &&
71+
mkdir -p dist/linux-arm64 &&
72+
export CGO_ENABLED=1 GOOS=linux GOARCH=arm64 &&
73+
go build -trimpath -tags=ocr \
74+
-ldflags "-s -w \
7675
-X github.com/libi/ko-browser/cmd.version=${{ github.ref_name }} \
7776
-X github.com/libi/ko-browser/cmd.commit=${{ github.sha }} \
78-
-X github.com/libi/ko-browser/cmd.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)\" \
79-
-o ko-browser-linux-arm64 .
80-
"
81-
82-
- name: Package
83-
run: tar czf ${BINARY_NAME}-linux-arm64.tar.gz ${BINARY_NAME}-linux-arm64
77+
-X github.com/libi/ko-browser/cmd.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
78+
-o dist/linux-arm64/kbr ./cmd/kbr &&
79+
tar czf ko-browser-linux-arm64.tar.gz -C dist/linux-arm64 kbr
80+
'
8481
8582
- uses: actions/upload-artifact@v4
8683
with:
87-
name: ${{ env.BINARY_NAME }}-linux-arm64
88-
path: ${{ env.BINARY_NAME }}-linux-arm64.tar.gz
84+
name: ko-browser-linux-arm64
85+
path: ko-browser-linux-arm64.tar.gz
8986

90-
# ---------------------------------------------------------------------------
91-
# macOS amd64 — Intel runner
92-
# ---------------------------------------------------------------------------
9387
build-darwin-amd64:
9488
runs-on: macos-13
9589
steps:
@@ -99,33 +93,33 @@ jobs:
9993
with:
10094
go-version-file: go.mod
10195

102-
- name: Install Tesseract OCR
103-
run: brew install tesseract
96+
- name: Install OCR build dependencies
97+
run: |
98+
brew install tesseract pkg-config
10499
105-
- name: Build
100+
- name: Build OCR binary
106101
env:
107102
CGO_ENABLED: "1"
108103
GOOS: darwin
109104
GOARCH: amd64
110105
run: |
111-
go build -trimpath \
106+
mkdir -p dist/darwin-amd64
107+
go build -trimpath -tags=ocr \
112108
-ldflags "-s -w \
113109
-X github.com/libi/ko-browser/cmd.version=${{ github.ref_name }} \
114110
-X github.com/libi/ko-browser/cmd.commit=${{ github.sha }} \
115111
-X github.com/libi/ko-browser/cmd.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
116-
-o ${BINARY_NAME}-darwin-amd64 .
112+
-o dist/darwin-amd64/${BINARY_NAME} ./cmd/kbr
117113
118114
- name: Package
119-
run: tar czf ${BINARY_NAME}-darwin-amd64.tar.gz ${BINARY_NAME}-darwin-amd64
115+
run: |
116+
tar czf ko-browser-darwin-amd64.tar.gz -C dist/darwin-amd64 ${BINARY_NAME}
120117
121118
- uses: actions/upload-artifact@v4
122119
with:
123-
name: ${{ env.BINARY_NAME }}-darwin-amd64
124-
path: ${{ env.BINARY_NAME }}-darwin-amd64.tar.gz
120+
name: ko-browser-darwin-amd64
121+
path: ko-browser-darwin-amd64.tar.gz
125122

126-
# ---------------------------------------------------------------------------
127-
# macOS arm64 — Apple Silicon runner
128-
# ---------------------------------------------------------------------------
129123
build-darwin-arm64:
130124
runs-on: macos-14
131125
steps:
@@ -135,33 +129,33 @@ jobs:
135129
with:
136130
go-version-file: go.mod
137131

138-
- name: Install Tesseract OCR
139-
run: brew install tesseract
132+
- name: Install OCR build dependencies
133+
run: |
134+
brew install tesseract pkg-config
140135
141-
- name: Build
136+
- name: Build OCR binary
142137
env:
143138
CGO_ENABLED: "1"
144139
GOOS: darwin
145140
GOARCH: arm64
146141
run: |
147-
go build -trimpath \
142+
mkdir -p dist/darwin-arm64
143+
go build -trimpath -tags=ocr \
148144
-ldflags "-s -w \
149145
-X github.com/libi/ko-browser/cmd.version=${{ github.ref_name }} \
150146
-X github.com/libi/ko-browser/cmd.commit=${{ github.sha }} \
151147
-X github.com/libi/ko-browser/cmd.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
152-
-o ${BINARY_NAME}-darwin-arm64 .
148+
-o dist/darwin-arm64/${BINARY_NAME} ./cmd/kbr
153149
154150
- name: Package
155-
run: tar czf ${BINARY_NAME}-darwin-arm64.tar.gz ${BINARY_NAME}-darwin-arm64
151+
run: |
152+
tar czf ko-browser-darwin-arm64.tar.gz -C dist/darwin-arm64 ${BINARY_NAME}
156153
157154
- uses: actions/upload-artifact@v4
158155
with:
159-
name: ${{ env.BINARY_NAME }}-darwin-arm64
160-
path: ${{ env.BINARY_NAME }}-darwin-arm64.tar.gz
156+
name: ko-browser-darwin-arm64
157+
path: ko-browser-darwin-arm64.tar.gz
161158

162-
# ---------------------------------------------------------------------------
163-
# Windows amd64 — MSYS2 + MinGW for CGO/Tesseract
164-
# ---------------------------------------------------------------------------
165159
build-windows-amd64:
166160
runs-on: windows-latest
167161
defaults:
@@ -171,7 +165,6 @@ jobs:
171165
- uses: actions/checkout@v4
172166

173167
- uses: actions/setup-go@v5
174-
id: setup-go
175168
with:
176169
go-version-file: go.mod
177170

@@ -186,29 +179,30 @@ jobs:
186179
mingw-w64-x86_64-tesseract-ocr
187180
mingw-w64-x86_64-leptonica
188181
189-
- name: Build
182+
- name: Build OCR binary
190183
run: |
184+
mkdir -p dist/windows-amd64
191185
export CGO_ENABLED=1
186+
export GOOS=windows
187+
export GOARCH=amd64
192188
export CC=gcc
193-
go build -trimpath \
189+
go build -trimpath -tags=ocr \
194190
-ldflags "-s -w \
195191
-X github.com/libi/ko-browser/cmd.version=${{ github.ref_name }} \
196192
-X github.com/libi/ko-browser/cmd.commit=${{ github.sha }} \
197193
-X github.com/libi/ko-browser/cmd.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
198-
-o ${BINARY_NAME}-windows-amd64.exe .
194+
-o dist/windows-amd64/${BINARY_NAME}.exe ./cmd/kbr
199195
200196
- name: Package
201197
shell: pwsh
202-
run: Compress-Archive -Path "${{ env.BINARY_NAME }}-windows-amd64.exe" -DestinationPath "${{ env.BINARY_NAME }}-windows-amd64.zip"
198+
run: |
199+
Compress-Archive -Path "dist/windows-amd64/${{ env.BINARY_NAME }}.exe" -DestinationPath "ko-browser-windows-amd64.zip"
203200
204201
- uses: actions/upload-artifact@v4
205202
with:
206-
name: ${{ env.BINARY_NAME }}-windows-amd64
207-
path: ${{ env.BINARY_NAME }}-windows-amd64.zip
203+
name: ko-browser-windows-amd64
204+
path: ko-browser-windows-amd64.zip
208205

209-
# ---------------------------------------------------------------------------
210-
# Create GitHub Release with all artifacts
211-
# ---------------------------------------------------------------------------
212206
release:
213207
needs:
214208
- build-linux-amd64
@@ -218,20 +212,21 @@ jobs:
218212
- build-windows-amd64
219213
runs-on: ubuntu-latest
220214
steps:
221-
- uses: actions/checkout@v4
222-
223215
- uses: actions/download-artifact@v4
224216
with:
225217
path: artifacts
226218
merge-multiple: true
227219

228-
- name: List artifacts
229-
run: ls -lR artifacts/
220+
- name: Generate checksums
221+
run: |
222+
cd artifacts
223+
sha256sum *.tar.gz *.zip > checksums.txt
230224
231-
- name: Create Release
225+
- name: Create GitHub release
232226
uses: softprops/action-gh-release@v2
233227
with:
234228
generate_release_notes: true
235229
files: |
236230
artifacts/*.tar.gz
237231
artifacts/*.zip
232+
artifacts/checksums.txt

README-CN.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,39 +25,48 @@
2525

2626
## 📦 安装
2727

28+
### Homebrew
29+
30+
```bash
31+
brew tap libi/tap
32+
brew install ko-browser
33+
```
34+
35+
> Homebrew 安装的是带 OCR 的 `kbr`
36+
> 它会自动安装 `tesseract`,并通过源码编译。
37+
2838
### 预编译二进制
2939

3040
[GitHub Releases](https://github.com/libi/ko-browser/releases) 下载:
3141

42+
> GitHub Release 提供的二进制同样是带 OCR 的版本。
43+
> 使用前请先安装 Tesseract 运行时库:macOS 用 `brew install tesseract`,Linux 用 `apt install libtesseract-dev`
44+
3245
```bash
3346
# macOS (Apple Silicon)
3447
curl -LO https://github.com/libi/ko-browser/releases/latest/download/ko-browser-darwin-arm64.tar.gz
3548
tar xzf ko-browser-darwin-arm64.tar.gz
36-
mv ko-browser-darwin-arm64 /usr/local/bin/kbr
49+
mv kbr /usr/local/bin/kbr
3750

3851
# macOS (Intel)
3952
curl -LO https://github.com/libi/ko-browser/releases/latest/download/ko-browser-darwin-amd64.tar.gz
4053
tar xzf ko-browser-darwin-amd64.tar.gz
41-
mv ko-browser-darwin-amd64 /usr/local/bin/kbr
54+
mv kbr /usr/local/bin/kbr
4255

4356
# Linux (amd64)
4457
curl -LO https://github.com/libi/ko-browser/releases/latest/download/ko-browser-linux-amd64.tar.gz
4558
tar xzf ko-browser-linux-amd64.tar.gz
46-
mv ko-browser-linux-amd64 /usr/local/bin/kbr
59+
mv kbr /usr/local/bin/kbr
4760
```
4861

4962
### 源码编译
5063

5164
```bash
52-
# 安装 kbr 二进制(无 CGO 依赖,无需 Tesseract)
53-
go install github.com/libi/ko-browser/cmd/kbr@latest
54-
55-
# 带 OCR 支持(需要先安装 Tesseract)
65+
# 安装带 OCR 支持的 kbr(需要先安装 Tesseract)
5666
CGO_ENABLED=1 go install -tags=ocr github.com/libi/ko-browser/cmd/kbr@latest
5767
```
5868

59-
> **OCR 是可选功能。** 默认编译零 CGO 依赖,开箱即用。
60-
> 仅在需要 `kbr snapshot --ocr` 处理图片密集页面时才需要 `-tags=ocr`
69+
> 发布出去的安装方式统一使用 OCR 版本。
6170
> OCR 依赖 Tesseract:`brew install tesseract`(macOS)/ `apt install libtesseract-dev`(Linux)。
6271
6372
### 安装浏览器

0 commit comments

Comments
 (0)