-
Notifications
You must be signed in to change notification settings - Fork 0
296 lines (257 loc) · 9.77 KB
/
Copy pathrelease.yml
File metadata and controls
296 lines (257 loc) · 9.77 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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
version:
description: 'Release version'
required: false
permissions:
contents: write
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-apple-darwin
os: macos-latest
suffix: darwin-x64
goos: darwin
goarch: amd64
fzf_url: https://github.com/junegunn/fzf/releases/download/v0.73.1/fzf-0.73.1-darwin_amd64.tar.gz
rg_url: https://github.com/BurntSushi/ripgrep/releases/download/15.1.0/ripgrep-15.1.0-x86_64-apple-darwin.tar.gz
- target: aarch64-apple-darwin
os: macos-latest
suffix: darwin-arm64
goos: darwin
goarch: arm64
fzf_url: https://github.com/junegunn/fzf/releases/download/v0.73.1/fzf-0.73.1-darwin_arm64.tar.gz
rg_url: https://github.com/BurntSushi/ripgrep/releases/download/15.1.0/ripgrep-15.1.0-aarch64-apple-darwin.tar.gz
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
suffix: linux-x64
goos: linux
goarch: amd64
fzf_url: https://github.com/junegunn/fzf/releases/download/v0.73.1/fzf-0.73.1-linux_amd64.tar.gz
rg_url: https://github.com/BurntSushi/ripgrep/releases/download/15.1.0/ripgrep-15.1.0-x86_64-unknown-linux-musl.tar.gz
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Rust
uses: dtolnay/rust-toolchain@1.95
with:
targets: ${{ matrix.target }}
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
workspaces: "codeseek/rust-core"
key: ${{ matrix.target }}
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
cache: true
- name: Install protoc
uses: arduino/setup-protoc@v3
with:
version: "25.x"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build Rust codeseek (${{ matrix.target }})
working-directory: codeseek/rust-core
run: cargo build --release --target ${{ matrix.target }}
env:
CC_x86_64_apple_darwin: clang -arch x86_64
MACOSX_DEPLOYMENT_TARGET: "10.15"
- name: Prepare embedded binaries
run: |
set -euo pipefail
mkdir -p dist/bin
# Copy codeseek built from Rust
cp codeseek/rust-core/target/${{ matrix.target }}/release/codeseek dist/bin/
# Download and extract fzf
echo "Downloading fzf from ${{ matrix.fzf_url }}"
curl -fLo /tmp/fzf.tar.gz "${{ matrix.fzf_url }}"
tar -xzf /tmp/fzf.tar.gz -C /tmp
mv /tmp/fzf dist/bin/fzf
rm -f /tmp/fzf.tar.gz
# Download and extract rg (rg 在 tar 中有目录前缀,用 find 定位)
echo "Downloading rg from ${{ matrix.rg_url }}"
curl -fLo /tmp/rg.tar.gz "${{ matrix.rg_url }}"
mkdir -p /tmp/rg_extract
tar -xzf /tmp/rg.tar.gz -C /tmp/rg_extract
find /tmp/rg_extract -name rg -type f -exec mv {} dist/bin/rg \;
rm -rf /tmp/rg_extract /tmp/rg.tar.gz
# Set executable permissions
chmod +x dist/bin/codeseek dist/bin/fzf dist/bin/rg
# Verify
ls -la dist/bin/
echo "✓ Embedded binaries ready: codeseek, fzf, rg"
- name: Build Go codeactor (${{ matrix.suffix }})
run: |
go build \
-ldflags="-s -w -X 'codeactor/internal/globalctx.Version=${{ github.ref_name }}' -X 'codeactor/internal/globalctx.BuildTime=$(date -u +%Y-%m-%dT%H:%M:%SZ)' -X 'codeactor/internal/globalctx.GitCommit=${{ github.sha }}'" \
-o codeactor \
.
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: "0"
- name: Verify artifact
run: |
file codeactor
echo "---"
ls -lh codeactor
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: codeactor-${{ matrix.suffix }}
path: codeactor
if-no-files-found: error
centos7-build:
name: Build linux-x64 (musl static)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install musl tools and build deps
run: |
sudo apt-get update
sudo apt-get install -y musl-tools perl make pkg-config
- name: Setup Rust
uses: dtolnay/rust-toolchain@1.95
with:
targets: x86_64-unknown-linux-musl
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
workspaces: "codeseek/rust-core"
key: musl-v2
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
cache: true
- name: Install protoc
uses: arduino/setup-protoc@v3
with:
version: "25.x"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Apply vendored OpenSSL patch for musl build
working-directory: codeseek
run: git apply --verbose ../patches/codeseek-vendored-openssl.patch
- name: Build Rust codeseek (static musl)
working-directory: codeseek/rust-core
run: |
cargo build --release --target x86_64-unknown-linux-musl
env:
# Cross-compilation toolchain
CC_x86_64_unknown_linux_musl: musl-gcc
CXX_x86_64_unknown_linux_musl: musl-g++
AR_x86_64_unknown_linux_musl: ar
CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER: musl-gcc
# OpenSSL configuration for vendored static build
OPENSSL_STATIC: "1"
# Allow cross-compilation pkg-config (safety net)
PKG_CONFIG_ALLOW_CROSS: "1"
- name: Prepare embedded binaries
run: |
set -euo pipefail
mkdir -p dist/bin
# Copy codeseek (musl static)
cp codeseek/rust-core/target/x86_64-unknown-linux-musl/release/codeseek dist/bin/
# Download fzf
echo "Downloading fzf..."
curl -fLo /tmp/fzf.tar.gz "https://github.com/junegunn/fzf/releases/download/v0.73.1/fzf-0.73.1-linux_amd64.tar.gz"
tar -xzf /tmp/fzf.tar.gz -C /tmp
mv /tmp/fzf dist/bin/fzf
rm -f /tmp/fzf.tar.gz
# Download ripgrep (musl build for static linking)
echo "Downloading ripgrep..."
curl -fLo /tmp/rg.tar.gz "https://github.com/BurntSushi/ripgrep/releases/download/15.1.0/ripgrep-15.1.0-x86_64-unknown-linux-musl.tar.gz"
mkdir -p /tmp/rg_extract
tar -xzf /tmp/rg.tar.gz -C /tmp/rg_extract
find /tmp/rg_extract -name rg -type f -exec mv {} dist/bin/rg \;
rm -rf /tmp/rg_extract /tmp/rg.tar.gz
chmod +x dist/bin/codeseek dist/bin/fzf dist/bin/rg
ls -la dist/bin/
echo "✓ Embedded binaries ready: codeseek, fzf, rg"
- name: Build Go codeactor (linux-x64-musl)
run: |
go build \
-ldflags="-s -w -X 'codeactor/internal/globalctx.Version=${{ github.ref_name }}' -X 'codeactor/internal/globalctx.BuildTime=$(date -u +%Y-%m-%dT%H:%M:%SZ)' -X 'codeactor/internal/globalctx.GitCommit=${{ github.sha }}'" \
-o codeactor \
.
env:
GOOS: linux
GOARCH: amd64
CGO_ENABLED: "0"
- name: Verify static linking
run: |
echo "=== Verifying static linking ==="
file dist/bin/codeseek
echo ""
echo "=== Checking for dynamic symbols ==="
if command -v readelf &> /dev/null; then
readelf -d dist/bin/codeseek 2>&1 | head -20 || echo "(no dynamic section = fully static)"
fi
if command -v ldd &> /dev/null; then
ldd dist/bin/codeseek 2>&1 | head -10 || true
fi
- name: Verify artifact
run: |
file codeactor
echo "---"
ls -lh codeactor
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: codeactor-linux-x64-musl
path: codeactor
if-no-files-found: error
create-release:
name: Create Release
needs: [build, centos7-build]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Package release assets
run: |
set -euo pipefail
echo "=== Artifacts structure ==="
find artifacts -type f -exec ls -lh {} \;
echo ""
echo "=== Packaging release assets ==="
for dir in artifacts/*/; do
name="$(basename "$dir")"
cd "artifacts/$name"
chmod +x codeactor
tar -czf "${name}.tar.gz" codeactor
cd ../..
echo "Created artifacts/${name}/${name}.tar.gz"
done
echo ""
echo "=== Release assets ==="
find artifacts -type f -name "*.tar.gz" -exec ls -lh {} \;
- name: Upload Release Assets
uses: softprops/action-gh-release@v2
with:
files: |
artifacts/codeactor-darwin-x64/codeactor-darwin-x64.tar.gz
artifacts/codeactor-darwin-arm64/codeactor-darwin-arm64.tar.gz
artifacts/codeactor-linux-x64/codeactor-linux-x64.tar.gz
artifacts/codeactor-linux-x64-musl/codeactor-linux-x64-musl.tar.gz
generate_release_notes: true
fail_on_unmatched_files: true