Skip to main content

How to build ORAS CLI locally

Prerequisites​

  • Go 1.20+
  • Git
  • Make

Clone the Repository​

Once you have the basic tools installed, fork the repository on GitHub and clone it locally:

MY_GITHUB_NAME="my-name"
git clone git@github.com:${MY_GITHUB_NAME}/oras.git
cd oras

Running Tests​

The default Makefile target will run the tests and build the architecture appropriate binary.

make

This command will:

  • Run go mod tidy to ensure dependencies are up to date
  • Run go mod vendor to vendor dependencies
  • Check file encoding
  • Execute all unit tests with race detection and generate a coverage report
  • Build the binary for the current architecture

Building the Binaries​

Running make build will build all platform binaries to the bin/ directory. To compile and run the tests in one step, just run the make command.

Mac:

# builds to
# - bin/darwin/amd64/oras
# - bin/darwin/arm64/oras
make build-mac

# builds to bin/darwin/amd64/oras
make build-mac-amd64

# builds to bin/darwin/arm64/oras
make build-mac-arm64

Linux:

# builds to
# - bin/linux/arm64/oras
# - bin/linux/amd64/oras
# - bin/linux/arm/v7/oras
make build-linux

# builds to bin/linux/arm64/oras
make build-linux-arm64

# builds to bin/linux/amd64/oras
make build-linux-amd64

# builds to bin/linux/arm/v7/oras
make build-linux-arm-v7

Windows:

# builds to bin/windows/amd64/oras.exe
make build-windows

Cleaning Your Workspace​

To remove all files not managed by git, run make clean (be careful!)

Managing Dependencies​

Using Go Modules to manage dependencies.

To update or add new dependencies, run go get <package name>.