-
Notifications
You must be signed in to change notification settings - Fork 18
345 lines (297 loc) · 10.6 KB
/
Copy pathci.yml
File metadata and controls
345 lines (297 loc) · 10.6 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
name: CI
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
env:
BUN_VERSION: "latest"
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
# ============================================
# Code Quality
# ============================================
lint:
name: Lint & Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: ${{ env.BUN_VERSION }}
- name: Install dependencies
run: bun install --ignore-scripts
- name: Biome check (lint + format)
run: bun run check:biome
typecheck:
name: Type Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: ${{ env.BUN_VERSION }}
- name: Install dependencies
run: bun install --ignore-scripts
- name: Run type check
run: bun run typecheck
# ============================================
# Tests
# ============================================
test:
name: Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: ${{ env.BUN_VERSION }}
- name: Install dependencies
run: bun install --ignore-scripts
- name: Run unit tests
run: bun test
# test-tcp:
# name: TCP Integration Tests
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
#
# - uses: oven-sh/setup-bun@v2
# with:
# bun-version: ${{ env.BUN_VERSION }}
#
# - name: Install dependencies
# run: bun install --ignore-scripts
#
# - name: Run TCP integration tests
# run: bun scripts/tcp/run-all-tests.ts
# test-embedded:
# name: Embedded Integration Tests
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
#
# - uses: oven-sh/setup-bun@v2
# with:
# bun-version: ${{ env.BUN_VERSION }}
#
# - name: Install dependencies
# run: bun install --ignore-scripts
#
# - name: Run embedded integration tests
# run: bun scripts/embedded/run-all-tests.ts
test-websocket:
name: WebSocket/SSE Integration Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: ${{ env.BUN_VERSION }}
- name: Install dependencies
run: bun install --ignore-scripts
- name: Run WebSocket/SSE integration tests
run: bun scripts/websocket/run-all-tests.ts
# ============================================
# Version gate — only build binaries / cut a release when package.json
# version is NEW (avoids rebuilding 5×~90MB binaries + a fresh release on
# every docs/chore commit to main, which never bumps the version).
# ============================================
version-gate:
name: Version gate
runs-on: ubuntu-latest
needs: [lint, typecheck, test, test-websocket]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
outputs:
version: ${{ steps.gate.outputs.version }}
should_release: ${{ steps.gate.outputs.should_release }}
steps:
- uses: actions/checkout@v4
- name: Decide whether this version is already released
id: gate
run: |
set -euo pipefail
VERSION=$(node -p "require('./package.json').version")
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
if git ls-remote --exit-code --tags origin "refs/tags/v$VERSION" >/dev/null 2>&1; then
echo "should_release=false" >> "$GITHUB_OUTPUT"
echo "::notice::v$VERSION already released — skipping binary build, docker push, and release."
else
echo "should_release=true" >> "$GITHUB_OUTPUT"
echo "::notice::v$VERSION is new — building binaries and cutting a release."
fi
# ============================================
# Build Binaries (only on a new version)
# ============================================
build:
name: Build (${{ matrix.target }})
runs-on: ubuntu-latest
needs: [version-gate]
if: needs.version-gate.outputs.should_release == 'true'
strategy:
matrix:
include:
- target: bun-linux-x64
artifact: bunqueue-linux-x64
- target: bun-linux-arm64
artifact: bunqueue-linux-arm64
- target: bun-darwin-x64
artifact: bunqueue-darwin-x64
- target: bun-darwin-arm64
artifact: bunqueue-darwin-arm64
- target: bun-windows-x64
artifact: bunqueue-windows-x64.exe
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: ${{ env.BUN_VERSION }}
- name: Install dependencies
run: bun install --ignore-scripts
- name: Get version from package.json
id: version
run: |
VERSION=$(node -p "require('./package.json').version")
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Build executable
run: bun build --compile --minify --target=${{ matrix.target }} src/main.ts --outfile ${{ matrix.artifact }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.artifact }}
path: ${{ matrix.artifact }}
retention-days: 7
# ============================================
# Docker Build & Push (only on main)
# ============================================
docker:
name: Docker
runs-on: ubuntu-latest
needs: [version-gate]
if: needs.version-gate.outputs.should_release == 'true'
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate tags
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest
type=sha,prefix=
type=raw,value={{date 'YYYYMMDD-HHmm'}}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
# ============================================
# Create Release (only on main)
# ============================================
release:
name: Release
runs-on: ubuntu-latest
needs: [version-gate, build, docker]
# Explicit gate (not just implicit success() propagation from build/docker):
# only cut a release for a NEW version.
if: needs.version-gate.outputs.should_release == 'true'
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Resolve version
id: version
run: echo "version=${{ needs.version-gate.outputs.version }}" >> "$GITHUB_OUTPUT"
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts/
pattern: bunqueue-*
merge-multiple: true
- name: Prepare release assets
run: |
set -euo pipefail
mkdir -p release
ls -la artifacts/
# Collect binaries (artifacts may be nested one level depending on the
# upload-artifact version), keeping the canonical names.
for name in bunqueue-linux-x64 bunqueue-linux-arm64 bunqueue-darwin-x64 bunqueue-darwin-arm64 bunqueue-windows-x64.exe; do
cp "artifacts/$name" release/ 2>/dev/null || cp "artifacts/$name/$name" release/ 2>/dev/null || true
done
# Compress each binary before upload: a Bun --compile binary embeds the
# whole runtime (~60–94MB) but compresses ~55–65%, so the DOWNLOAD drops
# to ~30–40MB. Unix → .tar.gz (preserves the +x bit), Windows → .zip.
cd release
for name in bunqueue-linux-x64 bunqueue-linux-arm64 bunqueue-darwin-x64 bunqueue-darwin-arm64; do
[ -f "$name" ] || continue
chmod +x "$name"
tar -czf "$name.tar.gz" "$name"
rm "$name"
done
if [ -f bunqueue-windows-x64.exe ]; then
zip -9 bunqueue-windows-x64.zip bunqueue-windows-x64.exe
rm bunqueue-windows-x64.exe
fi
# Checksums of the published (compressed) artifacts.
sha256sum bunqueue-* > SHA256SUMS
ls -la
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.version.outputs.version }}
name: Release v${{ steps.version.outputs.version }}
generate_release_notes: true
draft: false
prerelease: false
make_latest: true
files: |
release/bunqueue-linux-x64.tar.gz
release/bunqueue-linux-arm64.tar.gz
release/bunqueue-darwin-x64.tar.gz
release/bunqueue-darwin-arm64.tar.gz
release/bunqueue-windows-x64.zip
release/SHA256SUMS
body: |
## Installation
### Docker (recommended)
```bash
docker pull ghcr.io/${{ github.repository }}:latest
docker run -p 6789:6789 -p 6790:6790 ghcr.io/${{ github.repository }}:latest
```
### Binary
Compressed downloads (~30–40MB; extract to get the standalone
executable, which embeds the Bun runtime). Verify with `SHA256SUMS`.
| Platform | Architecture | Download |
|----------|-------------|----------|
| Linux | x64 | `bunqueue-linux-x64.tar.gz` |
| Linux | arm64 | `bunqueue-linux-arm64.tar.gz` |
| macOS | x64 (Intel) | `bunqueue-darwin-x64.tar.gz` |
| macOS | arm64 (Apple Silicon) | `bunqueue-darwin-arm64.tar.gz` |
| Windows | x64 | `bunqueue-windows-x64.zip` |
```bash
# Example: Linux x64
tar -xzf bunqueue-linux-x64.tar.gz
chmod +x bunqueue-linux-x64
./bunqueue-linux-x64
```