Skip to content

Support for single binary distribution#491

Merged
dyoshikawa merged 17 commits intomainfrom
claude/enable-bun-compile-binary-011CUv7Fy7fJ9FZYpbxR35VB
Nov 9, 2025
Merged

Support for single binary distribution#491
dyoshikawa merged 17 commits intomainfrom
claude/enable-bun-compile-binary-011CUv7Fy7fJ9FZYpbxR35VB

Conversation

@dyoshikawa
Copy link
Copy Markdown
Owner

@dyoshikawa dyoshikawa commented Nov 8, 2025

Fixes: #284

- Add build scripts for creating standalone binaries using bun compile
- Support cross-platform builds (Linux x64, macOS x64/ARM64, Windows x64)
- Use two-stage build process: esbuild bundles dependencies, then bun compiles to binary
- Add dist-bun directory to gitignore for compiled binaries
- Add esbuild as dev dependency for bundling

Available scripts:
- build:bun: Build binary for current platform
- build:bun:all: Build binaries for all platforms
- build:bun:linux/macos/windows: Build platform-specific binaries
Copilot AI review requested due to automatic review settings November 8, 2025 09:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for creating standalone binaries using Bun's compile feature, enabling cross-platform distribution of the rulesync CLI tool.

  • Adds build scripts for bundling and compiling standalone binaries using esbuild and Bun
  • Introduces cross-platform build targets (Linux x64, macOS x64/ARM64, Windows x64)
  • Updates .gitignore to exclude build artifacts

Reviewed Changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.

File Description
package.json Adds 7 new build:bun scripts for binary compilation and adds esbuild as a dev dependency
.gitignore Adds dist-bun directory and /rulesync binary to ignored files

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

claude and others added 7 commits November 8, 2025 10:25
- Replace esbuild with tsup for dependency bundling
- Add GitHub Actions workflow to build and upload binaries on release
- Support cross-platform builds (Linux x64, macOS x64/ARM64, Windows x64)
- Add tsup.bundle.config.ts for bundling all dependencies
- Update build scripts to use tsup instead of esbuild

Build process:
1. tsup bundles all dependencies into single file (dist-bun/index.js)
2. bun compile creates standalone binary from bundled file

This approach resolves node-fetch-native export issues with bun compile.
- Remove tsup dependency for bundling (no longer needed)
- Use bun build --compile --external giget directly
- Significantly faster build times compared to tsup approach
- Remove tsup.bundle.config.ts

Technical details:
- The --external giget flag prevents bundling c12's dependency chain
- This avoids the node-fetch-native export compatibility issue
- Binary size remains similar (~60-116MB depending on platform)
- All functionality works correctly with giget as external dependency

This simplifies the build process while maintaining full compatibility.
Changed from ignoring `/rulesync` to ignoring `dist-bun/` directory and `*.bun-build` files for better organization of Bun build artifacts.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Simplify CI workflow to focus on binary building instead of quality checks
- Consolidate binary builds to single Ubuntu runner (cross-compilation)
- Remove redundant Bun installation from Dockerfile (use mise instead)
- Add Bun to mise.toml toolchain configuration
- Remove npm scripts for individual platform builds
- Add e2e workflow for end-to-end testing
- Build Linux (x64, arm64) and macOS (x64, arm64) binaries

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Move binary build from CI to E2E workflow to reduce CI execution time
- Rename CI job from "build" to "quality" to better reflect its purpose
- Add dependency checks and build artifact validation to CI workflow
- E2E workflow now builds binaries first, then runs platform-specific tests
- Remove workflow_run trigger from E2E to simplify workflow dependencies

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
cm-dyoshikawa and others added 5 commits November 8, 2025 06:47
Update the workflow name from "E2E Tests" to "E2E Tests on Cross-Platform" to better reflect that these tests run on multiple operating systems (Ubuntu, macOS, Windows).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add explicit `bun install` step before building binaries to ensure all dependencies are available during the build process.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add --ignore-scripts flag to bun install to prevent unnecessary script execution during CI.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Split binary building workflows into dedicated files
  - Created release-binaries.yml for release binary builds
  - Renamed e2e.yml to e2e-binaries.yml for consistency
- Removed build-binaries job from release.yml (now in release-binaries.yml)
- Added permissions declaration to ci.yml for clarity

This separation improves workflow maintainability and allows independent
execution and debugging of binary builds and NPM publishing.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Changed contents permission from write to read in the release workflow since release assets are uploaded via JSR publish action which uses OIDC authentication rather than requiring direct write permissions to the repository.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@cm-dyoshikawa cm-dyoshikawa changed the title feat: add bun compile support for binary distribution Support for single binary distribution Nov 9, 2025
cm-dyoshikawa and others added 3 commits November 8, 2025 17:08
Removed Node.js and pnpm setup steps from the release-binaries workflow.
Now using Bun exclusively for dependency installation with --ignore-scripts
flag to streamline the binary compilation process.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit addresses three critical security issues identified in PR #491:

1. **Pin Bun version to 1.3.2 in release workflow**
   - Changed from 'latest' to '1.3.2' to ensure consistent binary builds
   - Eliminates supply chain risk from version inconsistency

2. **Add SHA256 checksum generation and publishing**
   - Generate SHA256SUMS file for all binaries
   - Include checksums in release assets for integrity verification
   - Enables users to verify binary authenticity

3. **Fix GitHub Actions expression injection risks**
   - Use environment variables instead of direct expression interpolation
   - Changed ${{ matrix.os }} to env variable MATRIX_OS
   - Changed ${{ env.BINARY_PATH }} to shell variable "${BINARY_PATH}"
   - Prevents potential command injection vulnerabilities

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@dyoshikawa dyoshikawa merged commit 9c27a79 into main Nov 9, 2025
7 checks passed
@dyoshikawa dyoshikawa deleted the claude/enable-bun-compile-binary-011CUv7Fy7fJ9FZYpbxR35VB branch November 9, 2025 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for distributing single binary

5 participants