Add manual script to deploy built CLI binaries to GitHub

This commit is contained in:
Tim Perry 2017-12-13 18:33:03 +01:00
parent e8c19df8c9
commit 2c9b80c177
3 changed files with 58 additions and 0 deletions

1
.gitignore vendored
View File

@ -36,3 +36,4 @@ resinrc.yml
/tmp
build/
build-bin/
resin-cli-*.zip

53
automation/deploy-bin.ts Normal file
View File

@ -0,0 +1,53 @@
import * as Promise from 'bluebird';
import * as path from 'path';
import * as os from 'os';
import * as fs from 'fs-extra';
import * as publishRelease from 'publish-release';
import * as archiver from 'archiver';
const publishReleaseAsync = Promise.promisify<any, any>(publishRelease);
const { GITHUB_TOKEN } = process.env;
const ROOT = path.join(__dirname, '..');
const version = 'v' + require('../package.json').version;
const outputFile = path.join(ROOT, `resin-cli-${version}-${os.platform()}-${os.arch()}.zip`);
new Promise((resolve, reject) => {
console.log('Zipping build...');
let archive = archiver('zip', {
zlib: { level: 7 }
});
archive.directory(path.join(ROOT, 'build-bin'), 'resin-cli');
let outputStream = fs.createWriteStream(outputFile);
outputStream.on('close', resolve);
outputStream.on('error', reject);
archive.on('error', reject);
archive.on('warning', console.warn);
archive.pipe(outputStream);
archive.finalize();
}).then(() => {
console.log('Build zipped');
console.log('Publishing build...');
return publishReleaseAsync({
token: GITHUB_TOKEN,
owner: 'resin-io',
repo: 'resin-cli',
tag: version,
name: `Resin-CLI ${version}`,
reuseRelease: true,
assets: [outputFile]
});
}).then((release) => {
console.log(`Release ${version} successful: ${release.html_url}`);
}).catch((err) => {
console.error('Release failed');
console.error(err);
process.exit(1);
});

View File

@ -32,6 +32,7 @@
"build": "npm run build:src && npm run build:bin",
"build:src": "gulp build && tsc && npm run doc",
"build:bin": "ts-node automation/build-bin.ts",
"release": "npm run build && ts-node automation/deploy-bin.ts",
"pretest": "npm run build",
"test": "gulp test",
"ci": "npm run test && catch-uncommitted",
@ -51,6 +52,7 @@
"node": ">=6.0"
},
"devDependencies": {
"@types/archiver": "^2.0.1",
"@types/fs-extra": "^5.0.0",
"catch-uncommitted": "^1.0.0",
"ent": "^2.2.0",
@ -64,6 +66,7 @@
"gulp-shell": "^0.5.2",
"mochainon": "^2.0.0",
"pkg": "^4.3.0-beta.1",
"publish-release": "^1.3.3",
"require-npm4-to-publish": "^1.0.0",
"ts-node": "^4.0.1",
"typescript": "^2.6.1"
@ -72,6 +75,7 @@
"@resin.io/valid-email": "^0.1.0",
"ansi-escapes": "^2.0.0",
"any-promise": "^1.3.0",
"archiver": "^2.1.0",
"bash": "0.0.1",
"bluebird": "^3.3.3",
"body-parser": "^1.14.1",