-
Notifications
You must be signed in to change notification settings - Fork 1
256 lines (220 loc) · 8.1 KB
/
release.yml
File metadata and controls
256 lines (220 loc) · 8.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
name: GitHub Release
on:
push:
tags:
- "v*"
workflow_dispatch:
permissions:
contents: write
env:
BINARY_NAME: kbr
jobs:
build-linux-amd64:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Install OCR build dependencies
run: |
sudo apt-get update
sudo apt-get install -y pkg-config libtesseract-dev libleptonica-dev tesseract-ocr
- name: Build OCR binary
env:
CGO_ENABLED: "1"
GOOS: linux
GOARCH: amd64
run: |
mkdir -p dist/linux-amd64
go build -buildvcs=false -trimpath -tags=ocr \
-ldflags "-s -w \
-X github.com/libi/ko-browser/cmd.version=${{ github.ref_name }} \
-X github.com/libi/ko-browser/cmd.commit=${{ github.sha }} \
-X github.com/libi/ko-browser/cmd.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
-o dist/linux-amd64/${BINARY_NAME} ./cmd/kbr
- name: Package
run: |
tar czf ko-browser-linux-amd64.tar.gz -C dist/linux-amd64 ${BINARY_NAME}
- uses: actions/upload-artifact@v4
with:
name: ko-browser-linux-amd64
path: ko-browser-linux-amd64.tar.gz
build-linux-arm64:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Build OCR binary in ARM64 container
run: |
docker run --rm --platform linux/arm64 \
-v "${{ github.workspace }}:/workspace" \
-w /workspace \
golang:1.26-bookworm \
bash -c '
apt-get update &&
apt-get install -y pkg-config libtesseract-dev libleptonica-dev tesseract-ocr &&
mkdir -p dist/linux-arm64 &&
export CGO_ENABLED=1 GOOS=linux GOARCH=arm64 &&
go build -buildvcs=false -trimpath -tags=ocr \
-ldflags "-s -w \
-X github.com/libi/ko-browser/cmd.version=${{ github.ref_name }} \
-X github.com/libi/ko-browser/cmd.commit=${{ github.sha }} \
-X github.com/libi/ko-browser/cmd.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
-o dist/linux-arm64/kbr ./cmd/kbr &&
tar czf ko-browser-linux-arm64.tar.gz -C dist/linux-arm64 kbr
'
- uses: actions/upload-artifact@v4
with:
name: ko-browser-linux-arm64
path: ko-browser-linux-arm64.tar.gz
build-darwin-amd64:
runs-on: macos-15-intel
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Install OCR build dependencies
run: |
brew install tesseract leptonica pkg-config
- name: Configure OCR build environment
run: |
TESSERACT_PREFIX="$(brew --prefix tesseract)"
LEPTONICA_PREFIX="$(brew --prefix leptonica)"
{
echo "PKG_CONFIG_PATH=${TESSERACT_PREFIX}/lib/pkgconfig:${LEPTONICA_PREFIX}/lib/pkgconfig"
echo "CGO_CFLAGS=-I${TESSERACT_PREFIX}/include -I${LEPTONICA_PREFIX}/include"
echo "CGO_LDFLAGS=-L${TESSERACT_PREFIX}/lib -L${LEPTONICA_PREFIX}/lib"
echo "CPATH=${TESSERACT_PREFIX}/include:${LEPTONICA_PREFIX}/include"
echo "LIBRARY_PATH=${TESSERACT_PREFIX}/lib:${LEPTONICA_PREFIX}/lib"
} >> "${GITHUB_ENV}"
- name: Build OCR binary
env:
CGO_ENABLED: "1"
GOOS: darwin
GOARCH: amd64
run: |
mkdir -p dist/darwin-amd64
go build -buildvcs=false -trimpath -tags=ocr \
-ldflags "-s -w \
-X github.com/libi/ko-browser/cmd.version=${{ github.ref_name }} \
-X github.com/libi/ko-browser/cmd.commit=${{ github.sha }} \
-X github.com/libi/ko-browser/cmd.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
-o dist/darwin-amd64/${BINARY_NAME} ./cmd/kbr
- name: Package
run: |
tar czf ko-browser-darwin-amd64.tar.gz -C dist/darwin-amd64 ${BINARY_NAME}
- uses: actions/upload-artifact@v4
with:
name: ko-browser-darwin-amd64
path: ko-browser-darwin-amd64.tar.gz
build-darwin-arm64:
runs-on: macos-14
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Install OCR build dependencies
run: |
brew install tesseract leptonica pkg-config
- name: Configure OCR build environment
run: |
TESSERACT_PREFIX="$(brew --prefix tesseract)"
LEPTONICA_PREFIX="$(brew --prefix leptonica)"
{
echo "PKG_CONFIG_PATH=${TESSERACT_PREFIX}/lib/pkgconfig:${LEPTONICA_PREFIX}/lib/pkgconfig"
echo "CGO_CFLAGS=-I${TESSERACT_PREFIX}/include -I${LEPTONICA_PREFIX}/include"
echo "CGO_LDFLAGS=-L${TESSERACT_PREFIX}/lib -L${LEPTONICA_PREFIX}/lib"
echo "CPATH=${TESSERACT_PREFIX}/include:${LEPTONICA_PREFIX}/include"
echo "LIBRARY_PATH=${TESSERACT_PREFIX}/lib:${LEPTONICA_PREFIX}/lib"
} >> "${GITHUB_ENV}"
- name: Build OCR binary
env:
CGO_ENABLED: "1"
GOOS: darwin
GOARCH: arm64
run: |
mkdir -p dist/darwin-arm64
go build -buildvcs=false -trimpath -tags=ocr \
-ldflags "-s -w \
-X github.com/libi/ko-browser/cmd.version=${{ github.ref_name }} \
-X github.com/libi/ko-browser/cmd.commit=${{ github.sha }} \
-X github.com/libi/ko-browser/cmd.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
-o dist/darwin-arm64/${BINARY_NAME} ./cmd/kbr
- name: Package
run: |
tar czf ko-browser-darwin-arm64.tar.gz -C dist/darwin-arm64 ${BINARY_NAME}
- uses: actions/upload-artifact@v4
with:
name: ko-browser-darwin-arm64
path: ko-browser-darwin-arm64.tar.gz
build-windows-amd64:
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
path-type: inherit
update: true
install: >-
mingw-w64-x86_64-gcc
mingw-w64-x86_64-pkg-config
mingw-w64-x86_64-tesseract-ocr
mingw-w64-x86_64-leptonica
- name: Build OCR binary
run: |
mkdir -p dist/windows-amd64
export CGO_ENABLED=1
export GOOS=windows
export GOARCH=amd64
export CC=gcc
go build -buildvcs=false -trimpath -tags=ocr \
-ldflags "-s -w \
-X github.com/libi/ko-browser/cmd.version=${{ github.ref_name }} \
-X github.com/libi/ko-browser/cmd.commit=${{ github.sha }} \
-X github.com/libi/ko-browser/cmd.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
-o dist/windows-amd64/${BINARY_NAME}.exe ./cmd/kbr
- name: Package
shell: pwsh
run: |
Compress-Archive -Path "dist/windows-amd64/${{ env.BINARY_NAME }}.exe" -DestinationPath "ko-browser-windows-amd64.zip"
- uses: actions/upload-artifact@v4
with:
name: ko-browser-windows-amd64
path: ko-browser-windows-amd64.zip
release:
needs:
- build-linux-amd64
- build-linux-arm64
- build-darwin-amd64
- build-darwin-arm64
- build-windows-amd64
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Generate checksums
run: |
cd artifacts
sha256sum *.tar.gz *.zip > checksums.txt
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: |
artifacts/*.tar.gz
artifacts/*.zip
artifacts/checksums.txt