Build & Release Pipeline
Relevant source files
The following files were used as context for generating this wiki page:
The Resend CLI build and release pipeline manages the transformation of TypeScript source code into distributed binaries and NPM packages. It includes automated linting, testing, cross-platform binary compilation, and integrity verification via checksums.
The pipeline ensures that the resend command is available across macOS, Linux, and Windows through various installation methods including NPM, Homebrew, and standalone installer scripts.
Build Orchestration
The build process is defined through NPM scripts that manage dependencies, compilation, and bundling. The project uses pnpm as the package manager and esbuild for rapid compilation of the TypeScript source.
Core Build Commands
| Command | Action |
|---|---|
pnpm build | Executes node scripts/build.mjs to compile source to dist/cli.cjs. |
pnpm build:bin | Compiles the project and then uses @yao-pkg/pkg to create standalone executables for node24. |
pnpm prepack | Runs a sequence: pnpm install -> pnpm build -> node scripts/verify-bundle.mjs. |
Sources: package.json:30-41
Binary Compilation Logic
Standalone binaries are compressed using Brotli and target the node24 runtime. The configuration includes specific assets required for React Email rendering, such as esbuild-wasm and its associated WebAssembly files.
Sources: package.json:34, package.json:54-63
The diagram shows the progression from source code to final distribution binaries, including verification steps.
Bundle Verification
The pipeline includes a specialized verification script, scripts/verify-bundle.mjs, which validates the integrity of the generated CJS bundle before distribution. This script prevents shipping broken or insecure builds.
Verification Criteria
- API Key Protection: Checks for the presence of the PostHog public key.
- External Dependencies: Ensures that
esbuildandesbuild-wasmare treated as external requirements and not incorrectly inlined into the bundle. - Bundling Markers: Scans for specific error strings that indicate the
esbuildJavaScript API was incorrectly bundled.
Sources: tests/scripts/verify-bundle.test.ts:39-75
Installation and Distribution
The CLI is distributed through multiple channels, each managed by specific scripts or package manager configurations.
1. Unix-like Systems (macOS / Linux)
The install.sh script automates the download and setup for Unix environments.
- Platform Detection: Detects
Darwin(x86_64/arm64) andLinux(x86_64/arm64). - Checksum Verification: Downloads
checksums.txtand validates the archive usingsha256sumorshasum. - Environment Setup: Automatically detects the user's shell (zsh, bash, or fish) and appends the binary path to the profile configuration file (e.g.,
.zshrc,.bash_profile).
Sources: install.sh:58-95, install.sh:160-200, install.sh:255-300
2. Windows Systems
The install.ps1 PowerShell script handles Windows installations.
- Architecture Check: Restricts installation to
AMD64(x64) architectures. - PATH Management: Uses
[Environment]::SetEnvironmentVariableto persist the installation path in the User scope.
Sources: install.ps1:32-35, install.ps1:194-205
Update Mechanism
The CLI includes an automated update detection system that checks for new releases on GitHub.
Update Logic
The system polls the GitHub Releases API (/releases/latest) and caches the result for one hour. It compares the local version against the tag_name from the remote API.
The diagram illustrates the background check process that occurs when a user runs a command in an interactive TTY.
Sources: src/lib/update-check.ts:9-85
Skipping Checks
Update checks are automatically bypassed if:
- The
--jsonflag is provided. - The
RESEND_NO_UPDATE_NOTIFIERenvironment variable is set to1. - The environment is a CI system (detects
CI=trueorGITHUB_ACTIONS). - The output is not a TTY.
Sources: src/lib/update-check.ts:87-105
Quality Assurance
The pipeline utilizes a multi-layered testing strategy to ensure reliability.
- Linting: Biome enforces code style and catches unused imports/variables.
- Unit Testing: Vitest runs unit tests for command logic and library functions.
- E2E Smoke Tests: The
test:e2escript runs the actual compiled CLI against the live Resend API to validate end-to-end connectivity and JSON output shapes. - Doctor Command: A built-in
resend doctorcommand allows users and developers to verify their local environment, including API key validity and credential storage safety.
Sources: package.json:36-39, tests/e2e/smoke.test.ts:36-75, src/commands/doctor.ts:241-260
Conclusion
The build and release pipeline ensures that the Resend CLI remains a robust, cross-platform tool. By combining static bundle verification, automated checksum validation in installers, and background update checks, the project maintains high standards of distribution security and user experience.