forked from io-craft-org/ephemer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fabfile.py
55 lines (43 loc) · 1.42 KB
/
fabfile.py
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
# encoding: utf-8
"""
Fabfile to drive development and deployment of ephemer
authors : raphael.marvie@beta.gouv.fr, guillaume.libersat@beta.gouv.fr
created : 2021-06-01 09:54:36 CEST
"""
from distutils.core import run_setup
from fabric import task
import ephemer
PACKAGE = f"ephemer-{ephemer.VERSION}.tar.gz"
@task
def upgrade(cnx, site=None):
"""Upgrade requirements to last version on server for site"""
if site not in ["production", "development"]:
print("Usage: fab upgrade --site={production,development} --hosts=...")
return
cnx.put(
"./requirements.txt",
remote=f"./www/ephemer-{site}/requirements.txt",
)
cnx.run(
f"cd www/ephemer-{site} " "&& env/bin/pip install --upgrade -r requirements.txt"
)
@task
def deploy(cnx, site=None):
"""Deploy new version of project to server for site"""
if site not in ["production", "development"]:
print("Usage: fab deploy --site={production,development} --hosts=...")
return
run_setup("setup.py", script_args=["sdist"])
cnx.put(
f"./dist/{PACKAGE}",
remote=f"./www/ephemer-{site}/dist/{PACKAGE}",
)
cnx.run(
f"cd www/ephemer-{site} "
f"&& ./env/bin/pip install ./dist/{PACKAGE}"
"&& ./manage.py migrate"
# "&& env/bin/python3 manage.py compilescss"
"&& ./manage.py collectstatic --noinput"
"&& ./manage.py initcontent"
)
# eof