Merge pull request #3084 from simianhacker/fix/3068
Closes #3068 - Create shasum for uploaded files
This commit is contained in:
commit
fb784c98c2
|
@ -23,6 +23,7 @@ module.exports = function (grunt) {
|
||||||
'clean:test_from_node_modules',
|
'clean:test_from_node_modules',
|
||||||
'download_node_binaries',
|
'download_node_binaries',
|
||||||
'copy:versioned_dist',
|
'copy:versioned_dist',
|
||||||
'create_packages'
|
'create_packages',
|
||||||
|
'create_shasums'
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,19 +1,31 @@
|
||||||
module.exports = function (config) {
|
var createPackages = require('../create_packages');
|
||||||
|
var _ = require('lodash');
|
||||||
|
var getBaseNames = createPackages.getBaseNames;
|
||||||
|
module.exports = function (grunt) {
|
||||||
|
var upload = _(getBaseNames(grunt))
|
||||||
|
.map(function (basename) {
|
||||||
|
return [
|
||||||
|
basename + '.tar.gz',
|
||||||
|
basename + '.tar.gz.sha1.txt',
|
||||||
|
basename + '.zip',
|
||||||
|
basename + '.zip.sha1.txt'
|
||||||
|
];
|
||||||
|
})
|
||||||
|
.flatten()
|
||||||
|
.map(function (filename) {
|
||||||
|
return {
|
||||||
|
src: 'target/' + filename,
|
||||||
|
dest: 'kibana/kibana/' + filename
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.value();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
release: {
|
release: {
|
||||||
bucket: 'download.elasticsearch.org',
|
bucket: 'download.elasticsearch.org',
|
||||||
access: 'private',
|
access: 'private',
|
||||||
//debug: true, // uncommment to prevent actual upload
|
// debug: true, // uncommment to prevent actual upload
|
||||||
upload: [
|
upload: upload
|
||||||
{
|
|
||||||
src: 'target/<%= pkg.name %>-<%= pkg.version %>.zip',
|
|
||||||
dest: 'kibana/kibana/<%= pkg.name %>-<%= pkg.version %>.zip',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
src: 'target/<%= pkg.name %>-<%= pkg.version %>.tar.gz',
|
|
||||||
dest: 'kibana/kibana/<%= pkg.name %>-<%= pkg.version %>.tar.gz',
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,26 +1,32 @@
|
||||||
var child_process = require('child_process');
|
var child_process = require('child_process');
|
||||||
var Promise = require('bluebird');
|
var Promise = require('bluebird');
|
||||||
var exec = Promise.promisify(child_process.exec);
|
|
||||||
var join = require('path').join;
|
var join = require('path').join;
|
||||||
var mkdirp = Promise.promisifyAll(require('mkdirp'));
|
var mkdirp = Promise.promisifyAll(require('mkdirp'));
|
||||||
|
|
||||||
module.exports = function (grunt) {
|
var exec = Promise.promisify(child_process.exec);
|
||||||
|
|
||||||
|
var getBaseNames = function (grunt) {
|
||||||
|
var packageName = grunt.config.get('pkg.name');
|
||||||
|
var version = grunt.config.get('pkg.version');
|
||||||
|
var platforms = grunt.config.get('platforms');
|
||||||
|
return platforms.map(function (platform) {
|
||||||
|
return packageName + '-' + version + '-' + platform;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
function createPackages(grunt) {
|
||||||
grunt.registerTask('create_packages', function () {
|
grunt.registerTask('create_packages', function () {
|
||||||
var done = this.async();
|
var done = this.async();
|
||||||
var target = grunt.config.get('target');
|
var target = grunt.config.get('target');
|
||||||
var packageName = grunt.config.get('pkg.name');
|
|
||||||
var version = grunt.config.get('pkg.version');
|
|
||||||
var distPath = join(grunt.config.get('build'), 'dist');
|
var distPath = join(grunt.config.get('build'), 'dist');
|
||||||
var platforms = grunt.config.get('platforms');
|
|
||||||
|
|
||||||
var createPackage = function (platform) {
|
var createPackage = function (name) {
|
||||||
var options = { cwd: distPath };
|
var options = { cwd: distPath };
|
||||||
var name = packageName + '-' + version + '-' + platform;
|
|
||||||
var archiveName = join(target, name);
|
var archiveName = join(target, name);
|
||||||
var tgzCmd = 'tar -zcf ' + archiveName + '.tar.gz ' + name;
|
var tgzCmd = 'tar -zcf ' + archiveName + '.tar.gz ' + name;
|
||||||
var zipCmd = 'zip -rq ' + archiveName + '.zip ' + name;
|
var zipCmd = 'zip -rq ' + archiveName + '.zip ' + name;
|
||||||
|
|
||||||
if (platform === 'windows') {
|
if (/windows/.test(name)) {
|
||||||
zipCmd = 'zip -rq -ll ' + archiveName + '.zip ' + name;
|
zipCmd = 'zip -rq -ll ' + archiveName + '.zip ' + name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +39,11 @@ module.exports = function (grunt) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Promise.map(platforms, createPackage).finally(done);
|
Promise.map(getBaseNames(grunt), createPackage).finally(done);
|
||||||
|
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
|
module.exports = createPackages;
|
||||||
|
createPackages.exec = exec;
|
||||||
|
createPackages.getBaseNames = getBaseNames;
|
||||||
|
|
27
tasks/create_shasums.js
Normal file
27
tasks/create_shasums.js
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
var createPackages = require('./create_packages');
|
||||||
|
var Promise = require('bluebird');
|
||||||
|
var exec = createPackages.exec;
|
||||||
|
var getBaseNames = createPackages.getBaseNames;
|
||||||
|
var _ = require('lodash');
|
||||||
|
module.exports = function (grunt) {
|
||||||
|
grunt.registerTask('create_shasums', function () {
|
||||||
|
var done = this.async();
|
||||||
|
var target = grunt.config.get('target');
|
||||||
|
var options = { cwd: target };
|
||||||
|
|
||||||
|
var createShasum = function (filename) {
|
||||||
|
var shacmd = 'shasum ' + filename + ' > ' + filename + '.sha1.txt';
|
||||||
|
return exec(shacmd, options);
|
||||||
|
};
|
||||||
|
|
||||||
|
var filenames = _(getBaseNames(grunt))
|
||||||
|
.map(function (basename) {
|
||||||
|
return [ basename + '.tar.gz', basename + '.zip' ];
|
||||||
|
})
|
||||||
|
.flatten()
|
||||||
|
.value();
|
||||||
|
|
||||||
|
Promise.map(filenames, createShasum).finally(done);
|
||||||
|
|
||||||
|
});
|
||||||
|
};
|
Loading…
Reference in a new issue