diff --git a/.gitignore b/.gitignore index 94c59ed6..084d116c 100644 --- a/.gitignore +++ b/.gitignore @@ -249,3 +249,4 @@ cli/keyconjurer-darwin* cli/keyconjurer-linux* cli/keyconjurer-windows.exe vendor +bin/ diff --git a/Makefile b/Makefile index 1c6b4563..ce6d41bc 100644 --- a/Makefile +++ b/Makefile @@ -3,19 +3,19 @@ RELEASE ?= dev VERSION ?= $(shell git rev-parse --short HEAD) # This runs on Linux machines. Mac users should override TIMESTAMP. -TIMESTAMP ?= $(shell date --iso-8601=minutes) +TIMESTAMP ?= $(-shell date --iso-8601=minutes) ## Standard targets for all Makefiles in our team all: build clean: - rm -rf cli/keyconjurer* + rm -rf bin/keyconjurer* rm -r frontend/dist test: frontend_test go_test -CLI_TARGETS = cli/keyconjurer-darwin cli/keyconjurer-darwin-amd64 cli/keyconjurer-darwin-arm64 cli/keyconjurer-linux cli/keyconjurer-linux-amd64 cli/keyconjurer-linux-arm64 cli/keyconjurer-windows.exe +CLI_TARGETS = bin/keyconjurer-darwin bin/keyconjurer-darwin-amd64 bin/keyconjurer-darwin-arm64 bin/keyconjurer-linux bin/keyconjurer-linux-amd64 bin/keyconjurer-linux-arm64 bin/keyconjurer-windows.exe build: api_build frontend/dist/index.html $(CLI_TARGETS) go_test: @@ -32,29 +32,28 @@ frontend/dist/index.html: frontend/node_modules VITE_APP_VERSION='$(shell git rev-parse --short HEAD)-$(RELEASE)' cd frontend && npm run-script build ### CLI Build Targets -cli/keyconjurer-linux-arm64 cli/keyconjurer-linux: - GOOS=linux GOARCH=amd64 BUILD_TARGET=keyconjurer-linux $(MAKE) cli/keyconjurer - GOOS=linux GOARCH=arm64 BUILD_TARGET=keyconjurer-linux-arm64 $(MAKE) cli/keyconjurer +bin/keyconjurer-linux-arm64 bin/keyconjurer-linux: + GOOS=linux GOARCH=amd64 BUILD_TARGET=keyconjurer-linux $(MAKE) bin/keyconjurer + GOOS=linux GOARCH=arm64 BUILD_TARGET=keyconjurer-linux-arm64 $(MAKE) bin/keyconjurer -cli/keyconjurer-linux-amd64: cli/keyconjurer-linux - cp cli/keyconjurer-linux cli/keyconjurer-linux-amd64 +bin/keyconjurer-linux-amd64: bin/keyconjurer-linux + cp bin/keyconjurer-linux bin/keyconjurer-linux-amd64 -cli/keyconjurer-darwin-arm64 cli/keyconjurer-darwin: - GOOS=darwin GOARCH=amd64 BUILD_TARGET=keyconjurer-darwin $(MAKE) cli/keyconjurer - GOOS=darwin GOARCH=arm64 BUILD_TARGET=keyconjurer-darwin-arm64 $(MAKE) cli/keyconjurer +bin/keyconjurer-darwin-arm64 bin/keyconjurer-darwin: + GOOS=darwin GOARCH=amd64 BUILD_TARGET=keyconjurer-darwin $(MAKE) bin/keyconjurer + GOOS=darwin GOARCH=arm64 BUILD_TARGET=keyconjurer-darwin-arm64 $(MAKE) bin/keyconjurer -cli/keyconjurer-darwin-amd64: cli/keyconjurer-darwin - cp cli/keyconjurer-darwin cli/keyconjurer-darwin-amd64 +bin/keyconjurer-darwin-amd64: bin/keyconjurer-darwin + cp bin/keyconjurer-darwin bin/keyconjurer-darwin-amd64 -cli/keyconjurer-windows.exe: - GOOS=windows GOARCH=amd64 BUILD_TARGET=keyconjurer-windows.exe $(MAKE) cli/keyconjurer +bin/keyconjurer-windows.exe: + GOOS=windows GOARCH=amd64 BUILD_TARGET=keyconjurer-windows.exe $(MAKE) bin/keyconjurer -cli/keyconjurer: +bin/keyconjurer: bin/ @test $${CLIENT_ID?is not set} @test $${OIDC_DOMAIN?is not set} @test $${SERVER_ADDRESS?is not set} - cd cli && \ - go build \ + @go build \ -ldflags "\ -s -w \ -X main.Version=$(shell git rev-parse --short HEAD)-$(RELEASE) \ @@ -62,13 +61,16 @@ cli/keyconjurer: -X main.OIDCDomain=$(OIDC_DOMAIN) \ -X main.BuildTimestamp='$(TIMESTAMP)' \ -X main.ServerAddress=$(SERVER_ADDRESS)" \ - -o $(BUILD_TARGET) + -o bin/$(BUILD_TARGET) + +bin/: + mkdir -p bin/ ## API Build Targets api_build: build/list_applications.zip build/list_applications.zip: - mkdir -p build/cli + mkdir -p build # A temporary destination is used because we don't want multiple targets run at the same time to conflict - they all have to be named 'bootstrap' TMP_DST=$$(mktemp -d) ;\ GOOS=linux GOARCH=amd64 go build \ @@ -83,7 +85,7 @@ upload: api_upload cli_upload frontend_upload cli_upload: $(CLI_TARGETS) @test $${S3_FRONTEND_BUCKET_NAME?is not set} @test $${RELEASE?is not set} - cd cli/ && \ + cd bin/ && \ aws s3 cp . s3://$(S3_FRONTEND_BUCKET_NAME)-$(RELEASE) --exclude "*" --include "keyconjurer*" --recursive frontend_upload: frontend/dist/index.html