Add release task

This commit is contained in:
Lance Edgar 2024-06-08 15:16:02 -05:00
parent 5a584982e4
commit 32cfafc88a

35
tasks.py Normal file
View file

@ -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'")