crates/formatjs_cli/RELEASE.md
This document explains how to build release binaries for the FormatJS Rust CLI for multiple platforms.
The repository includes two GitHub Actions workflows:
.github/workflows/rust-cli-test.yml)Runs automatically on:
main branchWhat it does:
.github/workflows/rust-cli-release.yml)Triggered by: Push a tag starting with formatjs_cli_v (e.g., formatjs_cli_v0.1.0)
# Create and push a release tag
git tag formatjs_cli_v0.1.0
git push origin formatjs_cli_v0.1.0
What it does:
Release artifacts:
formatjs_cli-darwin-arm64 (macOS Apple Silicon)formatjs_cli-linux-x64 (Linux x86_64)checksums.txt (SHA-256 checksums)cd crates/formatjs_cli
./release.sh
This uses native Cargo cross-compilation. Requires additional setup for cross-compilation (see below).
| Platform | Architecture | Target Triple | Status |
|---|---|---|---|
| macOS | Apple Silicon | aarch64-apple-darwin | ✅ Native (Bazel on GHA macOS runner) |
| Linux | x86_64 | x86_64-unknown-linux-gnu | ✅ Native (Bazel on GHA Linux runner) |
Note: The GitHub Actions workflow builds each platform natively on its respective runner, avoiding complex cross-compilation setup.
You have several options:
# Install zig (provides a cross-platform linker)
brew install zig
# Add Linux target
rustup target add x86_64-unknown-linux-gnu
# Zig will be automatically detected and used as the linker
# Add musl target (produces static binaries)
rustup target add x86_64-unknown-linux-musl
# Build
cargo build --release --target x86_64-unknown-linux-musl
# Install cross (Docker-based cross-compilation)
cargo install cross
# Build
cross build --release --target x86_64-unknown-linux-gnu
# Build for current platform
bazel build --compilation_mode=opt //crates/formatjs_cli:release_binary
# Build for specific platform (requires being on that platform)
# macOS ARM64:
bazel build --compilation_mode=opt --platforms=//crates/formatjs_cli/platforms:darwin_arm64 //crates/formatjs_cli:release_binary
# Linux x86_64:
bazel build --compilation_mode=opt --platforms=//crates/formatjs_cli/platforms:linux_x86_64 //crates/formatjs_cli:release_binary
Binary will be in bazel-bin/crates/formatjs_cli/formatjs_cli_release.
Note: Bazel builds each platform natively (no cross-compilation). Use GitHub Actions to build both platforms.
# macOS Apple Silicon
cargo build --release --target aarch64-apple-darwin
# macOS Intel
cargo build --release --target x86_64-apple-darwin
# Linux x86_64 (requires cross-compilation setup)
cargo build --release --target x86_64-unknown-linux-gnu
Binaries will be in target/<triple>/release/formatjs_cli.
After running the GitHub Actions workflow, artifacts will be available:
Release assets:
├── formatjs_cli-darwin-arm64 # macOS Apple Silicon
├── formatjs_cli-linux-x64 # Linux x86_64
└── checksums.txt # SHA-256 checksums
# Download from release
curl -LO https://github.com/formatjs/formatjs/releases/download/formatjs_cli_v0.1.0/checksums.txt
curl -LO https://github.com/formatjs/formatjs/releases/download/formatjs_cli_v0.1.0/formatjs_cli-darwin-arm64
shasum -a 256 -c checksums.txt
The GitHub Actions workflow includes smoke tests that run automatically:
./formatjs_cli-{platform} --version
./formatjs_cli-{platform} --help
To test manually after downloading:
# macOS Apple Silicon
chmod +x formatjs_cli-darwin-arm64
./formatjs_cli-darwin-arm64 --version
# Linux
chmod +x formatjs_cli-linux-x64
./formatjs_cli-linux-x64 --version
The GitHub Actions workflow automates the entire release process:
Tag the release:
# Update version in Cargo.toml if needed
git tag formatjs_cli_v0.1.0
git push origin formatjs_cli_v0.1.0
Workflow runs automatically:
Manual verification (optional):
Publish to npm (if applicable):
# Update package.json with release URLs
# Point to GitHub release assets
npm publish
Problem: cargo build --target x86_64-unknown-linux-gnu fails with linker errors.
Solutions:
brew install zig (easiest)cargo build --target x86_64-unknown-linux-muslcargo install cross && cross build --target x86_64-unknown-linux-gnuProblem: Binary fails to execute with "exec format error" or "cannot execute binary file".
Cause: Binary was built for wrong architecture.
Solution: Verify the target triple matches your platform:
file dist/v<version>/formatjs_cli-*
Problem: Bazel can't find the platform definition.
Solution: Ensure rules_rust is properly configured in MODULE.bazel or WORKSPACE.
The repository includes two production-ready GitHub Actions workflows:
.github/workflows/rust-cli-test.yml)Purpose: Continuous integration for all changes
Triggers:
main branchJobs:
build-and-test-macos: # Build and test on macOS runner
build-and-test-linux: # Build and test on Linux runner
Features:
.github/workflows/rust-cli-release.yml)Purpose: Create official releases with binaries
Triggers:
formatjs_cli_vJobs:
build-macos: # Build macOS binary
build-linux: # Build Linux binary
combine-and-release: # Combine, checksum, and create release
Features:
--version and --helpSame as the main FormatJS project (MIT).