-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
55 lines (43 loc) · 1.33 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
BINARY_NAME = kado
VERSION_FILE = VERSION
PYTHON_SCRIPT = bump_version.py
VERSION := $(shell cat $(VERSION_FILE))
GITHUB_USERNAME = janpreet
GITHUB_REPOSITORY = kado
DOCKER_IMAGE = ghcr.io/janpreet/kado
GOARCHES = amd64 arm64
build-all:
@for os in $(GOOSES); do \
for arch in $(GOARCHES); do \
if [ "$$os" != "windows" ] || [ "$$arch" != "arm64" ]; then \
echo "Building for $$os/$$arch"; \
GOOS=$$os GOARCH=$$arch go build -o $(BINARY_NAME)-$$os-$$arch$(if $(filter windows,$$os),.exe,) .; \
fi; \
done; \
done
build:
go build -o $(BINARY_NAME) .
docker-build: build
docker build -t $(DOCKER_IMAGE):latest -t $(DOCKER_IMAGE):$(VERSION) .
docker-push:
docker push $(DOCKER_IMAGE):latest
docker push $(DOCKER_IMAGE):$(VERSION)
version-bump:
python3 $(PYTHON_SCRIPT)
tag-and-push: version-bump
git add $(VERSION_FILE)
git commit -m "Bump version to $(VERSION)"
git tag v$(VERSION)
git push origin main --tags
clean:
rm -f $(BINARY_NAME)*
test:
go test ./...
all: clean build-all docker-build docker-push tag-and-push
github-release:
@echo "Creating GitHub release for v$(VERSION)"
@gh release create v$(VERSION) \
--title "Release $(VERSION)" \
--notes "Release notes for version $(VERSION)" \
$(BINARY_NAME)-*
.PHONY: build-all build docker-build docker-push version-bump tag-and-push clean test all github-release