mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Backports PR #9493
**Commit 1:**
Correctly reference the default bucket for the release task
The configuration is nested under options instead of config in the new aws_s3 library.
Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
* Original sha: 789b2bf355
* Authored by Tyler Smalley <tyler.smalley@elastic.co> on 2016-12-14T23:26:43Z
63 lines
1.8 KiB
JavaScript
63 lines
1.8 KiB
JavaScript
module.exports = function (grunt) {
|
|
const readline = require('readline');
|
|
const url = require('url');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const _ = require('lodash');
|
|
|
|
// build, then zip and upload to s3
|
|
grunt.registerTask('release', [
|
|
'_release:confirmUpload',
|
|
'build',
|
|
'_release:loadS3Config',
|
|
'aws_s3:staging',
|
|
'_release:complete'
|
|
]);
|
|
|
|
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();
|
|
});
|
|
});
|
|
|
|
// 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.options.bucket'),
|
|
region: config.region
|
|
});
|
|
});
|
|
|
|
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);
|
|
}
|
|
});
|
|
});
|
|
};
|