feat(dry_run): add a new input - "dry_run"

This commit is contained in:
cycjimmy 2019-10-18 13:49:05 +08:00
parent d21e9173cb
commit 65686aabe7
3 changed files with 32 additions and 2 deletions

View file

@ -5,6 +5,29 @@ const semanticRelease = require('semantic-release');
const OutputKey_NewReleasePublished = 'new-release-published';
/**
* handleDryRunOption
* @returns {{}|{dryRun: boolean}}
*/
const handleDryRunOption = () => {
const dryRun = core.getInput('dry_run', {required: false}) || '';
switch (dryRun) {
case 'true':
return {dryRun: true};
case 'false':
return {dryRun: false};
default:
return {};
}
};
/**
* Release main task
* @returns {Promise<Promise<never>|undefined>}
*/
const release = async () => {
const branch = core.getInput('branch', {required: false}) || 'master';
const extraPlugins = core.getInput('extra_plugins', {required: false}) || '';
@ -26,7 +49,10 @@ const release = async () => {
}
}
const result = await semanticRelease({branch});
const result = await semanticRelease({
branch,
...(handleDryRunOption()),
});
if (!result) {
core.debug('No release published.');