How To: Build the Hyaline CLI

Purpose

Build the hyaline cli locally or on a remote machine.

Prerequisite(s)

Steps

1. Clone/Checkout Hyaline Repo

Ensure that the Hyaline Repository is cloned and checked out to the version you wish to build.

2. Determine the Version

Hyaline uses the commit date and short hash to specify the version being build. This can be determined by running the following commands in the root of the repository with the desired commit checked out.

# Format: YYYY-MM-DD-HASH
DATE=`git log -n1 --pretty='%cd' --date=format:'%Y-%m-%d'`
HASH=`git rev-parse --short HEAD`
VERSION="$DATE-$HASH"

3. Run Go Build

Once the version is specified you can build hyaline using the following command (from the root of the repo):

$ go build -o ./dist/hyaline -ldflags="-X 'main.Version=$VERSION'" ./cmd/hyaline.go

You can specify the OS and architecture to use by setting the appropriate GOOS/GOARCH environment variables. For example, to build for the 64bit ARM version of MacOS:

$ GOOS=darwin GOARCH=arm64 go build -o ./dist/hyaline -ldflags="-X 'main.Version=$TAG'" ./cmd/hyaline.go

4. Test Executable

Make sure you test that the resulting executable was built sucessfully and at the right version by running:

$ ./hyaline version

Next Steps

Visit CLI Reference.