forked from helxplatform/tycho
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
58 lines (46 loc) · 1.92 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
SHELL := /bin/bash
BRANCH_NAME := $(shell git branch --show-current | sed -r 's/[/]+/_/g')
override VERSION := ${BRANCH_NAME}-${VER}
PYTHON := python3
DOCKER_REPO = docker.io
DOCKER_OWNER = helxplatform
DOCKER_APP = tycho-api
DOCKER_TAG = ${VERSION}
DOCKER_IMAGE = ${DOCKER_OWNER}/${DOCKER_APP}:$(DOCKER_TAG)
.DEFAULT_GOAL = help
.PHONY: help init clean install test build image publish
version:
${PYTHON} --version
echo ${VERSION}
#help: List available tasks on this project
help:
@grep -E '^#[a-zA-Z\.\-]+:.*$$' $(MAKEFILE_LIST) | tr -d '#' | awk 'BEGIN {FS = ": "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
#init: Initialize the repository with things like git commit hooks
init:
git --version
@echo "Please make sure your git version is greater than 2.9.0. If it's not, this command will fail."
git config --local core.hooksPath .githooks/
clean:
${PYTHON} -m pip uninstall -y tycho-api
${PYTHON} -m pip uninstall -y -r requirements.txt
install:
${PYTHON} -m pip install --upgrade pip
${PYTHON} -m pip install --upgrade wheel
${PYTHON} -m pip install --upgrade setuptools
${PYTHON} -m pip install -r requirements.txt
${PYTHON} -m pip install .
#test: Run all tests
test:
# ${PYTHON} -m flake8 src
${PYTHON} -m pytest tests
package.build: ${PYTHON} -m build
package.release:
${PYTHON} -m twine upload dist/*
rm -rf dist
build:
@if [ -z "$(VER)" ]; then echo "Please provide a value for the VER variable like this:"; echo "make VER=4 <target>"; false; fi;
docker build -t ${DOCKER_IMAGE} -f Dockerfile .
publish: build
@if [ -z "$(VER)" ]; then echo "Please provide a value for the VER variable like this:"; echo "make VER=4 <target>"; echo "Here are the images you have already built that can be published:" ; docker images | grep "IMAGE ID"; docker images | grep "${DOCKER_OWNER}/${DOCKER_APP}"; false; fi;
docker tag ${DOCKER_IMAGE} ${DOCKER_REPO}/${DOCKER_IMAGE}
docker push ${DOCKER_REPO}/${DOCKER_IMAGE}