Skip to content

Commit

Permalink
chore(release): calculate the cdnVersion on every build
Browse files Browse the repository at this point in the history
The CDN version of angular is now calculated on every build,
by looking at the tags in angular/angular.js, sorting them
by semver and checking against ajax.googleapis.com which
one is available.
  • Loading branch information
tbosch committed Mar 26, 2014
1 parent d6d7fe4 commit aa249ae
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 34 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = function(grunt) {
grunt.loadTasks('lib/grunt');

var NG_VERSION = versionInfo.currentVersion;
NG_VERSION.cdn = versionInfo.currentPackage.cdnVersion;
NG_VERSION.cdn = versionInfo.cdnVersion;
var dist = 'angular-'+ NG_VERSION.full;

//global beforeEach
Expand Down
2 changes: 1 addition & 1 deletion docs/docs.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var basePackage = require('./config');

module.exports = function(config) {

var cdnUrl = "//ajax.googleapis.com/ajax/libs/angularjs/" + versionInfo.currentPackage.cdnVersion;
var cdnUrl = "//ajax.googleapis.com/ajax/libs/angularjs/" + versionInfo.cdnVersion;

var getVersion = function(component, sourceFolder, packageFile) {
sourceFolder = sourceFolder || '../bower_components';
Expand Down
26 changes: 25 additions & 1 deletion lib/versions/version-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var shell = require('shelljs');
var semver = require('semver');
var _ = require('lodash');

var currentPackage, previousVersions;
var currentPackage, previousVersions, cdnVersion;


/**
Expand Down Expand Up @@ -131,6 +131,29 @@ var getPreviousVersions = function() {
}
};

var getCdnVersion = function() {
return _(previousVersions)
.filter(function(tag) {
return semver.satisfies(tag, currentPackage.branchVersion);
})
.reverse()
.reduce(function(cdnVersion, version) {
if (!cdnVersion) {
// Note: need to use shell.exec and curl here
// as version-infos returns its result synchronously...
var cdnResult = shell.exec('curl http://ajax.googleapis.com/ajax/libs/angularjs/'+version+'/angular.min.js '+
'--head --write-out "%{http_code}" -o /dev/null -silent',
{silent: true});
if ( cdnResult.code === 0 ) {
var statusCode = cdnResult.output.trim();
if (statusCode === '200') {
cdnVersion = version;
}
}
}
return cdnVersion;
}, null);
}

/**
* Get the unstable snapshot version
Expand Down Expand Up @@ -179,4 +202,5 @@ var getSnapshotVersion = function() {
exports.currentPackage = currentPackage = getPackage();
exports.gitRepoInfo = gitRepoInfo = getGitRepoInfo();
exports.previousVersions = previousVersions = getPreviousVersions();
exports.cdnVersion = cdnVersion = getCdnVersion();
exports.currentVersion = getTaggedVersion() || getSnapshotVersion();
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "angularjs",
"branchVersion": "1.3.*",
"cdnVersion": "1.3.0-beta.3",
"repository": {
"type": "git",
"url": "https://github.com/angular/angular.js.git"
Expand Down
30 changes: 0 additions & 30 deletions scripts/angular.js/publish-cdn-version.sh

This file was deleted.

0 comments on commit aa249ae

Please sign in to comment.