-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
56 lines (46 loc) · 1.74 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
HAS_DOCKER := $(shell command -v docker;)
HAS_BUILDPACKS := $(shell command -v pack;)
OWNER := shihyuho
REPO := go-jenkins-trigger
PACK_BUILDER ?= paketobuildpacks/builder:tiny
# GitHub PAT with write:packages scope: https://github.com/settings/tokens
GH_PAT ?=
# Image tag: https://github.com/shihyuho/go-jenkins-trigger/pkgs/container/go-jenkins-trigger
TAG ?= latest
##@ General
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
bootstrap: ## Bootstrap project
go mod download
govet: ## # Run go vet
go vet
gofmt: ## # Run gofmt
gofmt -s -w main.go
##@ Delivery
pack: bootstrap govet gofmt ## Create a runnable app image from source code
ifndef HAS_DOCKER
$(error Docker is required: https://www.docker.com/)
endif
ifndef HAS_BUILDPACKS
$(error Buildpacks is required: https://buildpacks.io/)
endif
ifeq ($(strip $(TAG)),)
$(error TAG is required)
endif
pack build ghcr.io/$(OWNER)/$(REPO):$(TAG) --builder $(PACK_BUILDER)
cr-login: ## To authenticate to the Container registry
ifndef HAS_DOCKER
$(error Docker is required: https://www.docker.com/)
endif
ifeq ($(strip $(GH_PAT)),)
$(error GH_PAT is required: https://github.com/settings/tokens)
endif
echo $(GH_PAT) | docker login ghcr.io -u $(OWNER) --password-stdin
publish: bootstrap govet gofmt cr-login ## Create a runnable app image from source code and Publish to registry
ifndef HAS_BUILDPACKS
$(error Buildpacks is required: https://buildpacks.io/)
endif
ifeq ($(strip $(TAG)),)
$(error TAG is required)
endif
pack build ghcr.io/$(OWNER)/$(REPO):$(TAG) --builder $(PACK_BUILDER) --publish