Change GitHub upload to use JS GitHub lib

Needed for Appveyor when running releases
This commit is contained in:
John Kleinschmidt 2017-09-24 06:26:04 +09:00 committed by GitHub
parent ec587032b2
commit cb7f8e256e
3 changed files with 37 additions and 13 deletions

5
.gitignore vendored
View file

@ -1,5 +1,6 @@
.DS_Store
.env
.gclient_done
.npmrc
.tags*
.vs/
@ -14,7 +15,6 @@
*.vcxproj.filters
*.vcxproj.user
*.xcodeproj
node_modules/
/.idea/
/brightray/brightray.opensdf
/brightray/brightray.sdf
@ -41,4 +41,5 @@ node_modules/
/vendor/node/deps/node-inspect/.npmrc
/vendor/npm/
/vendor/python_26/
.gclient_done
node_modules/
SHASUMS256.txt

View file

@ -0,0 +1,21 @@
const GitHub = require('github')
const github = new GitHub()
github.authenticate({type: 'token', token: process.env.ELECTRON_GITHUB_TOKEN})
let filePath = process.argv[2]
let fileName = process.argv[3]
let releaseId = process.argv[4]
let githubOpts = {
owner: 'electron',
repo: 'electron',
id: releaseId,
filePath: filePath,
name: fileName
}
github.repos.uploadAsset(githubOpts).then(() => {
process.exit()
}).catch((err) => {
console.log(`Error uploading ${fileName} to GitHub:`, err)
process.exitCode = 1
})

View file

@ -67,7 +67,7 @@ def main():
run_python_script('upload-index-json.py')
# Create and upload the Electron SHASUMS*.txt
release_electron_checksums(github, release)
release_electron_checksums(release)
# Press the publish button.
publish_release(github, release['id'])
@ -198,11 +198,14 @@ def create_release_draft(github, tag):
return r
def release_electron_checksums(github, release):
def release_electron_checksums(release):
checksums = run_python_script('merge-electron-checksums.py',
'-v', ELECTRON_VERSION)
upload_io_to_github(github, release, 'SHASUMS256.txt',
StringIO(checksums.decode('utf-8')), 'text/plain')
filename = 'SHASUMS256.txt'
filepath = os.path.join(SOURCE_ROOT, filename)
with open(filepath, 'w') as sha_file:
sha_file.write(checksums.decode('utf-8'))
upload_io_to_github(release, filename, filepath)
def upload_electron(github, release, file_path):
@ -217,8 +220,7 @@ def upload_electron(github, release, file_path):
pass
# Upload the file.
with open(file_path, 'rb') as f:
upload_io_to_github(github, release, filename, f, 'application/zip')
upload_io_to_github(release, filename, file_path)
# Upload the checksum file.
upload_sha256_checksum(release['tag_name'], file_path)
@ -232,11 +234,11 @@ def upload_electron(github, release, file_path):
upload_electron(github, release, arm_file_path)
def upload_io_to_github(github, release, name, io, content_type):
params = {'name': name}
headers = {'Content-Type': content_type}
github.repos(ELECTRON_REPO).releases(release['id']).assets.post(
params=params, headers=headers, data=io, verify=False)
def upload_io_to_github(release, filename, filepath):
print 'Uploading %s to Github' % \
(filename)
script_path = os.path.join(SOURCE_ROOT, 'script', 'upload-to-github.js')
execute(['node', script_path, filepath, filename, str(release['id'])])
def upload_sha256_checksum(version, file_path):