Change GitHub upload to use JS GitHub lib
Needed for Appveyor when running releases
This commit is contained in:
parent
ec587032b2
commit
cb7f8e256e
3 changed files with 37 additions and 13 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -1,5 +1,6 @@
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.env
|
.env
|
||||||
|
.gclient_done
|
||||||
.npmrc
|
.npmrc
|
||||||
.tags*
|
.tags*
|
||||||
.vs/
|
.vs/
|
||||||
|
@ -14,7 +15,6 @@
|
||||||
*.vcxproj.filters
|
*.vcxproj.filters
|
||||||
*.vcxproj.user
|
*.vcxproj.user
|
||||||
*.xcodeproj
|
*.xcodeproj
|
||||||
node_modules/
|
|
||||||
/.idea/
|
/.idea/
|
||||||
/brightray/brightray.opensdf
|
/brightray/brightray.opensdf
|
||||||
/brightray/brightray.sdf
|
/brightray/brightray.sdf
|
||||||
|
@ -41,4 +41,5 @@ node_modules/
|
||||||
/vendor/node/deps/node-inspect/.npmrc
|
/vendor/node/deps/node-inspect/.npmrc
|
||||||
/vendor/npm/
|
/vendor/npm/
|
||||||
/vendor/python_26/
|
/vendor/python_26/
|
||||||
.gclient_done
|
node_modules/
|
||||||
|
SHASUMS256.txt
|
||||||
|
|
21
script/upload-to-github.js
Normal file
21
script/upload-to-github.js
Normal 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
|
||||||
|
})
|
|
@ -67,7 +67,7 @@ def main():
|
||||||
run_python_script('upload-index-json.py')
|
run_python_script('upload-index-json.py')
|
||||||
|
|
||||||
# Create and upload the Electron SHASUMS*.txt
|
# Create and upload the Electron SHASUMS*.txt
|
||||||
release_electron_checksums(github, release)
|
release_electron_checksums(release)
|
||||||
|
|
||||||
# Press the publish button.
|
# Press the publish button.
|
||||||
publish_release(github, release['id'])
|
publish_release(github, release['id'])
|
||||||
|
@ -198,11 +198,14 @@ def create_release_draft(github, tag):
|
||||||
return r
|
return r
|
||||||
|
|
||||||
|
|
||||||
def release_electron_checksums(github, release):
|
def release_electron_checksums(release):
|
||||||
checksums = run_python_script('merge-electron-checksums.py',
|
checksums = run_python_script('merge-electron-checksums.py',
|
||||||
'-v', ELECTRON_VERSION)
|
'-v', ELECTRON_VERSION)
|
||||||
upload_io_to_github(github, release, 'SHASUMS256.txt',
|
filename = 'SHASUMS256.txt'
|
||||||
StringIO(checksums.decode('utf-8')), 'text/plain')
|
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):
|
def upload_electron(github, release, file_path):
|
||||||
|
@ -217,8 +220,7 @@ def upload_electron(github, release, file_path):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Upload the file.
|
# Upload the file.
|
||||||
with open(file_path, 'rb') as f:
|
upload_io_to_github(release, filename, file_path)
|
||||||
upload_io_to_github(github, release, filename, f, 'application/zip')
|
|
||||||
|
|
||||||
# Upload the checksum file.
|
# Upload the checksum file.
|
||||||
upload_sha256_checksum(release['tag_name'], file_path)
|
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)
|
upload_electron(github, release, arm_file_path)
|
||||||
|
|
||||||
|
|
||||||
def upload_io_to_github(github, release, name, io, content_type):
|
def upload_io_to_github(release, filename, filepath):
|
||||||
params = {'name': name}
|
print 'Uploading %s to Github' % \
|
||||||
headers = {'Content-Type': content_type}
|
(filename)
|
||||||
github.repos(ELECTRON_REPO).releases(release['id']).assets.post(
|
script_path = os.path.join(SOURCE_ROOT, 'script', 'upload-to-github.js')
|
||||||
params=params, headers=headers, data=io, verify=False)
|
execute(['node', script_path, filepath, filename, str(release['id'])])
|
||||||
|
|
||||||
|
|
||||||
def upload_sha256_checksum(version, file_path):
|
def upload_sha256_checksum(version, file_path):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue