Skip to content

Commit

Permalink
Put binaries in bin/
Browse files Browse the repository at this point in the history
  • Loading branch information
punmechanic committed Nov 12, 2024
1 parent 1277d79 commit bfa112f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,4 @@ cli/keyconjurer-darwin*
cli/keyconjurer-linux*
cli/keyconjurer-windows.exe
vendor
bin/
44 changes: 23 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -32,43 +32,45 @@ 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) \
-X main.ClientID=$(CLIENT_ID) \
-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 \
Expand All @@ -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
Expand Down

0 comments on commit bfa112f

Please sign in to comment.