forked from micha/clj-soap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile.docker
90 lines (74 loc) · 2.25 KB
/
makefile.docker
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
# -*- mode: makefile -*-
ifdef BUILD_TARGET_URL
# Tell syringe to load environment from file
export ENV_FILE=.env.ci
CI := true
REPORT_CMD := gh-status-reporter
endif
APP_NAME ?= clj-soap
BUILD_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
BUILD_NUMBER ?= DEV
BUILD_SHA ?= $(shell git rev-parse --verify HEAD)
REPO := rentpath/csi-linkmod
SHORT_BUILD_SHA := $(shell echo $(BUILD_SHA) | head -c 7)
DATE := $(shell date -u "+%Y%m%d")
TAG_NAME := v$(DATE)-$(BUILD_NUMBER)-$(SHORT_BUILD_SHA)
DOCKER_TAG := $(REPO):$(TAG_NAME)
# Build and Release are called by docker's ONBUILD step
build: test uberjar
release: gh_release
clean:
lein clean
deps:
lein deps
test:
BUILD_CONTEXT="ci/test" \
$(REPORT_CMD) lein test
jar:
BUILD_CONTEXT="ci/jar" \
$(REPORT_CMD) lein jar
uberjar: buildinfo
BUILD_CONTEXT="ci/uberjar" \
$(REPORT_CMD) lein with-profile -dev,+uberjar uberjar
buildinfo:
echo "---" > BUILD-INFO
echo "version: $(TAG_NAME)" >> BUILD-INFO
echo "build_number: $(BUILD_NUMBER)" >> BUILD-INFO
echo "git_commit: $(BUILD_SHA)" >> BUILD-INFO
BUILD_CONTEXT="BuildInfo" \
BUILD_DESCRIPTION="Build $(TAG_NAME)" \
$(REPORT_CMD) test -e BUILD-INFO
docker_build:
docker build \
--build-arg BUILD_BRANCH=$(BUILD_BRANCH) \
--build-arg BUILD_AUTH=$(BUILD_AUTH) \
--build-arg BUILD_NUMBER=$(BUILD_NUMBER) \
--build-arg BUILD_ORG_REPO=$(REPO) \
--build-arg BUILD_SHA=$(BUILD_SHA) \
--build-arg BUILD_TARGET_URL=$(BUILD_URL) \
-t $(DOCKER_TAG) .
docker_push:
docker push $(DOCKER_TAG)
docker_rmi:
docker rmi $(DOCKER_TAG)
gh_release:
ifeq ($(BUILD_BRANCH),master)
ifdef CI
TAG_NAME=$(TAG_NAME) \
BUILD_CONTEXT="ci/github-release" \
$(REPORT_CMD) script/github_release
endif
else
@echo "Current Branch - ${BUILD_BRANCH}"
@echo "Not on the CI server and master, so not creating a GitHub release."
endif
clojars_deploy:
ifeq ($(BUILD_BRANCH),master)
TAG_NAME=$(TAG_NAME) \
BUILD_CONTEXT="ci/clojars-deploy" \
$(REPORT_CMD) lein deploy
else
@echo "Current Branch - ${BUILD_BRANCH}"
@echo "Not on the CI server and master, so not creating a GitHub release."
endif
.PHONY: clean deps test uberjar build buildinfo docker_build docker_push docker_rmi gh_release release