Merge branch 'master' into 14313-basic-view-recent-queries
[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 --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          --maintainer="$(MAINTAINER)" \
86          --description="$(DESCRIPTION)" \
87          --config-files="etc/arvados/workbench2/workbench2.example.json" \
88         $(WORKSPACE)/build/=$(DEST_DIR)
89
90 $(RPM_FILE): build
91         fpm \
92          -s dir \
93          -t rpm \
94          -n "$(APP_NAME)" \
95          -v "$(VERSION)" \
96          --iteration "$(ITERATION)" \
97          --maintainer="$(MAINTAINER)" \
98          --description="$(DESCRIPTION)" \
99          --config-files="etc/arvados/workbench2/workbench2.example.json" \
100          $(WORKSPACE)/build/=$(DEST_DIR)
101
102 copy: $(DEB_FILE) $(RPM_FILE)
103         for target in $(TARGETS); do \
104                 if [[ $$target =~ ^centos ]]; then
105                         cp -p $(RPM_FILE) packages/$$target ; \
106                 else
107                         cp -p $(DEB_FILE) packages/$$target ; \
108                 fi
109         done
110         rm -f $(RPM_FILE)
111         rm -f $(DEB_FILE)
112
113 # use FPM to create DEB and RPM
114 packages: copy