move zipping the daemon to separate script
This commit is contained in:
parent
135742c87e
commit
05f94a95ed
6 changed files with 73 additions and 35 deletions
|
@ -38,13 +38,16 @@ build_script:
|
|||
# build electron app
|
||||
- node_modules\.bin\build -p never
|
||||
# for debugging, see what was built
|
||||
- python zip_daemon.py
|
||||
- dir dist
|
||||
- pip install PyGithub uritemplate
|
||||
- python release_on_tag.py
|
||||
|
||||
test: off
|
||||
|
||||
|
||||
artifacts:
|
||||
- path: dist\*.exe
|
||||
name: LBRY
|
||||
|
||||
- path: dist\*.zip
|
||||
name: lbrynet-daemon
|
||||
|
|
1
build.sh
1
build.sh
|
@ -72,6 +72,7 @@ if [ "$FULL_BUILD" == "true" ]; then
|
|||
fi
|
||||
|
||||
node_modules/.bin/build -p never
|
||||
python zip_daemon.py
|
||||
|
||||
echo 'Build and packaging complete.'
|
||||
else
|
||||
|
|
22
release.py
22
release.py
|
@ -71,12 +71,18 @@ def main():
|
|||
|
||||
# ensure that we have changelog entries for each part
|
||||
for repo in repos:
|
||||
if not repo.has_changes():
|
||||
continue
|
||||
entry = repo.get_changelog_entry().strip()
|
||||
if not entry:
|
||||
raise Exception('Changelog is missing for {}'.format(repo.name))
|
||||
changelogs[repo.name] = entry
|
||||
if repo.has_changes():
|
||||
entry = repo.get_changelog_entry().strip()
|
||||
if not entry:
|
||||
raise Exception('Changelog is missing for {}'.format(repo.name))
|
||||
changelogs[repo.name] = entry
|
||||
else:
|
||||
log.warning('Submodule %s has no changes.', repo.name)
|
||||
if repo.name == 'lbryum':
|
||||
# The other repos have their version track each other so need to bump
|
||||
# them even if there aren't any changes, but lbryum should only be
|
||||
# bumped if it has changes
|
||||
continue
|
||||
part = get_part(args, repo.name)
|
||||
if not part:
|
||||
raise Exception('Cannot bump version for {}: no part specified'.format(repo.name))
|
||||
|
@ -207,4 +213,8 @@ def pushd(new_dir):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
log = logging.getLogger('release')
|
||||
logging.basicConfig("%(asctime)s %(levelname)-8s %(name)s:%(lineno)d: %(message)s")
|
||||
sys.exit(main())
|
||||
else:
|
||||
log = logging.getLogger('__name__')
|
||||
|
|
|
@ -7,7 +7,7 @@ import platform
|
|||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import zipfile
|
||||
|
||||
|
||||
import github
|
||||
import requests
|
||||
|
@ -40,16 +40,13 @@ def main(args=None):
|
|||
# TODO: maybe this should be an error
|
||||
return
|
||||
|
||||
artifact = get_artifact()
|
||||
app = get_app_artifact()
|
||||
release = get_release(app_repo, current_tag)
|
||||
upload_asset(release, artifact, gh_token)
|
||||
upload_asset(release, app, gh_token)
|
||||
|
||||
daemon = get_daemon_artifact()
|
||||
release = get_release(daemon_repo, current_tag)
|
||||
artifact = os.path.join('app', 'dist', 'lbrynet-daemon')
|
||||
if platform.system() == 'Windows':
|
||||
artifact += '.exe'
|
||||
asset_to_upload = get_asset(artifact, get_system_label())
|
||||
upload_asset(release, asset_to_upload, gh_token)
|
||||
upload_asset(release, daemon, gh_token)
|
||||
|
||||
|
||||
def check_repo_has_tag(repo, target_tag):
|
||||
|
@ -67,7 +64,7 @@ def get_release(current_repo, current_tag):
|
|||
raise Exception('No release for {} was found'.format(current_tag))
|
||||
|
||||
|
||||
def get_artifact():
|
||||
def get_app_artifact():
|
||||
system = platform.system()
|
||||
if system == 'Darwin':
|
||||
return glob.glob('dist/mac/LBRY*.dmg')[0]
|
||||
|
@ -79,22 +76,8 @@ def get_artifact():
|
|||
raise Exception("I don't know about any artifact on {}".format(system))
|
||||
|
||||
|
||||
def get_system_label():
|
||||
system = platform.system()
|
||||
if system == 'Darwin':
|
||||
return 'macOS'
|
||||
else:
|
||||
return system
|
||||
|
||||
|
||||
def get_asset(filename, label):
|
||||
label = '-{}'.format(label)
|
||||
base, ext = os.path.splitext(filename)
|
||||
# TODO: probably want to clean this up
|
||||
zipfilename = '{}{}.zip'.format(base, label)
|
||||
with zipfile.ZipFile(zipfilename, 'w') as myzip:
|
||||
myzip.write(filename)
|
||||
return zipfilename
|
||||
def get_daemon_artifact():
|
||||
return glob.glob('dist/*.zip')[0]
|
||||
|
||||
|
||||
def upload_asset(release, asset_to_upload, token):
|
||||
|
@ -105,9 +88,11 @@ def upload_asset(release, asset_to_upload, token):
|
|||
release.upload_url, {'name': basename})
|
||||
# using requests.post fails miserably with SSL EPIPE errors. I spent
|
||||
# half a day trying to debug before deciding to switch to curl.
|
||||
#
|
||||
# TODO: actually set the content type
|
||||
cmd = [
|
||||
'curl', '-sS', '-X', 'POST', '-u', ':{}'.format(os.environ['GH_TOKEN']),
|
||||
'--header', 'Content-Type:application/zip',
|
||||
'--header', 'Content-Type:application/octet-stream',
|
||||
'--data-binary', '@{}'.format(asset_to_upload), upload_uri
|
||||
]
|
||||
raw_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
|
||||
|
@ -128,7 +113,7 @@ def is_asset_already_uploaded(release, basename):
|
|||
|
||||
if __name__ == '__main__':
|
||||
log = logging.getLogger('release-on-tag')
|
||||
log_support.configure_console(level='DEBUG')
|
||||
log_support.configure_console(level='INFO')
|
||||
sys.exit(main())
|
||||
else:
|
||||
log = logging.getLogger(__name__)
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
import argparse
|
||||
import json
|
||||
import os.path
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
@ -11,10 +12,22 @@ def main():
|
|||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--version', help="defaults to the output of `git describe`")
|
||||
args = parser.parse_args()
|
||||
version = args.version or subprocess.check_output(['git', 'describe']).strip()
|
||||
if args.version:
|
||||
version = args.version
|
||||
else:
|
||||
tag = subprocess.check_output(['git', 'describe']).strip()
|
||||
version = get_version_from_tag(tag)
|
||||
set_version(version)
|
||||
|
||||
|
||||
def get_version_from_tag(tag):
|
||||
match = re.match('v([\d.]+)', tag)
|
||||
if match:
|
||||
return match.group(1)
|
||||
else:
|
||||
raise Exception('Failed to parse version from tag {}'.format(tag))
|
||||
|
||||
|
||||
def set_version(version):
|
||||
package_file = os.path.join('app', 'package.json')
|
||||
with open(package_file) as fp:
|
||||
|
|
26
zip_daemon.py
Normal file
26
zip_daemon.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
import os
|
||||
import platform
|
||||
import sys
|
||||
import zipfile
|
||||
|
||||
|
||||
def main():
|
||||
zipfilename = 'lbrynet-daemon-{}.zip'.format(get_system_label())
|
||||
full_filename = os.path.join('dist', zipfilename)
|
||||
executable = 'lbrynet-daemon'
|
||||
if platform.system() == 'Windows':
|
||||
executable += '.exe'
|
||||
with zipfile.ZipFile(full_filename, 'w') as myzip:
|
||||
myzip.write(os.path.join('app', 'dist', executable), executable)
|
||||
|
||||
|
||||
def get_system_label():
|
||||
system = platform.system()
|
||||
if system == 'Darwin':
|
||||
return 'macOS'
|
||||
else:
|
||||
return system
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
Loading…
Add table
Reference in a new issue