From 55d8594f6c3862704e19815ebbf51f6f7aa6d7cb Mon Sep 17 00:00:00 2001 From: Dan Bucholtz Date: Wed, 28 Sep 2016 12:22:43 -0500 Subject: [PATCH] chore(build): release process automated release process automated --- package.json | 2 ++ scripts/gulp/declarations.d.ts | 2 ++ scripts/gulp/tasks/release.ts | 37 ++++++++++++++++++++++++++++++++-- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 71fb96537f..4b19722dc6 100644 --- a/package.json +++ b/package.json @@ -57,6 +57,7 @@ "@types/through2": "2.0.29", "canonical-path": "0.0.2", "connect": "3.5.0", + "conventional-changelog": "1.1.0", "core-js": "2.4.1", "cpr": "2.0.0", "del": "2.2.2", @@ -64,6 +65,7 @@ "dgeni-packages": "^0.10.18", "event-stream": "3.3.4", "file-loader": "0.9.0", + "github": "0.2.4", "glob": "7.0.6", "gulp": "3.9.1", "gulp-autoprefixer": "3.1.1", diff --git a/scripts/gulp/declarations.d.ts b/scripts/gulp/declarations.d.ts index 358e343bda..7e42f60114 100644 --- a/scripts/gulp/declarations.d.ts +++ b/scripts/gulp/declarations.d.ts @@ -1,5 +1,7 @@ +declare module 'conventional-changelog'; declare module 'dgeni'; declare module 'event-stream'; +declare module 'github'; declare module 'gulp-if'; declare module 'gulp-scss-lint'; declare module 'gulp-tslint'; diff --git a/scripts/gulp/tasks/release.ts b/scripts/gulp/tasks/release.ts index 11e1cb586f..dc2344fa5e 100644 --- a/scripts/gulp/tasks/release.ts +++ b/scripts/gulp/tasks/release.ts @@ -1,12 +1,15 @@ import { exec, spawnSync, spawn } from 'child_process'; import { readFileSync, writeFileSync } from 'fs'; +import * as changelog from 'conventional-changelog'; +import * as GithubApi from 'github'; import * as glob from 'glob'; import { dest, src, task } from 'gulp'; import { rollup } from 'rollup'; import * as commonjs from 'rollup-plugin-commonjs'; import * as nodeResolve from 'rollup-plugin-node-resolve'; import * as runSequence from 'run-sequence'; +import { obj } from 'through2'; import { DIST_BUILD_UMD_BUNDLE_ENTRYPOINT, DIST_BUILD_ROOT, DIST_BUNDLE_ROOT, PROJECT_ROOT, SCRIPTS_ROOT, SRC_ROOT } from '../constants'; import { compileSass, copyFonts, createTimestamp, setSassIonicVersion, writePolyfills } from '../util'; @@ -20,11 +23,12 @@ task('nightly', (done: (err: any) => void) => { }); task('release', (done: (err: any) => void) => { - // don't automatically push the button, require the user to call the publish command separately for now runSequence('release.prepareReleasePackage', 'release.copyProdVersion', 'release.removeDebugStatements', 'release.prepareChangelog', + 'release.publishNpmRelease', + 'release.publishGithubRelease', done); }); @@ -48,7 +52,36 @@ function replaceAll(input: string, tokenToReplace: string, replaceWith: string) return input.split(tokenToReplace).join(replaceWith); } -task('release.publishRelease', (done: Function) => { +task('release.publishGithubRelease', (done: Function) => { + + const packageJSON = require('../../../package.json'); + + const github = new GithubApi({ + version: '3.0.0' + }); + + github.authenticate({ + type: 'oauth', + token: process.env.GH_TOKEN + }); + + return changelog({ + preset: 'angular' + }) + .pipe(obj(function(file, enc, cb){ + github.releases.createRelease({ + owner: 'driftyco', + repo: 'ionic', + target_commitish: 'master', + tag_name: 'v' + packageJSON.version, + name: packageJSON.version, + body: file.toString(), + prerelease: false + }, done); + })); +}); + +task('release.publishNpmRelease', (done: Function) => { const npmCmd = spawn('npm', ['publish', DIST_BUILD_ROOT]); npmCmd.stdout.on('data', function (data) { console.log(data.toString());