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