Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
# BUILD_VERSION is the latest tag.
BUILD_VERSION := $(shell git describe --tags --always)
GO=$(shell which go)
RM=rm -f ./bin/*

# windows specific commands
ifeq ($(OS), Windows_NT)
MV=move bin\opair bin\opair.exe
GO=go
RM=IF exist bin (cmd /c del /s /q bin && rmdir bin)
endif

#
# Go sources management.
#

GO := $(shell which go)

.PHONY: build
build:
build: clean-bin
$(GO) build -ldflags="-X 'optable-pair-cli/pkg/cmd/cli.version=${BUILD_VERSION}'" -o bin/opair pkg/cmd/main.go
$(MV)

.PHONY: release
release: darwin linux windows
Expand All @@ -23,33 +31,33 @@ darwin: darwin-amd64 darwin-arm64
.PHONY: darwin-amd64
darwin-amd64:
make clean-bin ;\
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 make build ;\
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 make build ;\
mkdir -p release && cp bin/opair release/opair-darwin-amd64

.PHONY: darwin-arm64
darwin-arm64:
make clean-bin ;\
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 make build ;\
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 make build ;\
mkdir -p release && cp bin/opair release/opair-darwin-arm64

.PHONY: linux
linux:
make clean-bin ;\
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make build ;\
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 make build ;\
mkdir -p release && cp bin/opair release/opair-linux-amd64

.PHONY: windows
windows:
make clean-bin ;\
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 make build ;\
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 make build ;\
mkdir -p release && cp bin/opair release/opair-windows-amd64.exe

.PHONY: clean
clean: clean-bin clean-release

.PHONY: clean-bin
clean-bin:
rm -f ./bin/opair
$(RM)

.PHONY: clean-release
clean-release:
Expand Down
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,22 @@ make
# or more specifically:
make build
```

The successfully compiled binary will be located in `bin/opair`.

## Build on windows
To build the CLI on windows, you would need to first install make.
You can either install make directly [here](https://gnuwin32.sourceforge.net/packages/make.htm) or through [chocolatey](https://chocolatey.org/install), in which case, you can run the following command in **power shell**:
```bash
choco install make
```

After installing make, you can run the following command in **power shell** to build the CLI:
```bash
make
```
The successfully compiled binary will be located in `bin\opair.exe`.


# Download binaries
You can also download the pre-built binaries [here](https://github.com/Optable/optable-pair-cli/releases/latest) under the assets of the latest release.

Expand Down