Skip to content
Open
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
12 changes: 6 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
version: 2.1

defaults: &defaults
docker:
- image: circleci/golang:1.16
- image: cimg/go:1.24

workflows:
version: 2
build-and-test:
jobs:
- test
Expand All @@ -13,13 +14,12 @@ jobs:
!!merge <<: *defaults
steps:
- checkout
- run: make test
- run: make lint test
build:
!!merge <<: *defaults
steps:
- checkout
# Compile, and make sure it's not dynamically linked.
- run: make bin/ssm-env && ! ldd bin/ssm-env
- run: make dist
- store_artifacts:
path: bin/ssm-env
destination: ssm-env
path: _dist
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
bin
/bin
/ssm-env
/_dist
46 changes: 36 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,42 @@
.DEFAULT_GOAL := bin/ssm-env
name := ssm-env
version := $(shell git describe --tags --match 'v*' HEAD)
ldflags := -X main.version=$(VERSION)

ARGS :=
ssm-env: *.go
CGO_ENABLED=0 go build -ldflags "$(ldflags)" -o $@ .

version := $(shell git describe --tags --match 'v*')
.PHONY: fmt
fmt:
go fmt ./...

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

bin/ssm-env: *.go
CGO_ENABLED=0 go build -ldflags "-X main.version=$(version)" -o $@ .
.PHONY: lint
lint:
@test -z $(shell gofmt -l . | tee /dev/stderr) || { echo "files above are not go fmt"; exit 1; }
go vet ./...

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

.PHONY: clean
clean:
rm -rf ssm-env
rm -rf _dist

dist_os_arch := \
linux-amd64 \
linux-arm64 \
darwin-amd64 \
darwin-arm64

dists := $(dist_os_arch:%=_dist/$(name)-%)

.PHONY: dist $(dists)
dist: $(dists)

$(dists): _dist/$(name)-%:
mkdir -p _dist
CGO_ENABLED=0 \
GOOS=$(word 1,$(subst -, ,$*)) \
GOARCH=$(word 2,$(subst -, ,$*)) \
go build -ldflags "$(ldflags)" -o $@ .