2017-08-09 17:49:31 +00:00
|
|
|
#!/usr/bin/env node
|
|
|
|
|
|
|
|
require('colors')
|
|
|
|
const assert = require('assert')
|
|
|
|
const GitHub = require('github')
|
2017-08-09 20:40:52 +00:00
|
|
|
const heads = require('heads')
|
2017-08-09 17:49:31 +00:00
|
|
|
const pkg = require('../package.json')
|
|
|
|
const pass = '\u2713'.green
|
|
|
|
const fail = '\u2717'.red
|
|
|
|
let failureCount = 0
|
|
|
|
|
|
|
|
assert(process.env.ELECTRON_GITHUB_TOKEN, 'ELECTRON_GITHUB_TOKEN not found in environment')
|
|
|
|
|
|
|
|
const github = new GitHub()
|
|
|
|
github.authenticate({type: 'token', token: process.env.ELECTRON_GITHUB_TOKEN})
|
|
|
|
github.repos.getReleases({owner: 'electron', repo: 'electron'})
|
|
|
|
.then(res => {
|
2017-08-09 18:06:16 +00:00
|
|
|
const releases = res.data
|
2017-08-09 20:40:52 +00:00
|
|
|
const drafts = releases
|
|
|
|
.filter(release => release.draft) // comment out for testing
|
|
|
|
// .filter(release => release.tag_name === 'v1.7.5') // uncomment for testing
|
2017-08-09 18:06:16 +00:00
|
|
|
|
|
|
|
check(drafts.length === 1, 'one draft exists', true)
|
2017-08-09 17:49:31 +00:00
|
|
|
const draft = drafts[0]
|
2017-08-09 18:06:16 +00:00
|
|
|
|
|
|
|
check(draft.tag_name === `v${pkg.version}`, `draft release version matches local package.json (v${pkg.version})`)
|
2017-08-09 17:49:31 +00:00
|
|
|
check(draft.prerelease, 'draft is a prerelease')
|
|
|
|
check(draft.body.length > 50 && !draft.body.includes('(placeholder)'), 'draft has release notes')
|
|
|
|
|
2017-08-09 20:40:52 +00:00
|
|
|
const requiredAssets = assetsForVersion(draft.tag_name).sort()
|
2017-08-09 17:49:31 +00:00
|
|
|
const extantAssets = draft.assets.map(asset => asset.name).sort()
|
|
|
|
|
|
|
|
requiredAssets.forEach(asset => {
|
|
|
|
check(extantAssets.includes(asset), asset)
|
|
|
|
})
|
|
|
|
|
2017-08-09 20:40:52 +00:00
|
|
|
const s3Urls = s3UrlsForVersion(draft.tag_name)
|
|
|
|
heads(s3Urls)
|
|
|
|
.then(results => {
|
|
|
|
results.forEach((result, i) => {
|
|
|
|
check(result === 200, s3Urls[i])
|
|
|
|
})
|
|
|
|
|
|
|
|
process.exit(failureCount > 0 ? 1 : 0)
|
|
|
|
})
|
|
|
|
.catch(err => {
|
|
|
|
console.error('Error making HEAD requests for S3 assets')
|
|
|
|
console.error(err)
|
|
|
|
process.exit(1)
|
|
|
|
})
|
2017-08-09 17:49:31 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
function check (condition, statement, exitIfFail = false) {
|
|
|
|
if (condition) {
|
|
|
|
console.log(`${pass} ${statement}`)
|
|
|
|
} else {
|
|
|
|
failureCount++
|
|
|
|
console.log(`${fail} ${statement}`)
|
|
|
|
if (exitIfFail) process.exit(1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-09 20:40:52 +00:00
|
|
|
function assetsForVersion (version) {
|
2017-08-09 17:49:31 +00:00
|
|
|
const patterns = [
|
|
|
|
'electron-{{VERSION}}-darwin-x64-dsym.zip',
|
|
|
|
'electron-{{VERSION}}-darwin-x64-symbols.zip',
|
|
|
|
'electron-{{VERSION}}-darwin-x64.zip',
|
|
|
|
'electron-{{VERSION}}-linux-arm-symbols.zip',
|
|
|
|
'electron-{{VERSION}}-linux-arm.zip',
|
2017-08-22 01:08:27 +00:00
|
|
|
'electron-{{VERSION}}-linux-arm64-symbols.zip',
|
|
|
|
'electron-{{VERSION}}-linux-arm64.zip',
|
2017-08-09 17:49:31 +00:00
|
|
|
'electron-{{VERSION}}-linux-armv7l-symbols.zip',
|
|
|
|
'electron-{{VERSION}}-linux-armv7l.zip',
|
|
|
|
'electron-{{VERSION}}-linux-ia32-symbols.zip',
|
|
|
|
'electron-{{VERSION}}-linux-ia32.zip',
|
|
|
|
'electron-{{VERSION}}-linux-x64-symbols.zip',
|
|
|
|
'electron-{{VERSION}}-linux-x64.zip',
|
|
|
|
'electron-{{VERSION}}-mas-x64-dsym.zip',
|
|
|
|
'electron-{{VERSION}}-mas-x64-symbols.zip',
|
|
|
|
'electron-{{VERSION}}-mas-x64.zip',
|
|
|
|
'electron-{{VERSION}}-win32-ia32-pdb.zip',
|
|
|
|
'electron-{{VERSION}}-win32-ia32-symbols.zip',
|
|
|
|
'electron-{{VERSION}}-win32-ia32.zip',
|
|
|
|
'electron-{{VERSION}}-win32-x64-pdb.zip',
|
|
|
|
'electron-{{VERSION}}-win32-x64-symbols.zip',
|
|
|
|
'electron-{{VERSION}}-win32-x64.zip',
|
|
|
|
'electron-api.json',
|
|
|
|
'electron.d.ts',
|
|
|
|
'ffmpeg-{{VERSION}}-darwin-x64.zip',
|
|
|
|
'ffmpeg-{{VERSION}}-linux-arm.zip',
|
2017-08-22 01:08:27 +00:00
|
|
|
'ffmpeg-{{VERSION}}-linux-arm64.zip',
|
2017-08-09 17:49:31 +00:00
|
|
|
'ffmpeg-{{VERSION}}-linux-armv7l.zip',
|
|
|
|
'ffmpeg-{{VERSION}}-linux-ia32.zip',
|
|
|
|
'ffmpeg-{{VERSION}}-linux-x64.zip',
|
|
|
|
'ffmpeg-{{VERSION}}-mas-x64.zip',
|
|
|
|
'ffmpeg-{{VERSION}}-win32-ia32.zip',
|
|
|
|
'ffmpeg-{{VERSION}}-win32-x64.zip'
|
|
|
|
]
|
2017-08-09 20:40:52 +00:00
|
|
|
return patterns.map(pattern => pattern.replace(/{{VERSION}}/g, version))
|
|
|
|
}
|
|
|
|
|
|
|
|
function s3UrlsForVersion (version) {
|
|
|
|
const bucket = 'https://gh-contractor-zcbenz.s3.amazonaws.com/'
|
|
|
|
const patterns = [
|
|
|
|
'atom-shell/dist/{{VERSION}}/iojs-{{VERSION}}-headers.tar.gz',
|
|
|
|
'atom-shell/dist/{{VERSION}}/iojs-{{VERSION}}.tar.gz',
|
|
|
|
'atom-shell/dist/{{VERSION}}/node-{{VERSION}}.tar.gz',
|
|
|
|
'atom-shell/dist/{{VERSION}}/node.lib',
|
|
|
|
'atom-shell/dist/{{VERSION}}/win-x64/iojs.lib',
|
|
|
|
'atom-shell/dist/{{VERSION}}/win-x86/iojs.lib',
|
|
|
|
'atom-shell/dist/{{VERSION}}/x64/node.lib',
|
|
|
|
'atom-shell/dist/index.json'
|
|
|
|
]
|
|
|
|
return patterns.map(pattern => bucket + pattern.replace(/{{VERSION}}/g, version))
|
2017-08-09 18:06:16 +00:00
|
|
|
}
|