It depends on your definition of automated. There is no Build Feature within TeamCity to update the various .json files that gulp / bower etc using Teamcity 9.
Like you I am using gulp-bump to set the version number, but I have found a way to set the version number inside the package.json file using the teamcity version number.
FYI, I am using var $ = require('gulp-load-plugins')({ lazy: true }); so if you see $ sign that's is why
I am also using yargs to read from the command line
That is the gulp task that i am using, and I have set it as a dependency of my mail build task.
var args = require('yargs').argv;
var fs = require('fs');
gulp.task('setVersion', function () {
var msg = 'Setting version';
var version = args.version;
var options = {};
if (version) {
options.version = version;
msg += ' to ' + version;
}
log(msg);
return gulp
.src(config.packages)
.pipe($.print())
.pipe(version ? $.bump(options) : $.util.noop())
.pipe(gulp.dest(config.dest.root));
});
This is my config. It is abbreviated to only show whats needed
module.exports = function () {
var root = './';
var config = {
dest: {
root: root,
},
packages: [
'./package.json'
]
};
return config;
};
I check to make sure that a version is passed because when the gulpfile is being executed on dev machines, there is no need to set the version number because I only care about the build number on TeamCity.
so If you called it from the node command line it would be
gulp build --version=2.3.4
There is a gotcha. If you use the package.json via via a require statement, then the value will be cached and you may not get the correct version when you use the file. Using the require statement caused me problems as I initially struggled to determine why it was using the previous build number and not the new build number.
Because of this I created a new function to load the file when I needed to read the contents
function getPackageJson() {
return JSON.parse(fs.readFileSync('./package.json'));
}
Within my TeamCity build, I have a build step using the Gulp runner type. For the Commands I only have "build"
And I have the following for Additional command line parameters
--version=%build.number%
This for me sets the version in package.json. If you are using bower etc, then just add the additional json files to config.packages