Skip to content

Commit

Permalink
Tweaks for pushing releases out
Browse files Browse the repository at this point in the history
Hopefully setting up a good bower package
  • Loading branch information
c0bra committed Sep 25, 2014
1 parent 2b26aae commit 621797c
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 15 deletions.
24 changes: 21 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ module.exports = function(grunt) {
},

'gh-pages': {
'gh-pages': {
'ui-grid.info': {
options: {
base: '<%= dist %>',
tag: (currentTag) ? 'v' + currentTag : null,
Expand All @@ -393,6 +393,17 @@ module.exports = function(grunt) {
add: true
},
src: ['**/*']
},
'bower': {
options: {
base: '<%= dist %>/release/' + currentTag,
tag: (currentTag) ? 'v' + currentTag : null,
repo: 'https://github.com/angular-ui/bower-ui-grid.git',
message: 'v' + currentTag,
branch: 'master',
add: true
},
src: ['**/*']
}
},

Expand Down Expand Up @@ -540,7 +551,7 @@ module.exports = function(grunt) {
keepUnstable: false
},
dist: {
src: '<%= dist %>/release/*.{js,css}',
src: '<%= dist %>/release/*.{js,css,svg,woff,ttf,eot}',
dest: '<%= dist %>/release/'
}
}
Expand Down Expand Up @@ -631,5 +642,12 @@ module.exports = function(grunt) {
}
});

grunt.registerTask('release', ['clean', 'ngtemplates', 'build', 'cut-release', 'gh-pages']);
grunt.registerTask('release', 'Release a new version out info the world', function () {
grunt.task.run(['clean', 'ngtemplates', 'build', 'cut-release', 'gh-pages:ui-grid.info']);

// If there's a tag on this commit, release a new version to bower
if (currentTag) {
grunt.task.run('gh-pages:bower');
}
});
};
23 changes: 13 additions & 10 deletions lib/grunt/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,16 @@ module.exports = function(grunt) {

var tag = util.getVersion();

var currentTag = util.getCurrentTag();

grunt.log.writeln("Version: " + tag);

if (!tag) {
grunt.fatal("Couldn't get git version");
}

// Figure out if the tag is stable or not
var stable = !/-\w+$/.test(tag);
// Figure out if the tag is stable or not (if it has a hyphen in it it's unstable)
var stable = !/-.+$/.test(tag);
grunt.log.writeln('stable', stable);

// Log release type
Expand All @@ -209,10 +211,10 @@ module.exports = function(grunt) {
var stableDir;

// If we're on a stable release or we want to keep unstable releases, create a directory for this release and copy the built files there
if (stable || options.keepUnstable) {
if (currentTag || options.keepUnstable) {
grunt.log.writeln("DEST: " + file.dest);
grunt.log.writeln("TAG: " + tag);
stableDir = path.join(file.dest, tag);
releaseDir = path.join(file.dest, tag);
}

file.src.forEach(function (f) {
Expand All @@ -228,23 +230,24 @@ module.exports = function(grunt) {
// Skip file if it was already released
var re = new RegExp('(' + options.stableSuffix + '|' + options.unstableSuffix + ')');
if (basename.match(re)) {
grunt.log.writeln("Skipping file: " + f);
return;
}

var newFileName = basename + extension + ext;

// If this is a stable release
if (stableDir) {
if (releaseDir) {
// Create the stable directory if it doesn't exist
if (!fs.existsSync(stableDir)) {
fs.mkdirSync(stableDir);
if (!fs.existsSync(releaseDir)) {
fs.mkdirSync(releaseDir);
}

var stablePath = path.join(stableDir, oldFileName);
var releasePath = path.join(releaseDir, oldFileName);

grunt.log.writeln('Copying ' + f + ' to ' + stablePath);
grunt.log.writeln('Copying ' + f + ' to ' + releasePath);
// fs.createReadStream(f).pipe(fs.createWriteStream(stablePath));
shell.cp(f, stablePath);
shell.cp(f, releasePath);
}

var newPath = path.join(file.dest, newFileName)
Expand Down
12 changes: 10 additions & 2 deletions lib/grunt/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,20 @@ var util = module.exports = {
util.createSauceConfig();

if (process.env.TRAVIS) {
grunt.config('gh-pages.gh-pages.options.user', {
// Update the config for the gh-pages task for it pushes changes as the user: Grud
grunt.config('gh-pages.ui-grid.info.options.user', {
name: 'grud',
email: 'nggridteam@gmail.com'
});

grunt.config('gh-pages.gh-pages.options.repo', 'https://' + process.env.GITHUB_NAME + ':' + process.env.GITHUB_PASS + '@github.com/angular-ui/ui-grid.info.git');
grunt.config('gh-pages.ui-grid.info.options.repo', 'https://' + process.env.GITHUB_NAME + ':' + process.env.GITHUB_PASS + '@github.com/angular-ui/ui-grid.info.git');

grunt.config('gh-pages.bower.options.user', {
name: 'grud',
email: 'nggridteam@gmail.com'
});

grunt.config('gh-pages.bower.options.repo', 'https://' + process.env.GITHUB_NAME + ':' + process.env.GITHUB_PASS + '@github.com/angular-ui/bower-ui-grid.git');
}
},

Expand Down

0 comments on commit 621797c

Please sign in to comment.