Merge pull request #469 from lbryio/build-fixes

Fix build and release system to store all daemon version settings in app/package.json
This commit is contained in:
Jeremy Kauffman 2017-08-10 22:47:41 -04:00 committed by GitHub
commit ce0dd5ae62
5 changed files with 33 additions and 21 deletions

View file

@ -20,6 +20,7 @@
"electron-rebuild": "^1.5.11" "electron-rebuild": "^1.5.11"
}, },
"lbrySettings": { "lbrySettings": {
"lbrynetDaemonVersion": "0.14.2" "lbrynetDaemonVersion": "0.14.2",
"lbrynetDaemonUrlTemplate": "https://github.com/lbryio/lbry/releases/download/vDAEMONVER/lbrynet-daemon-vDAEMONVER-OSNAME.zip"
} }
} }

View file

@ -1 +0,0 @@
https://github.com/lbryio/lbry/releases/download/v0.14.2/lbrynet-daemon-v0.14.2-OSNAME.zip

View file

@ -29,7 +29,10 @@ cd ..
# get daemon and cli executable # get daemon and cli executable
$daemon_url = (Get-Content build\DAEMON_URL -Raw).replace("OSNAME", "windows") $package_settings = (Get-Content app\package.json -Raw | ConvertFrom-Json).lbrySettings
$daemon_ver = $package_settings.lbrynetDaemonVersion
$daemon_url_template = $package_settings.lbrynetDaemonUrlTemplate
$daemon_url = $daemon_url_template.Replace('OSNAME', 'windows').Replace('DAEMONVER', $daemon_ver)
Invoke-WebRequest -Uri $daemon_url -OutFile daemon.zip Invoke-WebRequest -Uri $daemon_url -OutFile daemon.zip
Expand-Archive daemon.zip -DestinationPath app\dist\ Expand-Archive daemon.zip -DestinationPath app\dist\
dir app\dist\ # verify that daemon binary is there dir app\dist\ # verify that daemon binary is there

View file

@ -80,7 +80,8 @@ else
OSNAME="linux" OSNAME="linux"
fi fi
DAEMON_VER=$(node -e "console.log(require(\"$ROOT/app/package.json\").lbrySettings.lbrynetDaemonVersion)") DAEMON_VER=$(node -e "console.log(require(\"$ROOT/app/package.json\").lbrySettings.lbrynetDaemonVersion)")
DAEMON_URL="https://github.com/lbryio/lbry/releases/download/v${DAEMON_VER}/lbrynet-daemon-v${DAEMON_VER}-${OSNAME}.zip" DAEMON_URL_TEMPLATE=$(node -e "console.log(require(\"$ROOT/app/package.json\").lbrySettings.lbrynetDaemonUrlTemplate)")
DAEMON_URL=$(echo ${DAEMON_URL_TEMPLATE//DAEMONVER/$DAEMON_VER} | sed "s/OSNAME/$OSNAME/g")
wget --quiet "$DAEMON_URL" -O "$BUILD_DIR/daemon.zip" wget --quiet "$DAEMON_URL" -O "$BUILD_DIR/daemon.zip"
unzip "$BUILD_DIR/daemon.zip" -d "$ROOT/app/dist/" unzip "$BUILD_DIR/daemon.zip" -d "$ROOT/app/dist/"
rm "$BUILD_DIR/daemon.zip" rm "$BUILD_DIR/daemon.zip"

View file

@ -5,6 +5,7 @@ This script should be run locally, not on a build server.
import argparse import argparse
import contextlib import contextlib
import os import os
import json
import re import re
import requests import requests
import subprocess import subprocess
@ -16,7 +17,7 @@ import github
import changelog import changelog
ROOT = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) ROOT = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
DAEMON_URL_FILE = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'DAEMON_URL') APP_PACKAGE_JSON_FILE = os.path.join(ROOT, 'app', 'package.json')
def main(): def main():
@ -38,11 +39,11 @@ def main():
print 'Current version: {}'.format(repo.current_version) print 'Current version: {}'.format(repo.current_version)
print 'New version: {}'.format(repo.new_version) print 'New version: {}'.format(repo.new_version)
with open(DAEMON_URL_FILE, 'r') as f: with open(APP_PACKAGE_JSON_FILE, 'r') as f:
daemon_url_template = f.read().strip() package_settings = json.load(f)['lbrySettings']
daemon_version = re.search('/(?P<version>v[^/]+)', daemon_url_template) daemon_url_template = package_settings['lbrynetDaemonUrlTemplate']
print 'Daemon version: {} ({})'.format( daemon_version = package_settings['lbrynetDaemonVersion']
daemon_version.group('version'), daemon_url_template) print 'Daemon version: {} ({})'.format(daemon_version, daemon_url_template.replace('DAEMONVER', daemon_version))
if not args.confirm and not confirm(): if not args.confirm and not confirm():
print "Aborting" print "Aborting"
@ -190,18 +191,25 @@ def run_sanity_checks(repo, branch):
def check_daemon_urls(): def check_daemon_urls():
success = True with open(APP_PACKAGE_JSON_FILE, 'r') as f:
with open(DAEMON_URL_FILE, 'r') as f: package_settings = json.load(f)['lbrySettings']
daemon_url_template = f.read().strip()
if "OSNAME" not in daemon_url_template:
print "Daemon URL must include the string 'OSNAME'"
return False
for osname in ('linux', 'macos', 'windows'):
if not check_url(daemon_url_template.replace('OSNAME', osname)):
success = False
print "Daemon URL for " + osname + " does not work"
return success
daemon_url_template = package_settings['lbrynetDaemonUrlTemplate']
daemon_version = package_settings['lbrynetDaemonVersion']
if "OSNAME" not in daemon_url_template:
print "Daemon URL must include the string \"OSNAME\""
return False
elif "DAEMONVER" not in daemon_url_template:
print "Daemon URL must include the string \"DAEMONVER\""
return False
for osname in ('linux', 'macos', 'windows'):
if not check_url(daemon_url_template.replace('DAEMONVER', daemon_version).replace('OSNAME', osname)):
print "Daemon URL for", osname, " does not work"
return False
return True
def check_url(url): def check_url(url):
url = url.strip() url = url.strip()