-
Notifications
You must be signed in to change notification settings - Fork 15
/
Makefile
55 lines (45 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
REGISTRY = $(DOCKER_REGISTRY)
RELEASE = $(RELEASE_VERSION)
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
BINARY_NAME=ritchie-server
CMD_PATH=./server/cmd/server/main.go
GIT_REMOTE=https://$(GIT_USERNAME):$(GIT_PASSWORD)@github.com/ZupIT/ritchie-server
# Docker
DOCKERCMD=docker
DOCKERBUILD=${DOCKERCMD} build
DOCKERPUSH=${DOCKERCMD} push
DOCKERTAG=${DOCKERCMD} tag
all: test build
build:
GOOS=linux GOARCH=amd64 ${GOBUILD} -o ./${BINARY_NAME} -v ${CMD_PATH}
cp $(BINARY_NAME) server
$(DOCKERBUILD) -t "${REGISTRY}/${BINARY_NAME}:${RELEASE}" ./server
# $(DOCKERTAG) "${REGISTRY}/${BINARY_NAME}:${RELEASE}" "${REGISTRY}/${BINARY_NAME}:latest"
rm go.sum ritchie-server
build-local-mac:
GOOS=darwin GOARCH=amd64 ${GOBUILD} -o ./${BINARY_NAME} -v ${CMD_PATH}
build-local:
${GOBUILD} -o ./${BINARY_NAME} -v ${CMD_PATH}
publish:
${DOCKERPUSH} "${REGISTRY}/${BINARY_NAME}:${RELEASE}"
# ${DOCKERPUSH} "${REGISTRY}/${BINARY_NAME}:latest"
test:
DOCKER_REGISTRY_BUILDER=${REGISTRY} docker-compose -f docker-compose-ci.yml run server
test-local:
docker-compose up -d
./run-tests.sh
docker-compose down
release:
git config --global user.email "$(GIT_EMAIL)"
git config --global user.name "$(GIT_USER)"
git add .
git commit --allow-empty -m "release"
git push $(GIT_REMOTE) HEAD:release-$(RELEASE_VERSION)
git tag -a $(RELEASE_VERSION) -m "release"
git push $(GIT_REMOTE) $(RELEASE_VERSION)
curl --user $(GIT_USERNAME):$(GIT_PASSWORD) -X POST https://api.github.com/repos/ZupIT/ritchie-server/pulls -H 'Content-Type: application/json' -d '{ "title": "Release $(RELEASE_VERSION) merge", "body": "Release $(RELEASE_VERSION) merge with master", "head": "release-$(RELEASE_VERSION)", "base": "master" }'