Native-addon CI prebuilds
Reference for the holepunchto/actions GitHub Actions that compile, upload, and merge native Bare-addon prebuilds across platforms in CI.
holepunchto/actions is a collection of reusable composite GitHub Actions. This page covers the ones for authors of native Bare addons who build prebuilt binaries across platforms in CI. Reference one with:
- uses: holepunchto/actions/<name>@v1See Native addons for writing the addon itself. This page covers only the CI pipeline that builds prebuilt binaries for every platform once the addon exists.
Prebuild pipeline
The typical shape is a build matrix where each job runs compile-prebuilds, then a final job merges the per-platform artifacts.
| Action | Purpose | Key inputs |
|---|---|---|
compile-prebuilds | Install bare-make with setup-bare-make, then generate / build / install a native prebuild for one platform + arch, optionally uploading it. | platform, arch, flags, tags, prefix (default prebuilds), path (default .), upload, wasi, musl |
upload-prebuilds | Upload a compiled prebuild as an artifact named <platform>-<arch><tags>. | platform (required), arch (required), tags, prefix |
download-prebuilds | Download all prebuild artifacts into one directory (merge-multiple). | prefix (default prebuilds) |
merge-prebuilds | Download every per-platform prebuild artifact and re-upload them as a single prebuilds artifact. | — |
compile-prebuilds inputs
platform and arch are optional. compile-prebuilds passes --platform and --arch to bare-make generate only when they are set, and bare-make builds for the host without them. Set both when upload is true, because upload-prebuilds requires them and names the artifact from them. flags is passed on to bare-make generate, and path is the directory that holds the source tree to compile.
wasi and musl default to false. Set wasi: true to install the WASI sysroot for targeting WASI, and musl: true to install the musl sysroot for targeting musl. compile-prebuilds passes both inputs to setup-bare-make, and they do nothing else. The target itself is still chosen with platform, arch, and flags; see the bare-make toolchain notes for the wasi-wasm32 and musl targets.
WebAssembly prebuilds
From Bare 1.36.0, an addon package can ship a WebAssembly build next to its native ones, which Bare loads sandboxed through WASI when an import asks for it with the host attribute, or when there is no native build for the platform. See WebAssembly addons. The build is one more matrix entry, with wasi set so that setup-bare-make installs wasi-sysroot. This is how bare-sqlite 0.1.5 builds its prebuilds:
strategy:
matrix:
include:
# ...the native platforms
- os: ubuntu-24.04
platform: wasi
arch: wasm32
steps:
- uses: holepunchto/actions/bare-base@v1
- uses: holepunchto/actions/compile-prebuilds@v1
with:
platform: ${{ matrix.platform }}
arch: ${{ matrix.arch }}
wasi: ${{ matrix.platform == 'wasi' }}
upload: trueWhat the job builds:
| Piece | Behavior |
|---|---|
| Target | bare-make generate --platform wasi --arch wasm32 uses the wasi-wasm32 toolchain of cmake-toolchains 2.1.1 and later (2.1.0 added it, and 2.1.1 fixed its WebAssembly compile and link flags), which compiles for wasm32-wasip1 with the Clang from llvm-runtime and the sysroot from wasi-sysroot. C++ exceptions and setjmp() use WebAssembly exception handling, and a shared library is built as a static one, because WebAssembly cannot link shared libraries. See the bare-make toolchain notes. |
| Module | For a wasi- host, add_bare_module() of cmake-bare 1.10.0 and later builds a WASI reactor instead of a shared library. It exports bare_register_module_v0, malloc, free, and the function table, and leaves undefined functions as imports, which the --allow-undefined linker flag of 1.10.1 allows. |
| Output | The module is installed as prebuilds/wasi-wasm32/<name>.wasm, where bare-addon-resolve looks for it after the native prebuilds and linked addons. |
| Runtime dependencies | None. Passing any to add_bare_module() fails with WebAssembly addons cannot install runtime dependencies. |
| Headers | bare/target.h defines the wasi platform and wasm32 architecture from Bare 1.35.0. bare-sqlite 0.1.5 includes <bare/module.h> rather than <bare.h>, and no longer includes <uv.h>, to build for it. |
The imports of the result are checked when it loads, not when it builds. Bare loads it through bare-wasm-abi, which rejects an addon that imports a libjs function it does not implement, such as threadsafe functions or the event loop. Load the built addon under Bare with require('.', { with: { host: 'wasi-wasm32' } }) from the package directory to check it.
Project and toolchain setup
These are the supporting actions for a prebuild job. Use any of them directly in a workflow.
| Action | Purpose |
|---|---|
checkout | actions/checkout with persist-credentials: false. Input: fetch-depth (default 1; 0 fetches all history). |
setup-node | Install Node.js (LTS by default) and configure the npm registry/scope for auth. Inputs: version (default lts/*), registry-url, scope, and package-manager-cache (default false). |
node-base | checkout + setup-socket + setup-node, then npm install --ignore-scripts. Inputs: allow-git (none, root, or all; default none), force-install, and the registry, scope, and auth options. |
setup-bare-make | Install bare-make globally with npm. With wasi: true or musl: true, also install wasi-sysroot or musl-sysroot. compile-prebuilds runs it. |
setup-bare | Install the bare-runtime globally. With source: true, compile Bare from source instead, using the ref, flags, and path inputs. |
compile-bare | Check out holepunchto/bare at ref (a branch, tag, or SHA), compile it, and install it onto PATH. Other inputs: flags and path (default .bare). |
bare-base | node-base + setup-bare: configure a Bare project on a runner. Takes the inputs of both. |
setup-llvm, setup-nasm, setup-swift, swift-base | Install LLVM, NASM, or Swift on the runner. setup-llvm and setup-nasm use the platform's package manager. setup-swift installs Swift on Linux only, because macOS runners use the Swift that ships with Xcode, and swift-base is checkout plus setup-swift. compile-prebuilds calls none of them. bare-make 2.0.0 and later depends on the llvm-runtime and nasm-runtime packages. |
setup-socket, setup-mininet | Install supporting tooling: setup-socket configures Socket.dev supply-chain scanning; setup-mininet installs Mininet and Open vSwitch for network-emulation tests. |
See also
- Native addons—writing the addon this pipeline builds.
bare-makereference—the build toolcompile-prebuildsruns.- Bare modules—the runtime the prebuild pipeline targets.
- Holepunch GitHub Actions—the same
holepunchto/actionscollection's Pear app CI/CD and release actions.
Last updated on