Fix upgrade script to support CI builds

This commit is contained in:
Arik Fraimovich
2018-02-08 11:35:12 +02:00
parent 943dcf1da3
commit 5e97834b80

View File

@@ -1,9 +1,9 @@
#!/usr/bin/env python
import urllib
import argparse
import os
import subprocess
import sys
import urllib
from collections import namedtuple
from fnmatch import fnmatch
@@ -75,14 +75,13 @@ class Release(namedtuple('Release', ('version', 'download_url', 'filename', 'des
def get_latest_release_from_ci():
response = requests.get('https://circleci.com/api/v1.1/project/github/getredash/redash/latest/artifacts')
response = requests.get('https://circleci.com/api/v1.1/project/github/getredash/redash/latest/artifacts?branch=master')
if response.status_code != 200:
exit("Failed getting releases (status code: %s)." % response.status_code)
tarball_asset = filter(lambda asset: asset['url'].endswith('.tar.gz'), response.json())[0]
filename = tarball_asset['pretty_path'].replace('$CIRCLE_ARTIFACTS/', '')
filename = os.path.basename(urllib.unquote(filename))
filename = urllib.unquote(tarball_asset['pretty_path'].split('/')[-1])
version = filename.replace('redash.', '').replace('.tar.gz', '')
release = Release(version, tarball_asset['url'], filename, '')
@@ -205,8 +204,10 @@ def show_description_and_confirm(description):
def verify_newer_version(release):
if not release.is_newer(current_version()):
red("The found release is not newer than your current deployed release ({}). Aborting upgrade.".format(current_version()))
exit(1)
red("The found release is not newer than your current deployed release ({}).".format(current_version()))
if not confirm("Continue with upgrade?"):
red("Cancelling upgrade.")
exit(1)
def deploy_release(channel):