This commit is contained in:
Zeke Sikelianos 2017-08-09 10:49:31 -07:00
Родитель 1e9109f3c6
Коммит 1a6f0ae437
2 изменённых файлов: 86 добавлений и 0 удалений

Просмотреть файл

@ -7,6 +7,7 @@
"asar": "^0.11.0",
"browserify": "^13.1.0",
"check-for-leaks": "^1.0.2",
"colors": "^1.1.2",
"dotenv-safe": "^4.0.4",
"electabul": "~0.0.4",
"electron-docs-linter": "^2.3.3",
@ -51,6 +52,7 @@
"publish-to-npm": "node ./script/publish-to-npm.js",
"prepack": "check-for-leaks",
"prepush": "check-for-leaks",
"prerelease": "node ./script/prerelease",
"release": "./script/upload.py -p",
"repl": "python ./script/start.py --interactive",
"start": "python ./script/start.py",

84
script/prerelease.js Executable file
Просмотреть файл

@ -0,0 +1,84 @@
#!/usr/bin/env node
require('colors')
const assert = require('assert')
const GitHub = require('github')
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 => {
releases = res.data
// console.log(releases)
const drafts = releases.filter(release => release.draft)
check(drafts.length == 1, 'one draft exists', true)
const draft = drafts[0]
check(draft.tag_name == `v${pkg.version}`, `draft release version matches local package.json (v${pkg.version})`)
check(draft.prerelease, 'draft is a prerelease')
check(draft.body.length > 50 && !draft.body.includes('(placeholder)'), 'draft has release notes')
const requiredAssets = filenames(draft.tag_name).sort()
const extantAssets = draft.assets.map(asset => asset.name).sort()
check(requiredAssets.length === extantAssets.length, 'draft has expected number of assets')
requiredAssets.forEach(asset => {
check(extantAssets.includes(asset), asset)
})
process.exit(failureCount > 0 ? 1 : 0)
})
function check (condition, statement, exitIfFail = false) {
if (condition) {
console.log(`${pass} ${statement}`)
} else {
failureCount++
console.log(`${fail} ${statement}`)
if (exitIfFail) process.exit(1)
}
}
function filenames (version) {
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',
'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',
'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'
]
return patterns.map(pattern => pattern.replace('{{VERSION}}', version))
}