This repository has been archived by the owner on Jan 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
90 lines (72 loc) · 2.22 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
IMAGE_NAME := theeadie/nest-exporter
PLATFORMS := linux/amd64,linux/arm64
NEXT_VERSION := 2.0
TAG_PREFIX :=
GITHUB_REPO := theeadie/nest-exporter
GITHUB_AUTH_TOKEN := empty
VERSION := $(shell ./build/version.sh $(NEXT_VERSION))
VERSION_MAJOR := $(word 1,$(subst ., ,$(VERSION)))
VERSION_MINOR := $(word 2,$(subst ., ,$(VERSION)))
VERSION_PATCH := $(word 2,$(subst ., ,$(VERSION)))
.PHONY: default build test
## Build
default: publish-local
publish-local:
@docker buildx build . \
-t $(IMAGE_NAME):$(VERSION)-dev \
--build-arg VERSION=$(VERSION) \
--load
build-local:
@docker buildx build . \
-t $(IMAGE_NAME):$(VERSION)-build \
--build-arg VERSION=$(VERSION) \
--target build \
--load \
--cache-from=type=gha,scope=build-local \
--cache-from=type=gha,scope=build \
--cache-to=type=gha,mode=max,scope=build-local
build:
@docker buildx build . \
-t $(IMAGE_NAME):$(VERSION)-build \
--build-arg VERSION=$(VERSION) \
--target build \
--platform $(PLATFORMS) \
--cache-from=type=gha,scope=build \
--cache-to=type=gha,mode=max,scope=build
test: build-local
@docker run --rm -i $(IMAGE_NAME):$(VERSION)-build dotnet test
publish:
@docker buildx build . \
-t $(IMAGE_NAME):$(VERSION) \
--build-arg VERSION=$(VERSION) \
--platform $(PLATFORMS) \
--cache-from=type=gha,scope=publish \
--cache-from=type=gha,scope=build \
--cache-to=type=gha,mode=max,scope=publish
start:
@docker-compose build --build-arg VERSION=$(VERSION)
@docker-compose up --build -d
stop:
@docker-compose down
version:
@echo $(VERSION)
lint: | lint-dockerfile lint-sh
lint-dockerfile:
@docker run --rm -i hadolint/hadolint:v2.12.0 < Dockerfile
lint-sh:
@docker run --rm -i -v "$(PWD):/mnt" koalaman/shellcheck:v0.9.0 **/*.sh
## Release
release: | docker-push github-release
docker-push:
@docker buildx build . \
-t $(IMAGE_NAME):latest \
-t $(IMAGE_NAME):$(VERSION) \
-t $(IMAGE_NAME):$(VERSION_MAJOR) \
-t $(IMAGE_NAME):$(VERSION_MAJOR).$(VERSION_MINOR) \
--build-arg VERSION=$(VERSION) \
--platform $(PLATFORMS) \
--push \
--cache-from=type=gha,scope=publish \
--cache-to=type=gha,mode=max,scope=publish
github-release:
@./build/github-release.sh $(VERSION) $(TAG_PREFIX)$(VERSION) $(GITHUB_AUTH_TOKEN) $(GITHUB_REPO)