Skip to main content

Building Your Own Zarf CLI

To build the Zarf CLI from scratch, you'll need to have the following dependencies configured:

  1. The Zarf repository cloned down:
    • git clone
  2. Have Go 1.19.x installed on your PATH (instructions to install Go).
  3. Have NPM/Node 18.x installed on your PATH (instructions to install NPM/Node).
  4. make utility installed on your PATH.

If you are running make targets other than the build-cli-* targets described below, you may need more software installed. Inspect the Makefile at the root of the project to view the commands each target runs.

If you don't want to build the CLI yourself, you can download a pre-compiled binary from the 'Assets' tab of our latest releases on GitHub. The pre-compiled binary is available for both arm64 and amd64 machines.

Building the CLI

Once you have the dependencies configured, you can build the Zarf CLI by running the following commands:

cd zarf        # go into the root level of the zarf repository

make build-cli # This will build binaries for linux, M1 Mac, and Intel Mac machines
# This puts the built binaries in the ./build directory
Optimization Note

The make build-cli command builds a binary for each combination of OS and architecture, which may take some time. If you only need a binary for a specific configuration, you can use one of the following commands:

  • make build-cli-mac-intel
  • make build-cli-mac-apple
  • make build-cli-linux-amd
  • make build-cli-linux-arm
  • make build-cli-windows-amd
  • make build-cli-windows-arm

The Technical Process

Under the hood, the make command executes a go build ..... command with specific CGO_ENABLED, GOOS, and GOARCH flags depending on the distro and architecture of the system it is building for. The CLI_VERSION is passed in as a ldflag and is set the latest tag is in the repository as defined by git describe --tags.