diff --git a/tasks.py b/tasks.py new file mode 100644 index 0000000..44c4c94 --- /dev/null +++ b/tasks.py @@ -0,0 +1,35 @@ +# -*- coding: utf-8; -*- +""" +Tasks for myweather +""" + +import os +import json + +from invoke import task + + +here = os.path.dirname(__file__) + + +@task +def release(c): + """ + Release a new version of myweather + """ + # figure out current package version + package_json = os.path.join(here, 'package.json') + with open(package_json, 'rt') as f: + js = json.load(f) + version = js['version'] + + # build the app, create zip archive + c.run('npm run build') + os.chdir('dist') + filename = f'myweather-{version}.zip' + c.run(f'zip --recurse-paths {filename} *') + os.chdir(os.pardir) + + # upload zip archive to server + c.run(f'scp dist/{filename} weather.edbob.org:/srv/myweather/releases/{filename}') + c.run(f"ssh weather.edbob.org 'cd /srv/myweather/releases; ln -sf {filename} latest.zip'")