Skip to content

Commit 161f5fc

Browse files
egeominotticlaude
andcommitted
ci(release): compress binary assets + only release on a new version
The release job in ci.yml uploaded raw Bun --compile binaries (~60–94MB each) on EVERY push to main. Two fixes: 1. Compress assets. "Prepare release assets" now tar.gz's each unix binary (chmod +x first, preserving the exec bit) and zip's the windows .exe, plus a SHA256SUMS. Download drops ~55–65% (~30–40MB). The files: list and the release-body download table/example were updated (extract step added). 2. Stop releasing on every commit. New version-gate job sets should_release based on whether refs/tags/v<package.json version> already exists on origin. build, docker, and release now run only when the version is NEW — so a docs/chore commit (no version bump) no longer rebuilds 5×~90MB binaries, re-pushes docker, or cuts a duplicate release. The release job gates explicitly on the version-gate output (not implicit success() propagation). 3. Delete the dead release.yml. It triggered on push:tags:v* but never ran (the tag is created by the release job's softprops action via GITHUB_TOKEN, which does not trigger tag-push workflows) and lacked the windows target. Note: docker :latest/:sha/:date now publish on a version bump rather than every main commit — :latest tracks the latest release. Static-validated only (YAML + bash -n); GitHub Actions can't run locally, so it is exercised on the next release. skeptic review: CONDITIONAL → addressed (explicit release gate applied; docker-gating behavior change acknowledged as intentional). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 5a6462f commit 161f5fc

2 files changed

Lines changed: 81 additions & 99 deletions

File tree

.github/workflows/ci.yml

Lines changed: 81 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,43 @@ jobs:
118118
run: bun scripts/websocket/run-all-tests.ts
119119

120120
# ============================================
121-
# Build Binaries (only on main)
121+
# Version gate — only build binaries / cut a release when package.json
122+
# version is NEW (avoids rebuilding 5×~90MB binaries + a fresh release on
123+
# every docs/chore commit to main, which never bumps the version).
122124
# ============================================
123-
build:
124-
name: Build (${{ matrix.target }})
125+
version-gate:
126+
name: Version gate
125127
runs-on: ubuntu-latest
126128
needs: [lint, typecheck, test, test-websocket]
127129
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
130+
outputs:
131+
version: ${{ steps.gate.outputs.version }}
132+
should_release: ${{ steps.gate.outputs.should_release }}
133+
steps:
134+
- uses: actions/checkout@v4
135+
136+
- name: Decide whether this version is already released
137+
id: gate
138+
run: |
139+
set -euo pipefail
140+
VERSION=$(node -p "require('./package.json').version")
141+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
142+
if git ls-remote --exit-code --tags origin "refs/tags/v$VERSION" >/dev/null 2>&1; then
143+
echo "should_release=false" >> "$GITHUB_OUTPUT"
144+
echo "::notice::v$VERSION already released — skipping binary build, docker push, and release."
145+
else
146+
echo "should_release=true" >> "$GITHUB_OUTPUT"
147+
echo "::notice::v$VERSION is new — building binaries and cutting a release."
148+
fi
149+
150+
# ============================================
151+
# Build Binaries (only on a new version)
152+
# ============================================
153+
build:
154+
name: Build (${{ matrix.target }})
155+
runs-on: ubuntu-latest
156+
needs: [version-gate]
157+
if: needs.version-gate.outputs.should_release == 'true'
128158
strategy:
129159
matrix:
130160
include:
@@ -172,8 +202,8 @@ jobs:
172202
docker:
173203
name: Docker
174204
runs-on: ubuntu-latest
175-
needs: [lint, typecheck, test, test-websocket]
176-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
205+
needs: [version-gate]
206+
if: needs.version-gate.outputs.should_release == 'true'
177207
permissions:
178208
contents: read
179209
packages: write
@@ -220,18 +250,18 @@ jobs:
220250
release:
221251
name: Release
222252
runs-on: ubuntu-latest
223-
needs: [build, docker]
224-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
253+
needs: [version-gate, build, docker]
254+
# Explicit gate (not just implicit success() propagation from build/docker):
255+
# only cut a release for a NEW version.
256+
if: needs.version-gate.outputs.should_release == 'true'
225257
permissions:
226258
contents: write
227259
steps:
228260
- uses: actions/checkout@v4
229261

230-
- name: Get version from package.json
262+
- name: Resolve version
231263
id: version
232-
run: |
233-
VERSION=$(node -p "require('./package.json').version")
234-
echo "version=$VERSION" >> $GITHUB_OUTPUT
264+
run: echo "version=${{ needs.version-gate.outputs.version }}" >> "$GITHUB_OUTPUT"
235265

236266
- name: Download all artifacts
237267
uses: actions/download-artifact@v4
@@ -242,20 +272,34 @@ jobs:
242272

243273
- name: Prepare release assets
244274
run: |
275+
set -euo pipefail
245276
mkdir -p release
246277
ls -la artifacts/
247278
248-
# Copy all binaries to release folder
249-
cp artifacts/bunqueue-linux-x64 release/ 2>/dev/null || cp artifacts/*/bunqueue-linux-x64 release/ 2>/dev/null || true
250-
cp artifacts/bunqueue-linux-arm64 release/ 2>/dev/null || cp artifacts/*/bunqueue-linux-arm64 release/ 2>/dev/null || true
251-
cp artifacts/bunqueue-darwin-x64 release/ 2>/dev/null || cp artifacts/*/bunqueue-darwin-x64 release/ 2>/dev/null || true
252-
cp artifacts/bunqueue-darwin-arm64 release/ 2>/dev/null || cp artifacts/*/bunqueue-darwin-arm64 release/ 2>/dev/null || true
253-
cp artifacts/bunqueue-windows-x64.exe release/ 2>/dev/null || cp artifacts/*/bunqueue-windows-x64.exe release/ 2>/dev/null || true
254-
255-
# Make executables
256-
chmod +x release/bunqueue-linux-x64 release/bunqueue-linux-arm64 release/bunqueue-darwin-x64 release/bunqueue-darwin-arm64 2>/dev/null || true
257-
258-
ls -la release/
279+
# Collect binaries (artifacts may be nested one level depending on the
280+
# upload-artifact version), keeping the canonical names.
281+
for name in bunqueue-linux-x64 bunqueue-linux-arm64 bunqueue-darwin-x64 bunqueue-darwin-arm64 bunqueue-windows-x64.exe; do
282+
cp "artifacts/$name" release/ 2>/dev/null || cp "artifacts/$name/$name" release/ 2>/dev/null || true
283+
done
284+
285+
# Compress each binary before upload: a Bun --compile binary embeds the
286+
# whole runtime (~60–94MB) but compresses ~55–65%, so the DOWNLOAD drops
287+
# to ~30–40MB. Unix → .tar.gz (preserves the +x bit), Windows → .zip.
288+
cd release
289+
for name in bunqueue-linux-x64 bunqueue-linux-arm64 bunqueue-darwin-x64 bunqueue-darwin-arm64; do
290+
[ -f "$name" ] || continue
291+
chmod +x "$name"
292+
tar -czf "$name.tar.gz" "$name"
293+
rm "$name"
294+
done
295+
if [ -f bunqueue-windows-x64.exe ]; then
296+
zip -9 bunqueue-windows-x64.zip bunqueue-windows-x64.exe
297+
rm bunqueue-windows-x64.exe
298+
fi
299+
300+
# Checksums of the published (compressed) artifacts.
301+
sha256sum bunqueue-* > SHA256SUMS
302+
ls -la
259303
260304
- name: Create Release
261305
uses: softprops/action-gh-release@v2
@@ -267,11 +311,12 @@ jobs:
267311
prerelease: false
268312
make_latest: true
269313
files: |
270-
release/bunqueue-linux-x64
271-
release/bunqueue-linux-arm64
272-
release/bunqueue-darwin-x64
273-
release/bunqueue-darwin-arm64
274-
release/bunqueue-windows-x64.exe
314+
release/bunqueue-linux-x64.tar.gz
315+
release/bunqueue-linux-arm64.tar.gz
316+
release/bunqueue-darwin-x64.tar.gz
317+
release/bunqueue-darwin-arm64.tar.gz
318+
release/bunqueue-windows-x64.zip
319+
release/SHA256SUMS
275320
body: |
276321
## Installation
277322
@@ -284,16 +329,20 @@ jobs:
284329
285330
### Binary
286331
332+
Compressed downloads (~30–40MB; extract to get the standalone
333+
executable, which embeds the Bun runtime). Verify with `SHA256SUMS`.
334+
287335
| Platform | Architecture | Download |
288336
|----------|-------------|----------|
289-
| Linux | x64 | `bunqueue-linux-x64` |
290-
| Linux | arm64 | `bunqueue-linux-arm64` |
291-
| macOS | x64 (Intel) | `bunqueue-darwin-x64` |
292-
| macOS | arm64 (Apple Silicon) | `bunqueue-darwin-arm64` |
293-
| Windows | x64 | `bunqueue-windows-x64.exe` |
337+
| Linux | x64 | `bunqueue-linux-x64.tar.gz` |
338+
| Linux | arm64 | `bunqueue-linux-arm64.tar.gz` |
339+
| macOS | x64 (Intel) | `bunqueue-darwin-x64.tar.gz` |
340+
| macOS | arm64 (Apple Silicon) | `bunqueue-darwin-arm64.tar.gz` |
341+
| Windows | x64 | `bunqueue-windows-x64.zip` |
294342
295343
```bash
296344
# Example: Linux x64
345+
tar -xzf bunqueue-linux-x64.tar.gz
297346
chmod +x bunqueue-linux-x64
298347
./bunqueue-linux-x64
299348
```

.github/workflows/release.yml

Lines changed: 0 additions & 67 deletions
This file was deleted.

0 commit comments

Comments
 (0)