Skip to content
Closed
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
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
steps:
- checkout
# Compile, and make sure it's not dynamically linked.
- run: make bin/ssm-env && ! ldd bin/ssm-env
- run: make && ! ldd bin/ssm-env-linux-amd64
- store_artifacts:
path: bin/ssm-env
path: bin
destination: ssm-env
31 changes: 26 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,37 @@
.DEFAULT_GOAL := bin/ssm-env
.DEFAULT_GOAL := all

VERSION := $(shell git describe --tags --match 'v*')
APP_NAME := ssm-env
OUTPUT_DIR := bin
CGO_ENABLED ?= 0
ARGS :=
PLATFORMS := linux/amd64 linux/arm64 darwin/amd64 darwin/arm64 windows/amd64

version := $(shell git describe --tags --match 'v*')
all: clean build

build:
@mkdir -p $(OUTPUT_DIR)
@echo "Building $(APP_NAME) for multiple platforms..."
@for platform in $(PLATFORMS); do \
GOOS=$$(echo $$platform | cut -d'/' -f1); \
GOARCH=$$(echo $$platform | cut -d'/' -f2); \
echo "Building for $$GOOS/$$GOARCH..."; \
BIN_NAME=$(OUTPUT_DIR)/$(APP_NAME)-$$GOOS-$$GOARCH$$( [ "$$GOOS" = "windows" ] && echo .exe ); \
CGO_ENABLED=$(CGO_ENABLED) GOOS=$$GOOS GOARCH=$$GOARCH go build -o $$BIN_NAME -ldflags "-X main.version=$(VERSION)" . || exit 1; \
done
@echo "Build completed."

.PHONY: run
run:
CGO_ENABLED=0 go run -ldflags "-X main.version=$(version)" . $(ARGS)
CGO_ENABLED=$(CGO_ENABLED) go run -ldflags "-X main.version=$(VERSION)" . $(ARGS)

bin/ssm-env: *.go
CGO_ENABLED=0 go build -ldflags "-X main.version=$(version)" -o $@ .
.PHONY: clean
clean:
rm -rf $(OUTPUT_DIR)
@echo "Cleaned build artifacts."

.PHONY: test
test:
go test -race $(shell go list ./... | grep -v /vendor/)

.PHONY: all build clean test