kibana/tasks/release.js

64 lines
1.8 KiB
JavaScript
Raw Normal View History

2014-10-04 02:26:05 +02:00
module.exports = function (grunt) {
const readline = require('readline');
const url = require('url');
const fs = require('fs');
const path = require('path');
const _ = require('lodash');
2014-10-04 02:26:05 +02:00
// build, then zip and upload to s3
grunt.registerTask('release', [
'_release:confirmUpload',
2014-10-04 02:26:05 +02:00
'build',
'_release:loadS3Config',
'aws_s3:staging',
'_release:complete'
2014-10-04 02:26:05 +02:00
]);
grunt.registerTask('_release:confirmUpload', function () {
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.on('close', this.async());
rl.question('Do you want to actually upload the files to s3 after building?, [N/y] ', function (resp) {
const debug = resp.toLowerCase().trim()[0] !== 'y';
grunt.config.set('aws_s3.staging.options.debug', debug);
rl.close();
});
});
2014-10-04 02:26:05 +02:00
// collect the key and secret from the .aws-config.json file, finish configuring the s3 task
grunt.registerTask('_release:loadS3Config', function () {
const config = grunt.file.readJSON('.aws-config.json');
grunt.config('aws_s3.options', {
accessKeyId: config.key,
secretAccessKey: config.secret,
bucket: config.bucket || grunt.config.get('aws_s3.config.bucket'),
region: config.region
2014-10-04 02:26:05 +02:00
});
});
2015-08-14 20:53:26 +02:00
grunt.registerTask('_release:complete', function () {
const { sha, version } = grunt.config.get('build');
const config = grunt.config.get('aws_s3.staging.files');
grunt.log.ok('Builds uploaded');
fs.readdirSync('./target').forEach((file) => {
if (path.extname(file) !== '.txt') {
let link = url.format({
protocol: 'https',
hostname: 'download.elastic.co',
pathname: config[0].dest + file
});
grunt.log.writeln(link);
}
});
2015-08-14 20:53:26 +02:00
});
2015-08-01 01:33:01 +02:00
};