Skip to content

Commit

Permalink
fix(release): updates to commit to version changes:
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasBurleson committed Feb 24, 2017
1 parent 053fa67 commit c2463a5
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 45 deletions.
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
"node": ">= 5.4.1 < 7"
},
"dependencies": {
"@angular/common": "^2.3.1",
"@angular/compiler": "^2.3.1",
"@angular/core": "^2.3.1",
"@angular/platform-browser": "^2.3.1",
"@angular/platform-browser-dynamic": "^2.3.1",
"@angular/common": "^2.3.5",
"@angular/compiler": "^2.3.5",
"@angular/core": "^2.3.5",
"@angular/platform-browser": "^2.3.5",
"@angular/platform-browser-dynamic": "^2.3.5",
"@types/gulp-util": "^3.0.30",
"core-js": "^2.4.1",
"reflect-metadata": "^0.1.8",
Expand All @@ -49,11 +49,11 @@
"zone.js": "^0.7.2"
},
"devDependencies": {
"@angular/compiler-cli": "^2.3.1",
"@angular/forms": "^2.3.1",
"@angular/http": "^2.3.1",
"@angular/compiler-cli": "^2.3.5",
"@angular/forms": "^2.3.5",
"@angular/http": "^2.3.5",
"@angular/material": "^2.0.0-beta.2",
"@angular/platform-server": "^2.3.1",
"@angular/platform-server": "^2.3.5",
"@angular/router": "~3.1.1",
"@angular/tsc-wrapped": "~0.4.0",
"@angularclass/conventions-loader": "^1.0.2",
Expand Down
64 changes: 30 additions & 34 deletions release
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,21 @@
const SOURCE_PACKAGE = './package.json';
const NPM_PACKAGE = './tools/scripts/release/npm_assets/package.json';

var lineWidth = 80;
var defaultOptions = { encoding: 'utf-8' };
var colors = require('colors');
var strip = require('cli-color/strip');
var fs = require('fs');
var prompt = require('prompt-sync')();
var child_process = require('child_process');
var releases = require('./tools/releases.json');
var oldVersion = require('./package.json').version;
var abortCmds = [ 'git reset --hard', 'git checkout staging', 'rm ./abort ./push' ];

var abortCmds = [ 'rm ./abort ./push', 'git reset --hard', 'git checkout staging' ];
var pushCmds = [ 'rm ./abort ./push' ];
var cleanupCmds = [];
var defaultOptions = { encoding: 'utf-8' };

var origin = 'git@github.com:angular/flex-layout.git';
var lineWidth = 80;
var lastMajorVer = releases.latest;
var newVersion = "";
var isYes = matches.bind(this, "yes");
Expand All @@ -47,15 +49,16 @@

checkoutVersionBranch();
updateVersion();
writeReleasesJson();
createChangelog();
commitChanges();
tagRelease();
createChangelog();
cloneRepo();
cloneDeployRepo();
generateLatestBuild();
updateMaster();
writeScript('abort', abortCmds.concat(cleanupCmds));
writeScript('push', (dryRun ? abortCmds : pushCmds).concat(cleanupCmds));
if ( !dryRun ) {
writeScript('push', pushCmds.concat(cleanupCmds));
}

line();
log(`Your repo is ${"ready".cyan} to be pushed.`);
Expand Down Expand Up @@ -98,51 +101,41 @@
function checkoutVersionBranch () {
exec(`git branch -q -D release/${newVersion}`);
exec(`git checkout -q -b release/${newVersion}`);

pushCmds.push(`# build release/${newVersion} branch...`);

abortCmds.push('git co master');
abortCmds.push(`git branch -D release/${newVersion}`);
}

/** writes the new version to package.json */
function updateVersion() {
start(`Updating ${"package.json".cyan} version from ${oldVersion.cyan} to ${newVersion.cyan}...`);

updatePackageVersions();

done();

abortCmds.push(`git checkout ${SOURCE_PACKAGE}`);
abortCmds.push(`git checkout ${NPM_PACKAGE}`);

pushCmds.push(`git add ${SOURCE_PACKAGE}`);
pushCmds.push(`git add ${NPM_PACKAGE}`);
}

/** generates the changelog from the commits since the last release */
function createChangelog () {
start(`Generating changelog from ${oldVersion.cyan} to ${newVersion.cyan}...`);

exec(`git fetch --all --tags ${origin}`);
// Do not use last tag's CHANGELOG; use one from master
exec(`git co origin/master -- CHANGELOG.md`);
// Use the current CHANGELOG.md (that is on #master and now this brank)
exec(`gulp changelog --sha=$(git rev-list -n 1 v${lastMajorVer})`);

done();

abortCmds.push('git checkout CHANGELOG.md');
pushCmds.push('git add CHANGELOG.md');
}

function writeReleasesJson () {
start('Adding new version of Releases...');
function updateReleasesJson () {
const RELEASE_PATH = './tools/releases.json';
var config = require( RELEASE_PATH );

config.versions.unshift(newVersion);
config.latest = newVersion;

fs.writeFileSync(RELEASE_PATH, JSON.stringify(config, null, 2));

done();
require('fs').writeFileSync(RELEASE_PATH, JSON.stringify(config, null, 2));
}

/** utility method for clearing the terminal */
Expand Down Expand Up @@ -243,13 +236,16 @@
/** amends the commit to include local changes (ie. changelog) */
function commitChanges () {
start('Committing changes...');
exec(`git commit -am "release: version ${newVersion}"`);
exec(`git commit -am "build(release): version ${newVersion}"`);
done();

// Now any other changes (on the release branch will
// be amended to the last commit
pushCmds.push('git commit --amend --no-edit');
}

/** utility method for cloning github repos */
function cloneRepo () {
function cloneDeployRepo () {
let path = "./"+BUILD_REPO;
start(`Cloning ${path.cyan} from Github...`);
exec(`rm -Rf ${path}`);
Expand All @@ -273,30 +269,32 @@
]);
done();

// Execute the next commands relative to the flex-layout-builds repo
let options = {cwd: "./"+BUILD_REPO};

start(`Copy files into ${options.cwd.cyan} repo...`);

exec([
'cp -Rf ../dist/@angular/flex-layout/* ./',
'cp -f ../tools/scripts/release/npm_assets/package.json ./',
'cp -f ../CHANGELOG.md ./',
'git add -A',
`git commit -m "release deploy: version ${newVersion}"`,
`git commit -m "build(deploy): release version ${newVersion}"`,
'rm -rf ../dist'
], options);
done();

//-- add steps to push script
pushCmds.push(
comment('push to builds (master and tag) and publish to npm'),
comment(`push to angular/${BUILD_REPO} (master and tag) and publish to npm`),
`cd ./${BUILD_REPO}`,
'cp -f ../CHANGELOG.md .',
'cp -f ../CHANGELOG.md',
'git add CHANGELOG.md',
'git commit --amend --no-edit',
`git tag -f v${newVersion}`,
'git pull --rebase --strategy=ours',
'git push',
'git push --tags',
comment(`publish @angular/flex-layout v${newVersion} to npm`),
'npm publish',
'cd ..'
);
Expand All @@ -322,18 +320,16 @@
pushCmds.push(
comment('update package.json in master'),
'git checkout master',
`git pull --rebase ${origin} master --strategy=theirs`,
`git checkout release/${newVersion} -- CHANGELOG.md`,
`node -e "var newVersion = '${newVersion}'; ${stringifyFunction(updatePackageVersions)}"`,
'git add CHANGELOG.md',
'git add package.json',
'git add tools/scripts/release/npm_assets/package.json',
`git commit -m "update version number in package.json to ${newVersion}"`,
`node -e ${stringifyFunction(updateReleasesJson)}`,
`git add tools/releases.json`,
`git commit -m "chore(version): update version number in package.json to ${newVersion}"`,
`git push ${origin} master`
);



function stringifyFunction (method) {
return method
.toString()
Expand Down
4 changes: 4 additions & 0 deletions tools/scripts/release/npm_assets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ The **real** power of Flex Layout, however, is its **responsive** engine. The [R
enables developers to easily specify different layouts, sizing, visibilities for different
viewport sizes and display devices.

### Updated CHANGELOG

Please consult our [CHANGELOG](https://github.com/angular/flex-layout-builds/blob/master/CHANGELOG.md) for latest changes and new features.

### Why choose Flex-Layout

While other Flexbox CSS libraries are implementations of:
Expand Down
4 changes: 2 additions & 2 deletions tools/scripts/release/npm_assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
},
"homepage": "https://github.com/angular/flex-layout#readme",
"peerDependencies": {
"@angular/common": "^2.2.3",
"@angular/core": "^2.2.3",
"@angular/common": "^2.3.5",
"@angular/core": "^2.3.5",
"rxjs": "^5.0.1",
"zone.js": "^0.7.2"
}
Expand Down

0 comments on commit c2463a5

Please sign in to comment.