15027: Cleans up unused imports.
[arvados-workbench2.git] / Makefile
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: Apache-2.0
4
5 # Use bash, and run all lines in each recipe as one shell command
6 SHELL := /bin/bash
7 .ONESHELL:
8
9 APP_NAME?=arvados-workbench2
10
11 # GIT_TAG is the last tagged stable release (i.e. 1.2.0)
12 GIT_TAG?=$(shell git describe --abbrev=0)
13
14 # TS_GIT is the timestamp in the current directory (i.e. 1528815021).
15 # Note that it will only change if files change.
16 TS_GIT?=$(shell git log -n1 --first-parent "--format=format:%ct" .)
17
18 # DATE_FROM_TS_GIT is the human(ish)-readable version of TS_GIT
19 # 1528815021 -> 20180612145021
20 DATE_FROM_TS_GIT?=$(shell date -ud @$(TS_GIT) +%Y%m%d%H%M%S)
21
22 # VERSION uses all the above to produce X.Y.Z.timestamp
23 # something in the lines of 1.2.0.20180612145021, this will be the package version
24 # it can be overwritten when invoking make as in make packages VERSION=1.2.0
25 VERSION?=$(GIT_TAG).$(DATE_FROM_TS_GIT)
26
27 # ITERATION is the package iteration, intended for manual change if anything non-code related
28 # changes in the package. (i.e. example config files externally added
29 ITERATION?=1
30
31 DESCRIPTION=Arvados Workbench2 - Arvados is a free and open source platform for big data science.
32 MAINTAINER=Ward Vandewege <wvandewege@veritasgenetics.com>
33
34 # DEST_DIR will have the build package copied.
35 DEST_DIR=/var/www/arvados-workbench2/workbench2/
36
37 # Debian package file
38 DEB_FILE=$(APP_NAME)_$(VERSION)-$(ITERATION)_amd64.deb
39
40 # redHat package file
41 RPM_FILE=$(APP_NAME)-$(VERSION)-$(ITERATION).x86_64.rpm
42
43 export WORKSPACE?=$(shell pwd)
44
45 .PHONY: help clean* yarn-install test build packages packages-with-version 
46
47 help:
48         @echo >&2
49         @echo >&2 "There is no default make target here.  Did you mean 'make test'?"
50         @echo >&2
51         @echo >&2 "More info:"
52         @echo >&2 "  Installing              --> http://doc.arvados.org/install"
53         @echo >&2 "  Developing/contributing --> https://dev.arvados.org"
54         @echo >&2 "  Project home            --> https://arvados.org"
55         @echo >&2
56         @false
57
58 clean-deb:
59         rm -f $(WORKSPACE)/*.deb
60
61 clean-rpm:
62         rm -f $(WORKSPACE)/*.rpm
63
64 clean-node-modules:
65         rm -rf $(WORKSPACE)/node_modules
66
67 clean: clean-rpm clean-deb clean-node-modules
68
69 yarn-install:
70         yarn install
71
72 test: yarn-install
73         yarn test --no-watchAll --bail --ci
74
75 build: test
76         yarn build
77
78 $(DEB_FILE): build
79         fpm \
80          -s dir \
81          -t deb \
82          -n "$(APP_NAME)" \
83          -v "$(VERSION)" \
84          --iteration "$(ITERATION)" \
85          --vendor="The Arvados Authors" \
86          --maintainer="$(MAINTAINER)" \
87          --url="https://arvados.org" \
88          --license="GNU Affero General Public License, version 3.0" \
89          --description="$(DESCRIPTION)" \
90          --config-files="etc/arvados/workbench2/workbench2.example.json" \
91         $(WORKSPACE)/build/=$(DEST_DIR)
92
93 $(RPM_FILE): build
94         fpm \
95          -s dir \
96          -t rpm \
97          -n "$(APP_NAME)" \
98          -v "$(VERSION)" \
99          --iteration "$(ITERATION)" \
100          --vendor="The Arvados Authors" \
101          --maintainer="$(MAINTAINER)" \
102          --url="https://arvados.org" \
103          --license="GNU Affero General Public License, version 3.0" \
104          --description="$(DESCRIPTION)" \
105          --config-files="etc/arvados/workbench2/workbench2.example.json" \
106          $(WORKSPACE)/build/=$(DEST_DIR)
107
108 copy: $(DEB_FILE) $(RPM_FILE)
109         for target in $(TARGETS); do \
110                 if [[ $$target =~ ^centos ]]; then
111                         cp -p $(RPM_FILE) packages/$$target ; \
112                 else
113                         cp -p $(DEB_FILE) packages/$$target ; \
114                 fi
115         done
116         rm -f $(RPM_FILE)
117         rm -f $(DEB_FILE)
118
119 # use FPM to create DEB and RPM
120 packages: copy