-
Notifications
You must be signed in to change notification settings - Fork 0
369 lines (322 loc) · 13 KB
/
Copy pathrelease.yml
File metadata and controls
369 lines (322 loc) · 13 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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
name: Release
# Release pipeline on GitHub-hosted runners. On every `v*` tag push we:
#
# 1. build-amd64 / build-arm64 (parallel) — compile on native GitHub-hosted runners
# (ubuntu-latest + ubuntu-24.04-arm). Each job uploads its per-arch staging
# tree as a workflow artifact. arm64 is not emulated under QEMU.
# 2. publish-image / publish-proxy-image (parallel after build) — assemble the
# multi-arch Docker images from those prebuilt binaries (Dockerfile.runtime
# and Dockerfile.proxy-runtime do no compilation), push both to GHCR.
# 3. publish-release — package tarballs, standalone CLI binaries, and create the
# GitHub Release.
#
# Compilation caches use GitHub Actions cache (sccache + Swatinem/rust-cache) instead
# of the self-hosted runner hostPath used by CI.
on:
push:
tags: ["v*"]
workflow_dispatch:
permissions:
contents: write # GitHub Release upload
packages: write # GHCR image push
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-D warnings"
RUSTC_WRAPPER: sccache
SCCACHE_DIR: ${{ github.workspace }}/.cache/sccache
SCCACHE_CACHE_SIZE: 10G
CHDB_RUST_REPO: https://github.com/hyperbyte-cloud/chdb-rust.git
CHDB_RUST_REF: feat_arrow_insert
REGISTRY: ghcr.io
IMAGE_NAME: hyperbyte-cloud/hyperbytedb
PROXY_IMAGE_NAME: hyperbyte-cloud/hyperbytedb-proxy
jobs:
build-amd64:
name: Build linux/amd64
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout chdb-rust
run: bash .github/scripts/checkout-chdb-rust.sh
- name: Restore sccache
uses: actions/cache@v4
with:
path: ${{ env.SCCACHE_DIR }}
key: sccache-release-amd64-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
sccache-release-amd64-
- uses: Swatinem/rust-cache@v2
with:
shared-key: release-amd64
- name: Compile release binaries
run: |
rm -rf release-staging/amd64
bash .github/scripts/run-in-rust-container.sh \
'bash .github/scripts/rust-container-setup.sh && \
sccache --zero-stats && \
cargo build --release --locked -p hyperbytedb --bin hyperbytedb -p hyperbytedb-cli --bin hyperbytedb-cli -p hyperbytedb-proxy --bin hyperbytedb-proxy && \
sccache --show-stats && \
mkdir -p release-staging/amd64 && \
cp target/release/hyperbytedb target/release/hyperbytedb-cli target/release/hyperbytedb-proxy /usr/local/lib/libchdb.so release-staging/amd64/'
- name: Upload amd64 staging artifact
uses: actions/upload-artifact@v4
with:
name: release-staging-amd64
path: release-staging/amd64/
if-no-files-found: error
build-arm64:
name: Build linux/arm64
runs-on: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v4
- name: Checkout chdb-rust
run: bash .github/scripts/checkout-chdb-rust.sh
- name: Restore sccache
uses: actions/cache@v4
with:
path: ${{ env.SCCACHE_DIR }}
key: sccache-release-arm64-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
sccache-release-arm64-
- uses: Swatinem/rust-cache@v2
with:
shared-key: release-arm64
- name: Compile release binaries
run: |
rm -rf release-staging/arm64
bash .github/scripts/run-in-rust-container.sh \
'bash .github/scripts/rust-container-setup.sh && \
sccache --zero-stats && \
cargo build --release --locked -p hyperbytedb --bin hyperbytedb -p hyperbytedb-cli --bin hyperbytedb-cli -p hyperbytedb-proxy --bin hyperbytedb-proxy && \
sccache --show-stats && \
mkdir -p release-staging/arm64 && \
cp target/release/hyperbytedb target/release/hyperbytedb-cli target/release/hyperbytedb-proxy /usr/local/lib/libchdb.so release-staging/arm64/'
- name: Upload arm64 staging artifact
uses: actions/upload-artifact@v4
with:
name: release-staging-arm64
path: release-staging/arm64/
if-no-files-found: error
publish-image:
name: Publish container image
runs-on: ubuntu-latest
needs: [build-amd64, build-arm64]
steps:
- uses: actions/checkout@v4
- name: Download prebuilt binaries
uses: actions/download-artifact@v4
with:
name: release-staging-amd64
path: release-staging/amd64
- uses: actions/download-artifact@v4
with:
name: release-staging-arm64
path: release-staging/arm64
- name: Verify staging layout
run: |
set -euo pipefail
for arch in amd64 arm64; do
chmod +x "release-staging/${arch}/hyperbytedb" "release-staging/${arch}/hyperbytedb-cli"
test -f "release-staging/${arch}/hyperbytedb"
test -f "release-staging/${arch}/hyperbytedb-cli"
test -f "release-staging/${arch}/hyperbytedb-proxy"
test -s "release-staging/${arch}/libchdb.so"
done
ls -lh release-staging/*/*
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry (PAT)
if: vars.GHCR_AUTH == 'pat'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.GHCR_PAT }}
- name: Log in to GitHub Container Registry (GITHUB_TOKEN)
if: vars.GHCR_AUTH != 'pat'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,prefix=
type=raw,value=latest,enable=${{ github.ref_type == 'tag' }}
- name: Build and push multi-arch image
uses: docker/build-push-action@v6
with:
context: release-staging
file: Dockerfile.runtime
platforms: linux/amd64,linux/arm64
push: true
provenance: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
publish-proxy-image:
name: Publish proxy container image
runs-on: ubuntu-latest
needs: [build-amd64, build-arm64]
steps:
- uses: actions/checkout@v4
- name: Download prebuilt binaries
uses: actions/download-artifact@v4
with:
name: release-staging-amd64
path: release-staging/amd64
- uses: actions/download-artifact@v4
with:
name: release-staging-arm64
path: release-staging/arm64
- name: Verify proxy binary
run: |
set -euo pipefail
for arch in amd64 arm64; do
chmod +x "release-staging/${arch}/hyperbytedb-proxy"
test -f "release-staging/${arch}/hyperbytedb-proxy"
done
ls -lh release-staging/*/hyperbytedb-proxy
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry (PAT)
if: vars.GHCR_AUTH == 'pat'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.GHCR_PAT }}
- name: Log in to GitHub Container Registry (GITHUB_TOKEN)
if: vars.GHCR_AUTH != 'pat'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.PROXY_IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,prefix=
type=raw,value=latest,enable=${{ github.ref_type == 'tag' }}
- name: Build and push multi-arch proxy image
uses: docker/build-push-action@v6
with:
context: release-staging
file: Dockerfile.proxy-runtime
platforms: linux/amd64,linux/arm64
push: true
provenance: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
publish-release:
name: Publish GitHub Release
runs-on: ubuntu-latest
needs: [build-amd64, build-arm64, publish-image, publish-proxy-image]
if: github.ref_type == 'tag'
steps:
- name: Download prebuilt binaries
uses: actions/download-artifact@v4
with:
name: release-staging-amd64
path: release-staging/amd64
- uses: actions/download-artifact@v4
with:
name: release-staging-arm64
path: release-staging/arm64
- name: Package release tarballs
env:
TAG: ${{ github.ref_name }}
run: |
set -euo pipefail
for arch in amd64 arm64; do
chmod +x "release-staging/${arch}/hyperbytedb" \
"release-staging/${arch}/hyperbytedb-cli" \
"release-staging/${arch}/hyperbytedb-proxy"
done
mkdir -p out
declare -A ARCHES=( [amd64]=x86_64 [arm64]=aarch64 )
for src in "${!ARCHES[@]}"; do
dst="${ARCHES[$src]}"
NAME="hyperbytedb-${TAG}-linux-${dst}"
tar -C "release-staging/${src}" -czf "out/${NAME}.tar.gz" \
hyperbytedb hyperbytedb-cli hyperbytedb-proxy libchdb.so
( cd out && sha256sum "${NAME}.tar.gz" > "${NAME}.tar.gz.sha256" )
ls -lh "out/${NAME}.tar.gz" "out/${NAME}.tar.gz.sha256"
CLI_NAME="hyperbytedb-cli-${TAG}-linux-${dst}"
cp "release-staging/${src}/hyperbytedb-cli" "out/${CLI_NAME}"
gzip -f "out/${CLI_NAME}"
( cd out && sha256sum "${CLI_NAME}.gz" > "${CLI_NAME}.gz.sha256" )
ls -lh "out/${CLI_NAME}.gz" "out/${CLI_NAME}.gz.sha256"
PROXY_NAME="hyperbytedb-proxy-${TAG}-linux-${dst}"
cp "release-staging/${src}/hyperbytedb-proxy" "out/${PROXY_NAME}"
gzip -f "out/${PROXY_NAME}"
( cd out && sha256sum "${PROXY_NAME}.gz" > "${PROXY_NAME}.gz.sha256" )
ls -lh "out/${PROXY_NAME}.gz" "out/${PROXY_NAME}.gz.sha256"
done
- name: Verify release artifacts
env:
TAG: ${{ github.ref_name }}
run: |
set -euo pipefail
for arch in x86_64 aarch64; do
tarball="out/hyperbytedb-${TAG}-linux-${arch}.tar.gz"
test -s "${tarball}"
test -s "out/hyperbytedb-${TAG}-linux-${arch}.tar.gz.sha256"
listing="$(tar -tzf "${tarball}")"
for entry in hyperbytedb hyperbytedb-cli hyperbytedb-proxy libchdb.so; do
grep -qx "${entry}" <<<"${listing}"
done
cli="out/hyperbytedb-cli-${TAG}-linux-${arch}.gz"
test -s "${cli}"
test -s "${cli}.sha256"
proxy="out/hyperbytedb-proxy-${TAG}-linux-${arch}.gz"
test -s "${proxy}"
test -s "${proxy}.sha256"
done
ls -lh out/
- name: Create / update GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
generate_release_notes: true
fail_on_unmatched_files: true
files: |
out/hyperbytedb-${{ github.ref_name }}-linux-x86_64.tar.gz
out/hyperbytedb-${{ github.ref_name }}-linux-x86_64.tar.gz.sha256
out/hyperbytedb-${{ github.ref_name }}-linux-aarch64.tar.gz
out/hyperbytedb-${{ github.ref_name }}-linux-aarch64.tar.gz.sha256
out/hyperbytedb-cli-${{ github.ref_name }}-linux-x86_64.gz
out/hyperbytedb-cli-${{ github.ref_name }}-linux-x86_64.gz.sha256
out/hyperbytedb-cli-${{ github.ref_name }}-linux-aarch64.gz
out/hyperbytedb-cli-${{ github.ref_name }}-linux-aarch64.gz.sha256
out/hyperbytedb-proxy-${{ github.ref_name }}-linux-x86_64.gz
out/hyperbytedb-proxy-${{ github.ref_name }}-linux-x86_64.gz.sha256
out/hyperbytedb-proxy-${{ github.ref_name }}-linux-aarch64.gz
out/hyperbytedb-proxy-${{ github.ref_name }}-linux-aarch64.gz.sha256