Compare commits
57
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
498534a61e | ||
|
|
01e19a457b | ||
|
|
105f234d2c | ||
|
|
18cd7608e3 | ||
|
|
9e7ca7c9f8 | ||
|
|
0c77644861 | ||
|
|
26f5d08567 | ||
|
|
d1c308181b | ||
|
|
ed053552c8 | ||
|
|
c03eb3b736 | ||
|
|
7d1bfb4c35 | ||
|
|
01955c312c | ||
|
|
be9d99f482 | ||
|
|
5c1803aaf8 | ||
|
|
9504be7146 | ||
|
|
eda71a50ff | ||
|
|
8234d6cc25 | ||
|
|
605c0eb8ab | ||
|
|
d19e436d04 | ||
|
|
c159f214ab | ||
|
|
48b665a3be | ||
|
|
3d46983500 | ||
|
|
05f94a95ed | ||
|
|
135742c87e | ||
|
|
c7cea9c94f | ||
|
|
77ce04b377 | ||
|
|
e28fab0696 | ||
|
|
b5fcc126d8 | ||
|
|
a9b32bac9f | ||
|
|
b03f652d5e | ||
|
|
48e9226cac | ||
|
|
4a68835bba | ||
|
|
25febd1880 | ||
|
|
5d55af0a77 | ||
|
|
4e431dc6fd | ||
|
|
445033f34a | ||
|
|
c0b34fe119 | ||
|
|
47c88a7604 | ||
|
|
6a95a37266 | ||
|
|
de5ecbe4a1 | ||
|
|
7b13e8e65a | ||
|
|
2a94a56765 | ||
|
|
abf1e49abe | ||
|
|
bd1bd96e5e | ||
|
|
980b1f710c | ||
|
|
4e2e2abe0f | ||
|
|
f09bf620b2 | ||
|
|
0f65170361 | ||
|
|
2af80c69ae | ||
|
|
7b1dc2c5a0 | ||
|
|
f6a28df636 | ||
|
|
592a48e412 | ||
|
|
5b95a3ab9d | ||
|
|
48cfdb1ab8 | ||
|
|
4763d29a4c | ||
|
|
9a21135223 | ||
|
|
3e49fd3758 |
No files matched your search
@@ -0,0 +1,17 @@
|
||||
[bumpversion]
|
||||
current_version = 0.9.0rc10
|
||||
commit = True
|
||||
tag = True
|
||||
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)((?P<release>[a-z]+)(?P<candidate>\d+))?
|
||||
serialize =
|
||||
{major}.{minor}.{patch}{release}{candidate}
|
||||
{major}.{minor}.{patch}
|
||||
|
||||
[bumpversion:part:release]
|
||||
optional_value = production
|
||||
values =
|
||||
rc
|
||||
production
|
||||
|
||||
[bumpversion:file:app/package.json]
|
||||
|
||||
+2
-1
@@ -6,4 +6,5 @@ dist
|
||||
lbrynet/build
|
||||
lbrynet/venv
|
||||
.#*
|
||||
build_venv
|
||||
build_venv
|
||||
*.pyc
|
||||
@@ -1,33 +1,42 @@
|
||||
# LBRY Electron
|
||||
# LBRY App
|
||||
|
||||
An electron version of the LBRY application.
|
||||
This is a graphical browser for the decentralized content marketplace provided by the [LBRY](https://lbry.io) protocol. It is essentially the [lbry daemon](https://github.com/lbryio/lbry) bundled with the [lbry web ui](https://github.com/lbryio/lbry-web-ui) in an [Electron](http://electron.atom.io/) application.
|
||||
|
||||
This repo uses submodules, so clone it using --recursive
|
||||
## Installing
|
||||
|
||||
## Setup
|
||||
Check out the [release page](https://github.com/lbryio/lbry-app/releases/latest) to download a binary.
|
||||
|
||||
The lbrynet library needs to be installed along with pyinstaller, and you
|
||||
need everything to be able to build the lbry-web-ui
|
||||
To install from source or make changes to the application, continue reading below.
|
||||
|
||||
## Build
|
||||
## Development
|
||||
|
||||
run `./build.sh` to create a lbry executable, bundle the front-end and move
|
||||
everything into the `app` folder
|
||||
This repo uses submodules, so clone it using `--recursive`.
|
||||
|
||||
## Run
|
||||
### Setup
|
||||
|
||||
The
|
||||
[lbry daemon](https://github.com/lbryio/lbry/blob/master/INSTALL.md) needs
|
||||
to be installed along with pyinstaller. You also need to be
|
||||
able to build the lbry-web-ui, so have node, webpack, etc installed.
|
||||
|
||||
### Build
|
||||
|
||||
run `./build.sh`
|
||||
|
||||
This builds the UI assets and puts them into `app/dist`. It also builds `app/dist/lbrynet-daemon`.
|
||||
|
||||
### Run
|
||||
|
||||
`./node_modules/.bin/electron app`
|
||||
|
||||
## Package
|
||||
### Package
|
||||
|
||||
To build a distributable package for OSX, run (on an OSX machine):
|
||||
We use [electron-builder](https://github.com/electron-userland/electron-builder)
|
||||
to create distributable packages, which is run by calling:
|
||||
|
||||
`electron-packager --electron-version=1.4.14 --overwrite electron LBRY`
|
||||
`node_modules/.bin/build -p never`
|
||||
|
||||
This also probably works for windows and linux, but I haven't tested it
|
||||
### Development on Windows
|
||||
|
||||
## TODO
|
||||
|
||||
This app works by launching the lbrynet daemon in a seperate process. Currently the
|
||||
process management is very poor and the lbrynet process might not be shut-down when the app
|
||||
is closed. Also, if the lbrynet daemon dies, there is no attempt to restart it.
|
||||
This project has currently only been worked on in Linux and macOS. If you are on Windows, you can
|
||||
checkout out the build steps in [appveyor.yml](https://github.com/lbryio/lbry-app/blob/master/appveyor.yml) and probably figure out something from there.
|
||||
+33
-17
@@ -1,4 +1,5 @@
|
||||
const {app, BrowserWindow} = require('electron');
|
||||
const {app, BrowserWindow, ipcMain} = require('electron');
|
||||
|
||||
var path = require('path');
|
||||
|
||||
var jayson = require('jayson');
|
||||
@@ -17,6 +18,7 @@ let subpy
|
||||
// set to true when the quitting sequence has started
|
||||
let quitting = false;
|
||||
|
||||
|
||||
function createWindow () {
|
||||
// Create the browser window.
|
||||
//win = new BrowserWindow({x: 0, y: 0, width: 1440, height: 414, backgroundColor: '#155b4a'})
|
||||
@@ -43,7 +45,7 @@ function lauchDaemon() {
|
||||
}
|
||||
console.log(`${__dirname}`);
|
||||
executable = path.join(__dirname, 'dist', 'lbrynet-daemon');
|
||||
subpy = require('child_process').spawn(executable, ['--verbose'])//, {stdio: ['ignore', process.stdout, process.stderr]});
|
||||
subpy = require('child_process').spawn(executable)
|
||||
// Need to handle the data event instead of attaching to
|
||||
// process.stdout because the latter doesn't work. I believe on
|
||||
// windows it buffers stdout and we don't get any meaningful output
|
||||
@@ -55,6 +57,7 @@ function lauchDaemon() {
|
||||
if (quitting) {
|
||||
app.quit();
|
||||
} else {
|
||||
// TODO: maybe it would be better to restart the daemon?
|
||||
win.loadURL(`file://${__dirname}/dist/warning.html`);
|
||||
setTimeout(app.quit, 5000)
|
||||
}
|
||||
@@ -70,9 +73,8 @@ app.on('ready', function(){
|
||||
// an error its because its not running
|
||||
console.log('Checking for lbrynet daemon')
|
||||
client.request(
|
||||
'status', [],
|
||||
function (err, res) {
|
||||
// Did it all work ?
|
||||
'status', [],
|
||||
function (err, res) {
|
||||
if (err) {
|
||||
console.log('lbrynet daemon needs to be launched')
|
||||
lauchDaemon();
|
||||
@@ -95,19 +97,14 @@ app.on('window-all-closed', () => {
|
||||
})
|
||||
|
||||
app.on('before-quit', (event) => {
|
||||
if (subpy != null) {
|
||||
event.preventDefault()
|
||||
if (win) {
|
||||
win.loadURL(`file://${__dirname}/dist/quit.html`);
|
||||
}
|
||||
quitting = true;
|
||||
console.log('Killing lbrynet-daemon process');
|
||||
kill(subpy.pid, undefined, (err) => {
|
||||
console.log('Killed lbrynet-daemon process');
|
||||
});
|
||||
if (subpy == null) {
|
||||
return
|
||||
}
|
||||
event.preventDefault();
|
||||
shutdownDaemon();
|
||||
})
|
||||
|
||||
|
||||
app.on('activate', () => {
|
||||
// On macOS it's common to re-create a window in the app when the
|
||||
// dock icon is clicked and there are no other windows open.
|
||||
@@ -116,5 +113,24 @@ app.on('activate', () => {
|
||||
}
|
||||
})
|
||||
|
||||
// In this file you can include the rest of your app's specific main process
|
||||
// code. You can also put them in separate files and require them here.
|
||||
|
||||
function shutdownDaemon() {
|
||||
console.log('Shutdown triggered');
|
||||
if (subpy == null) {
|
||||
// TODO: In this case, we didn't start the process so I'm hesitant
|
||||
// to shut it down. We might want to send a stop command
|
||||
// though instead of just letting it run.
|
||||
console.log('Not killing lbrynet because we did not start it')
|
||||
return
|
||||
}
|
||||
if (win) {
|
||||
win.loadURL(`file://${__dirname}/dist/quit.html`);
|
||||
}
|
||||
quitting = true;
|
||||
console.log('Killing lbrynet-daemon process');
|
||||
kill(subpy.pid, undefined, (err) => {
|
||||
console.log('Killed lbrynet-daemon process');
|
||||
});
|
||||
}
|
||||
|
||||
ipcMain.on('shutdown', shutdownDaemon);
|
||||
+2
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "LBRY",
|
||||
"version": "0.0.1",
|
||||
"version": "0.9.0rc10",
|
||||
"main": "main.js",
|
||||
"description": "LBRY is a fully decentralized, open-source protocol facilitating the discovery, access, and (sometimes) purchase of data.",
|
||||
"author": {
|
||||
@@ -8,6 +8,7 @@
|
||||
"name": "Job Evers-Meltzer"
|
||||
},
|
||||
"dependencies": {
|
||||
"electron-dl": "^1.6.0",
|
||||
"install": "^0.8.7",
|
||||
"jayson": "^2.0.2",
|
||||
"npm": "^4.2.0",
|
||||
|
||||
+10
-13
@@ -1,6 +1,8 @@
|
||||
# Test against the latest version of this Node.js version
|
||||
environment:
|
||||
nodejs_version: "6"
|
||||
GH_TOKEN:
|
||||
secure: LiI5jyuHUw6XbH4kC3gP1HX4P/v4rwD/gCNtaFhQu2AvJz1/1wALkp5ECnIxRySN
|
||||
|
||||
skip_branch_with_pr: true
|
||||
|
||||
@@ -10,7 +12,8 @@ clone_folder: C:\projects\lbry-electron
|
||||
install:
|
||||
# needed to deal with submodules
|
||||
- git submodule update --init --recursive
|
||||
- python set-version.py
|
||||
- python set_version.py
|
||||
- python set_build.py
|
||||
# Get the latest stable version of Node.js or io.js
|
||||
- ps: Install-Product node $env:nodejs_version
|
||||
# install modules
|
||||
@@ -35,22 +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\*.zip
|
||||
- path: dist\*.exe
|
||||
name: LBRY
|
||||
|
||||
deploy:
|
||||
- provider: GitHub
|
||||
release: $(APPVEYOR_REPO_TAG_NAME)
|
||||
description: 'Release'
|
||||
auth_token:
|
||||
secure: LiI5jyuHUw6XbH4kC3gP1HX4P/v4rwD/gCNtaFhQu2AvJz1/1wALkp5ECnIxRySN
|
||||
artifact: LBRY
|
||||
draft: true
|
||||
prerelease: true
|
||||
on:
|
||||
appveyor_repo_tag: true # deploy on tag push only
|
||||
- path: dist\*.zip
|
||||
name: lbrynet-daemon
|
||||
@@ -30,7 +30,8 @@ if [ "$FULL_BUILD" == "true" ]; then
|
||||
source "$VENV/bin/activate"
|
||||
set -u
|
||||
pip install -U pip setuptools pyinstaller
|
||||
python set-version.py
|
||||
python set_version.py
|
||||
python set_build.py
|
||||
fi
|
||||
|
||||
npm install
|
||||
@@ -71,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
|
||||
@@ -82,6 +84,6 @@ if [ "$FULL_BUILD" == "true" ]; then
|
||||
# it to reliably work and it also seemed difficult to configure. Not proud of
|
||||
# this, but it seemed better to write my own.
|
||||
pip install PyGithub uritemplate
|
||||
python release-on-tag.py
|
||||
python release_on_tag.py
|
||||
deactivate
|
||||
fi
|
||||
+129
@@ -0,0 +1,129 @@
|
||||
import argparse
|
||||
import datetime
|
||||
import re
|
||||
import sys
|
||||
|
||||
|
||||
CHANGELOG_START_RE = re.compile(r'^\#\# \[Unreleased\]')
|
||||
CHANGELOG_END_RE = re.compile(r'^\#\# \[.*\] - \d{4}-\d{2}-\d{2}')
|
||||
# if we come across a section header between two release section headers
|
||||
# then we probably have an improperly formatted changelog
|
||||
CHANGELOG_ERROR_RE = re.compile(r'^\#\# ')
|
||||
SECTION_RE = re.compile(r'^\#\#\# (.*)$')
|
||||
EMPTY_RE = re.compile(r'^\w*\*\w*$')
|
||||
ENTRY_RE = re.compile(r'\* (.*)')
|
||||
VALID_SECTIONS = ['Added', 'Changed', 'Deprecated', 'Removed', 'Fixed', 'Security']
|
||||
|
||||
|
||||
# allocate some entries to cut-down on merge conflicts
|
||||
TEMPLATE = """### Added
|
||||
*
|
||||
*
|
||||
*
|
||||
|
||||
### Changed
|
||||
*
|
||||
*
|
||||
*
|
||||
|
||||
### Fixed
|
||||
*
|
||||
*
|
||||
*
|
||||
|
||||
"""
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('changelog')
|
||||
parser.add_argument('version')
|
||||
args = parser.parse_args()
|
||||
bump(changelog, version)
|
||||
|
||||
|
||||
def bump(changelog, version):
|
||||
with open(changelog) as fp:
|
||||
lines = fp.readlines()
|
||||
|
||||
start = []
|
||||
unreleased = []
|
||||
rest = []
|
||||
unreleased_start_found = False
|
||||
unreleased_end_found = False
|
||||
for line in lines:
|
||||
if not unreleased_start_found:
|
||||
start.append(line)
|
||||
if CHANGELOG_START_RE.search(line):
|
||||
unreleased_start_found = True
|
||||
continue
|
||||
if unreleased_end_found:
|
||||
rest.append(line)
|
||||
continue
|
||||
if CHANGELOG_END_RE.search(line):
|
||||
rest.append(line)
|
||||
unreleased_end_found = True
|
||||
continue
|
||||
if CHANGELOG_ERROR_RE.search(line):
|
||||
raise Exception(
|
||||
'Failed to parse {}: {}'.format(filename, 'unexpected section header found'))
|
||||
unreleased.append(line)
|
||||
|
||||
today = datetime.datetime.today()
|
||||
header = '## [{}] - {}\n'.format(version, today.strftime('%Y-%m-%d'))
|
||||
released = normalize(unreleased)
|
||||
if not released:
|
||||
# If we don't have anything in the Unreleased section, then leave the
|
||||
# changelog as it is and return None
|
||||
return
|
||||
|
||||
changelog_data = (
|
||||
''.join(start) +
|
||||
TEMPLATE +
|
||||
header +
|
||||
'\n'.join(released) + '\n\n'
|
||||
+ ''.join(rest)
|
||||
)
|
||||
with open(changelog, 'w') as fp:
|
||||
fp.write(changelog_data)
|
||||
return '\n'.join(released) + '\n\n'
|
||||
|
||||
|
||||
def normalize(lines):
|
||||
"""Parse a changelog entry and output a normalized form"""
|
||||
sections = {}
|
||||
current_section_name = None
|
||||
current_section_contents = []
|
||||
for line in lines:
|
||||
line = line.strip()
|
||||
if not line or EMPTY_RE.match(line):
|
||||
continue
|
||||
match = SECTION_RE.match(line)
|
||||
if match:
|
||||
if current_section_contents:
|
||||
sections[current_section_name] = current_section_contents
|
||||
current_section_contents = []
|
||||
current_section_name = match.group(1)
|
||||
if current_section_name not in VALID_SECTIONS:
|
||||
raise ValueError("Section '{}' is not valid".format(current_section_name))
|
||||
continue
|
||||
match = ENTRY_RE.match(line)
|
||||
if match:
|
||||
current_section_contents.append(match.group(1))
|
||||
continue
|
||||
raise Exception('Something is wrong with line: {}'.format(line))
|
||||
if current_section_contents:
|
||||
sections[current_section_name] = current_section_contents
|
||||
|
||||
output = []
|
||||
for section in VALID_SECTIONS:
|
||||
if section not in sections:
|
||||
continue
|
||||
output.append('### {}'.format(section))
|
||||
for entry in sections[section]:
|
||||
output.append(' * {}'.format(entry))
|
||||
return output
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
+1
-1
Submodule lbry updated: 0302e3fff2...d3d8426430.
+1
-1
Submodule lbry-web-ui updated: 4068fb5fd8...9a36270d3e.
+1
-1
Submodule lbryum updated: 49253b6614...d3bfb004e2.
+1
-1
@@ -36,7 +36,7 @@
|
||||
"target": "deb"
|
||||
},
|
||||
"win": {
|
||||
"target": "zip"
|
||||
"target": "nsis"
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -1,169 +0,0 @@
|
||||
import argparse
|
||||
import glob
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import platform
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import zipfile
|
||||
|
||||
import github
|
||||
import requests
|
||||
import uritemplate
|
||||
|
||||
from lbrynet.core import log_support
|
||||
|
||||
|
||||
def main(args=None):
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--file', help='artifact to publish')
|
||||
parser.add_argument('--label', help='text to append to `file`')
|
||||
parser.add_argument('--zip', action='store_true')
|
||||
parser.add_argument(
|
||||
'--force', action='store_true',
|
||||
help='ignores whether the repo is currently tagged, publishes a draft release')
|
||||
args = parser.parse_args(args)
|
||||
|
||||
gh_token = os.environ['GH_TOKEN']
|
||||
auth = github.Github(gh_token)
|
||||
current_repo = auth.get_repo(current_repo_name())
|
||||
|
||||
if args.file:
|
||||
artifact = args.file
|
||||
else:
|
||||
artifact = get_artifact()
|
||||
|
||||
current_tag = None
|
||||
if not args.force:
|
||||
try:
|
||||
current_tag = subprocess.check_output(
|
||||
['git', 'describe', '--exact-match', 'HEAD']).strip()
|
||||
except subprocess.CalledProcessError:
|
||||
log.info('Stopping as we are not currently on a tag')
|
||||
return
|
||||
if not check_repo_has_tag(current_repo, current_tag):
|
||||
log.info('Tag %s is not in repo %s', current_tag, current_repo)
|
||||
# TODO: maybe this should be an error
|
||||
return
|
||||
|
||||
release = get_release(current_repo, current_tag, args.force)
|
||||
asset_to_upload = get_asset(artifact, args.label, args.zip)
|
||||
upload_asset(release, asset_to_upload, gh_token)
|
||||
|
||||
|
||||
def get_system():
|
||||
system = platform.system()
|
||||
if system == 'Darwin':
|
||||
return 'macOS'
|
||||
else:
|
||||
return system
|
||||
|
||||
|
||||
def current_repo_name():
|
||||
pattern = 'github.com[:/](.*)\.git'
|
||||
remote = subprocess.check_output('git remote -v'.split())
|
||||
m = re.search(pattern, remote)
|
||||
if not m:
|
||||
raise Exception('Unable to parse repo name from remote: {}'.format(remote))
|
||||
return m.group(1)
|
||||
|
||||
|
||||
def check_repo_has_tag(repo, target_tag):
|
||||
tags = repo.get_tags().get_page(0)
|
||||
for tag in tags:
|
||||
if tag.name == target_tag:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def get_release(current_repo, current_tag=None, draft=False):
|
||||
assert current_tag or draft, 'either current_tag or draft must be set'
|
||||
need_new_release = False
|
||||
if not draft and current_tag:
|
||||
try:
|
||||
release = current_repo.get_release(current_tag)
|
||||
log.info('Using an existing release for %s', current_tag)
|
||||
except github.UnknownObjectException:
|
||||
need_new_release = True
|
||||
if draft or need_new_release:
|
||||
log.info('Creating a new release for %s:%s', current_repo, current_tag)
|
||||
tag = current_tag or 'draft'
|
||||
release_name = current_tag or 'draft'
|
||||
msg = 'Release' # TODO: parse changelogs to get a better message
|
||||
try:
|
||||
# we have a race condition where its possible that between checking
|
||||
# for the release and now, another build agent has come along and already
|
||||
# created a release
|
||||
release = current_repo.create_git_release(tag, release_name, msg, draft)
|
||||
except github.GithubException:
|
||||
log.info('Failed to create a release, maybe somebody already has', exc_info=True)
|
||||
release = current_repo.get_release(current_tag)
|
||||
return release
|
||||
|
||||
|
||||
def get_artifact():
|
||||
system = platform.system()
|
||||
if system == 'Darwin':
|
||||
return glob.glob('dist/mac/LBRY*.dmg')[0]
|
||||
elif system == 'Linux':
|
||||
return glob.glob('dist/LBRY*.deb')[0]
|
||||
else:
|
||||
raise Exception("I don't know about any artifact on {}".format(system))
|
||||
|
||||
|
||||
def get_asset(filename, label=None, use_zip=False):
|
||||
if label:
|
||||
label = '-{}'.format(label)
|
||||
else:
|
||||
label = ''
|
||||
base, ext = os.path.splitext(filename)
|
||||
if use_zip:
|
||||
# TODO: probably want to clean this up
|
||||
zipfilename = '{}{}.zip'.format(base, label)
|
||||
with zipfile.ZipFile(zipfilename, 'w') as myzip:
|
||||
myzip.write(filename)
|
||||
asset_to_uplaod = zipfilename
|
||||
else:
|
||||
asset_to_upload = '{}{}{}'.format(base, label, ext)
|
||||
return asset_to_upload
|
||||
|
||||
|
||||
def upload_asset(release, asset_to_upload, token):
|
||||
basename = os.path.basename(asset_to_upload)
|
||||
|
||||
if is_asset_already_uploaded(release, basename):
|
||||
return
|
||||
|
||||
upload_uri = uritemplate.expand(
|
||||
release.upload_url, {'name': basename, 'label': get_system()})
|
||||
# using requests.post fails miserably with SSL EPIPE errors. I spent
|
||||
# half a day trying to debug before deciding to switch to curl.
|
||||
cmd = [
|
||||
'curl', '-sS', '-X', 'POST', '-u', ':{}'.format(os.environ['GH_TOKEN']),
|
||||
'--header', 'Content-Type:application/zip',
|
||||
'--data-binary', '@{}'.format(asset_to_upload), upload_uri
|
||||
]
|
||||
raw_output = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
|
||||
output = json.loads(raw_output)
|
||||
if 'errors' in output:
|
||||
raise Exception(output)
|
||||
else:
|
||||
log.info('Successfully uploaded to %s', output['browser_download_url'])
|
||||
|
||||
|
||||
def is_asset_already_uploaded(release, basename):
|
||||
for asset in release.raw_data['assets']:
|
||||
if asset['name'] == basename:
|
||||
log.info('File %s has already been uploaded to %s', basename, release.tag_name)
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
log = logging.getLogger('release-on-tag')
|
||||
log_support.configure_console(level='DEBUG')
|
||||
sys.exit(main())
|
||||
else:
|
||||
log = logging.getLogger(__name__)
|
||||
+250
@@ -0,0 +1,250 @@
|
||||
"""Trigger a release.
|
||||
|
||||
This script is to be run locally (not on a build server).
|
||||
"""
|
||||
import argparse
|
||||
import contextlib
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
import git
|
||||
import github
|
||||
import requests
|
||||
|
||||
import changelog
|
||||
|
||||
|
||||
NO_CHANGE = ('No change since the last release. This release is simply a placeholder'
|
||||
' so that LBRY and LBRY App track the same version')
|
||||
DEFAULT_BRANCHES = {
|
||||
'lbry': 'master',
|
||||
'lbry-app': 'master',
|
||||
'lbry-web-ui': 'development',
|
||||
'lbryum': 'master'
|
||||
}
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("lbry_part", help="part of lbry version to bump")
|
||||
parser.add_argument("--lbryum_part", help="part of lbryum version to bump")
|
||||
parser.add_argument("--ui-part", help="part of the ui to bump")
|
||||
parser.add_argument("--branch", help="branch to use for each repo; useful for testing")
|
||||
parser.add_argument("--last-release")
|
||||
parser.add_argument("--skip-sanity-checks", action="store_true")
|
||||
parser.add_argument("--require-changelog", action="store_true")
|
||||
parser.add_argument("--skip-push", action="store_true",
|
||||
help="Set to not push changes to remote repo")
|
||||
args = parser.parse_args()
|
||||
|
||||
base = git.Repo(os.getcwd())
|
||||
branch = get_branch('lbry-app', args.branch)
|
||||
|
||||
if not args.skip_sanity_checks:
|
||||
run_sanity_checks(base, branch)
|
||||
|
||||
if args.last_release:
|
||||
last_release = args.last_release
|
||||
else:
|
||||
response = requests.get('https://api.github.com/repos/lbryio/lbry-app/releases/latest')
|
||||
data = response.json()
|
||||
last_release = data['tag_name']
|
||||
logging.info('Last release: %s', last_release)
|
||||
|
||||
gh_token = os.environ['GH_TOKEN']
|
||||
auth = github.Github(gh_token)
|
||||
github_repo = auth.get_repo('lbryio/lbry-app')
|
||||
|
||||
names = ['lbry', 'lbry-web-ui', 'lbryum']
|
||||
repos = [Repo(name, get_part(args, name)) for name in names]
|
||||
|
||||
# in order to see if we've had any change in the submodule, we need to checkout
|
||||
# our last release, see what commit we were on, and then compare that to
|
||||
# current
|
||||
base.git.checkout(last_release)
|
||||
base.git.submodule('update')
|
||||
for repo in repos:
|
||||
repo.save_commit()
|
||||
|
||||
base.git.checkout(branch)
|
||||
base.git.submodule('update')
|
||||
|
||||
changelogs = {}
|
||||
|
||||
for repo in repos:
|
||||
logging.info('Processing repo: %s', repo.name)
|
||||
repo.checkout(args.branch)
|
||||
if repo.has_changes():
|
||||
entry = repo.get_changelog_entry()
|
||||
if entry:
|
||||
changelogs[repo.name] = entry.strip()
|
||||
repo.add_changelog()
|
||||
else:
|
||||
msg = 'Changelog entry is missing for {}'.format(repo.name)
|
||||
if args.require_changelog:
|
||||
raise Exception(msg)
|
||||
else:
|
||||
logging.warning(msg)
|
||||
else:
|
||||
logging.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
|
||||
repo.bumpversion()
|
||||
|
||||
release_msg = get_release_msg(changelogs, names)
|
||||
|
||||
for name in names:
|
||||
base.git.add(name)
|
||||
subprocess.check_call(['bumpversion', args.lbry_part, '--allow-dirty'])
|
||||
|
||||
current_tag = base.git.describe()
|
||||
|
||||
github_repo.create_git_release(current_tag, current_tag, release_msg, draft=True)
|
||||
lbrynet_daemon_release_msg = changelogs.get('lbry', NO_CHANGE)
|
||||
auth.get_repo('lbryio/lbrynet-daemon').create_git_release(
|
||||
current_tag, current_tag, lbrynet_daemon_release_msg, draft=True)
|
||||
|
||||
if not args.skip_push:
|
||||
for repo in repos:
|
||||
repo.git.push(follow_tags=True)
|
||||
base.git.push(follow_tags=True, recurse_submodules='check')
|
||||
else:
|
||||
logging.info('Skipping push; you will have to reset and delete tags if '
|
||||
'you want to run this script again')
|
||||
|
||||
|
||||
def get_branch(repo_name, override=None):
|
||||
if override:
|
||||
return override
|
||||
return DEFAULT_BRANCHES[repo_name]
|
||||
|
||||
|
||||
def get_release_msg(changelogs, names):
|
||||
lines = []
|
||||
for name in names:
|
||||
entry = changelogs.get(name)
|
||||
if not entry:
|
||||
continue
|
||||
lines.append('## {}\n'.format(name))
|
||||
lines.append('{}\n'.format(entry))
|
||||
return '\n'.join(lines)
|
||||
|
||||
|
||||
def run_sanity_checks(base, branch):
|
||||
if base.is_dirty():
|
||||
print 'Cowardly refusing to release a dirty repo'
|
||||
sys.exit(1)
|
||||
if base.active_branch.name != branch:
|
||||
print 'Cowardly refusing to release when not on the {} branch'.format(branch)
|
||||
sys.exit(1)
|
||||
if is_behind(base, branch):
|
||||
print 'Cowardly refusing to release when behind origin'
|
||||
sys.exit(1)
|
||||
check_bumpversion()
|
||||
|
||||
|
||||
def is_behind(base, branch):
|
||||
base.remotes.origin.fetch()
|
||||
rev_list = '{branch}...origin/{branch}'.format(branch=branch)
|
||||
commits_behind = base.git.rev_list(rev_list, right_only=True, count=True)
|
||||
commits_behind = int(commits_behind)
|
||||
return commits_behind > 0
|
||||
|
||||
|
||||
def check_bumpversion():
|
||||
|
||||
def requireNewVersion():
|
||||
print 'Install bumpversion: pip install -U git+https://github.com/lbryio/bumpversion.git'
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
output = subprocess.check_output(['bumpversion', '-v'], stderr=subprocess.STDOUT)
|
||||
output = output.strip()
|
||||
if output != 'bumpversion 0.5.4-lbry':
|
||||
requireNewVersion()
|
||||
except (subprocess.CalledProcessError, OSError) as err:
|
||||
requireNewVersion()
|
||||
|
||||
|
||||
def get_part(args, name):
|
||||
if name == 'lbry-web-ui':
|
||||
part = getattr(args, 'ui_part')
|
||||
return part or args.lbry_part
|
||||
else:
|
||||
return getattr(args, name + '_part')
|
||||
|
||||
|
||||
class Repo(object):
|
||||
def __init__(self, name, part):
|
||||
self.name = name
|
||||
self.part = part
|
||||
self.directory = os.path.join(os.getcwd(), name)
|
||||
self.git_repo = git.Repo(self.directory)
|
||||
self.saved_commit = None
|
||||
self._bumped = False
|
||||
|
||||
def has_changes(self):
|
||||
logging.info('%s =? %s', self.git_repo.commit(), self.saved_commit)
|
||||
return self.git_repo.commit() != self.saved_commit
|
||||
|
||||
def save_commit(self):
|
||||
self.saved_commit = self.git_repo.commit()
|
||||
|
||||
def checkout(self, override=None):
|
||||
branch = get_branch(self.name, override)
|
||||
self.git_repo.git.checkout(branch)
|
||||
self.git_repo.git.pull(rebase=True)
|
||||
|
||||
def get_changelog_entry(self):
|
||||
filename = os.path.join(self.directory, 'CHANGELOG.md')
|
||||
return changelog.bump(filename, self.new_version())
|
||||
|
||||
def add_changelog(self):
|
||||
with pushd(self.directory):
|
||||
self.git_repo.git.add('CHANGELOG.md')
|
||||
|
||||
def new_version(self):
|
||||
if self._bumped:
|
||||
raise Exception('Cannot calculate a new version on an already bumped repo')
|
||||
if not self.part:
|
||||
raise Exception('Cannot calculate a new version without a part')
|
||||
with pushd(self.directory):
|
||||
output = subprocess.check_output(
|
||||
['bumpversion', '--dry-run', '--list', '--allow-dirty', self.part])
|
||||
return re.search('^new_version=(.*)$', output, re.M).group(1)
|
||||
|
||||
def bumpversion(self):
|
||||
if self._bumped:
|
||||
raise Exception('Cowardly refusing to bump a repo twice')
|
||||
if not self.part:
|
||||
raise Exception('Cannot bump version for {}: no part specified'.format(repo.name))
|
||||
with pushd(self.directory):
|
||||
subprocess.check_call(['bumpversion', '--allow-dirty', self.part])
|
||||
self._bumped = True
|
||||
|
||||
@property
|
||||
def git(self):
|
||||
return self.git_repo.git
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def pushd(new_dir):
|
||||
previous_dir = os.getcwd()
|
||||
os.chdir(new_dir)
|
||||
yield
|
||||
os.chdir(previous_dir)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
logging.basicConfig(
|
||||
format="%(asctime)s %(levelname)-8s %(name)s:%(lineno)d: %(message)s",
|
||||
level='INFO'
|
||||
)
|
||||
sys.exit(main())
|
||||
else:
|
||||
log = logging.getLogger('__name__')
|
||||
@@ -0,0 +1,143 @@
|
||||
import argparse
|
||||
import glob
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import platform
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
import github
|
||||
import requests
|
||||
import uritemplate
|
||||
|
||||
from lbrynet.core import log_support
|
||||
|
||||
|
||||
def main(args=None):
|
||||
current_tag = None
|
||||
try:
|
||||
current_tag = subprocess.check_output(
|
||||
['git', 'describe', '--exact-match', 'HEAD']).strip()
|
||||
except subprocess.CalledProcessError:
|
||||
log.info('Stopping as we are not currently on a tag')
|
||||
return
|
||||
|
||||
if 'GH_TOKEN' not in os.environ:
|
||||
print 'Must set GH_TOKEN in order to publish assets to a release'
|
||||
return
|
||||
|
||||
gh_token = os.environ['GH_TOKEN']
|
||||
auth = github.Github(gh_token)
|
||||
app_repo = auth.get_repo('lbryio/lbry-app')
|
||||
# TODO: switch lbryio/lbrynet-daemon to lbryio/lbry
|
||||
daemon_repo = auth.get_repo('lbryio/lbrynet-daemon')
|
||||
|
||||
if not check_repo_has_tag(app_repo, current_tag):
|
||||
log.info('Tag %s is not in repo %s', current_tag, app_repo)
|
||||
# TODO: maybe this should be an error
|
||||
return
|
||||
|
||||
app = get_app_artifact()
|
||||
release = get_release(app_repo, current_tag)
|
||||
upload_asset(release, app, gh_token)
|
||||
|
||||
daemon = get_daemon_artifact()
|
||||
release = get_release(daemon_repo, current_tag)
|
||||
upload_asset(release, daemon, gh_token)
|
||||
|
||||
|
||||
def check_repo_has_tag(repo, target_tag):
|
||||
tags = repo.get_tags().get_page(0)
|
||||
for tag in tags:
|
||||
if tag.name == target_tag:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def get_release(current_repo, current_tag):
|
||||
for release in current_repo.get_releases():
|
||||
if release.tag_name == current_tag:
|
||||
return release
|
||||
raise Exception('No release for {} was found'.format(current_tag))
|
||||
|
||||
|
||||
def get_app_artifact():
|
||||
system = platform.system()
|
||||
if system == 'Darwin':
|
||||
return glob.glob('dist/mac/LBRY*.dmg')[0]
|
||||
elif system == 'Linux':
|
||||
return glob.glob('dist/LBRY*.deb')[0]
|
||||
elif system == 'Windows':
|
||||
return glob.glob('dist/LBRY*.exe')[0]
|
||||
else:
|
||||
raise Exception("I don't know about any artifact on {}".format(system))
|
||||
|
||||
|
||||
def get_daemon_artifact():
|
||||
return glob.glob('dist/*.zip')[0]
|
||||
|
||||
|
||||
def upload_asset(release, asset_to_upload, token):
|
||||
count = 0
|
||||
while count < 10:
|
||||
try:
|
||||
return _upload_asset(release, asset_to_upload, token)
|
||||
except Exception:
|
||||
count += 1
|
||||
|
||||
|
||||
def _upload_asset(release, asset_to_upload, token):
|
||||
basename = os.path.basename(asset_to_upload)
|
||||
if is_asset_already_uploaded(release, basename):
|
||||
return
|
||||
print 'Release upload url:', release.upload_url
|
||||
upload_uri = uritemplate.expand(
|
||||
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/octet-stream',
|
||||
'--data-binary', '@{}'.format(asset_to_upload),
|
||||
upload_uri
|
||||
]
|
||||
print 'Calling curl:'
|
||||
print cmd
|
||||
print
|
||||
p = subprocess.Popen(cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
|
||||
stdout, stderr = p.communicate()
|
||||
print 'curl return code:', p.returncode
|
||||
if stderr:
|
||||
print 'stderr output from curl:'
|
||||
print stderr
|
||||
print 'stdout from curl:'
|
||||
print stdout
|
||||
output = json.loads(stdout)
|
||||
if 'errors' in output:
|
||||
raise Exception(output)
|
||||
else:
|
||||
log.info('Successfully uploaded to %s', output['browser_download_url'])
|
||||
|
||||
|
||||
def is_asset_already_uploaded(release, basename):
|
||||
for asset in release.raw_data['assets']:
|
||||
if asset['name'] == basename:
|
||||
log.info('File %s has already been uploaded to %s', basename, release.tag_name)
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
log = logging.getLogger('release-on-tag')
|
||||
log_support.configure_console(level='INFO')
|
||||
sys.exit(main())
|
||||
else:
|
||||
log = logging.getLogger(__name__)
|
||||
@@ -1,20 +0,0 @@
|
||||
"""Set the package version to the output of `git describe`"""
|
||||
|
||||
import json
|
||||
import os.path
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
version = subprocess.check_output(['git', 'describe']).strip()
|
||||
package_file = os.path.join('app', 'package.json')
|
||||
with open(package_file) as fp:
|
||||
package_data = json.load(fp)
|
||||
package_data['version'] = version
|
||||
with open(package_file, 'w') as fp:
|
||||
json.dump(package_data, fp, indent=2, separators=(',', ': '))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,29 @@
|
||||
"""Set the build version to be 'dev', 'qa', 'rc', 'release'"""
|
||||
|
||||
import json
|
||||
import os.path
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
build = get_build()
|
||||
with open(os.path.join('lbry', 'lbrynet', 'build_type.py'), 'w') as f:
|
||||
f.write('BUILD = "{}"'.format(build))
|
||||
|
||||
|
||||
def get_build():
|
||||
try:
|
||||
tag = subprocess.check_output(['git', 'describe', '--exact-match']).strip()
|
||||
if re.match('v\d+\.\d+\.\d+rc\d+', tag):
|
||||
return 'rc'
|
||||
else:
|
||||
return 'release'
|
||||
except subprocess.CalledProcessError:
|
||||
# if the build doesn't have a tag
|
||||
return 'qa'
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,59 @@
|
||||
"""Set the package version to the output of `git describe`"""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import os.path
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('--version', help="defaults to the output of `git describe`")
|
||||
args = parser.parse_args()
|
||||
if args.version:
|
||||
version = args.version
|
||||
else:
|
||||
tag = subprocess.check_output(['git', 'describe']).strip()
|
||||
try:
|
||||
version = get_version_from_tag(tag)
|
||||
except InvalidVersionTag:
|
||||
# this should be an error but its easier to handle here
|
||||
# than in the calling scripts.
|
||||
print 'Tag cannot be converted to a version, Exitting'
|
||||
return
|
||||
set_version(version)
|
||||
|
||||
|
||||
class InvalidVersionTag(Exception):
|
||||
pass
|
||||
|
||||
|
||||
def get_version_from_tag(tag):
|
||||
match = re.match('v([\d.]+)', tag)
|
||||
if match:
|
||||
return match.group(1)
|
||||
else:
|
||||
raise InvalidVersionTag('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:
|
||||
package_data = json.load(fp)
|
||||
package_data['version'] = version
|
||||
with open(package_file, 'w') as fp:
|
||||
json.dump(package_data, fp, indent=2, separators=(',', ': '))
|
||||
with open(os.path.join('lbry', 'lbrynet', '__init__.py'), 'w') as fp:
|
||||
fp.write(LBRYNET_TEMPLATE.format(version=version))
|
||||
|
||||
|
||||
LBRYNET_TEMPLATE = """
|
||||
__version__ = "{version}"
|
||||
version = tuple(__version__.split('.'))
|
||||
"""
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(main())
|
||||
@@ -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())
|
||||
Reference in new issue
Block a user