-
Notifications
You must be signed in to change notification settings - Fork 773
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(release): updates to commit to version changes:
- Loading branch information
1 parent
053fa67
commit c2463a5
Showing
4 changed files
with
45 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 = '[email protected]:angular/flex-layout.git'; | ||
var lineWidth = 80; | ||
var lastMajorVer = releases.latest; | ||
var newVersion = ""; | ||
var isYes = matches.bind(this, "yes"); | ||
|
@@ -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.`); | ||
|
@@ -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 */ | ||
|
@@ -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}`); | ||
|
@@ -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 ..' | ||
); | ||
|
@@ -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() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters