mirror of
https://github.com/cycjimmy/semantic-release-action.git
synced 2026-04-07 16:09:24 +00:00
feat: added ability to use the "extends" settings
This is done to be able to use shared configurations docs: Added docs for the extends feature fix: syntax error, due to rebase
This commit is contained in:
parent
62fd14bc6c
commit
32db8a49b2
7 changed files with 71 additions and 31 deletions
|
|
@ -59,3 +59,17 @@ exports.handleDryRunOption = () => {
|
|||
return {};
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Handle Extends Option
|
||||
* @returns {{}|{extends: Array}|{extends: String}}
|
||||
*/
|
||||
exports.handleExtends = () => {
|
||||
const extend = core.getInput(inputs.extends);
|
||||
|
||||
if (extend) {
|
||||
return { extends: extend };
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
};
|
||||
|
|
|
|||
15
src/index.js
15
src/index.js
|
|
@ -1,10 +1,15 @@
|
|||
const core = require('@actions/core');
|
||||
const {handleBranchesOption, handleDryRunOption} = require('./handleOptions');
|
||||
const {
|
||||
handleBranchOption,
|
||||
handleDryRunOption,
|
||||
handleExtends
|
||||
} = require('./handleOptions');
|
||||
const setUpJob = require('./setUpJob.task');
|
||||
const installSpecifyingVersionSemantic = require('./installSpecifyingVersionSemantic.task');
|
||||
const preInstallPlugins = require('./preInstallPlugins.task');
|
||||
const preInstall = require('./preInstall.task');
|
||||
const cleanupNpmrc = require('./cleanupNpmrc.task');
|
||||
const windUpJob = require('./windUpJob.task');
|
||||
const inputs = require('./inputs.json');
|
||||
|
||||
/**
|
||||
* Release main task
|
||||
|
|
@ -13,12 +18,14 @@ const windUpJob = require('./windUpJob.task');
|
|||
const release = async () => {
|
||||
await setUpJob();
|
||||
await installSpecifyingVersionSemantic();
|
||||
await preInstallPlugins();
|
||||
await preInstall(core.getInput(inputs.extra_plugins));
|
||||
await preInstall(core.getInput(inputs.extends));
|
||||
|
||||
const semanticRelease = require('semantic-release');
|
||||
const result = await semanticRelease({
|
||||
...(handleBranchesOption()),
|
||||
...(handleBranchOption()),
|
||||
...(handleDryRunOption()),
|
||||
...(handleExtends()),
|
||||
});
|
||||
|
||||
await cleanupNpmrc();
|
||||
|
|
|
|||
|
|
@ -3,5 +3,6 @@
|
|||
"branches": "branches",
|
||||
"branch": "branch",
|
||||
"extra_plugins": "extra_plugins",
|
||||
"dry_run": "dry_run"
|
||||
"dry_run": "dry_run",
|
||||
"extends": "extends"
|
||||
}
|
||||
|
|
|
|||
21
src/preInstall.task.js
Normal file
21
src/preInstall.task.js
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
const path = require('path');
|
||||
const core = require('@actions/core');
|
||||
const exec = require('./_exec');
|
||||
|
||||
/**
|
||||
* Pre-install extra dependecies
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
module.exports = async extras => {
|
||||
if (!extras) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const _extras = extras.replace(/['"]/g, '').replace(/[\n\r]/g, ' ');
|
||||
|
||||
const { stdout, stderr } = await exec(`npm install ${_extras}`, {
|
||||
cwd: path.resolve(__dirname, '..')
|
||||
});
|
||||
core.debug(stdout);
|
||||
core.error(stderr);
|
||||
};
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
const path = require('path');
|
||||
const core = require('@actions/core');
|
||||
const exec = require('./_exec');
|
||||
const inputs = require('./inputs.json');
|
||||
|
||||
/**
|
||||
* Pre-install plugins
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
module.exports = async () => {
|
||||
const extraPlugins = core.getInput(inputs.extra_plugins);
|
||||
|
||||
if (!extraPlugins) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const _extraPlugins = extraPlugins
|
||||
.replace(/['"]/g, '')
|
||||
.replace(/[\n\r]/g, ' ');
|
||||
|
||||
const {stdout, stderr} = await exec(`npm install ${_extraPlugins}`, {
|
||||
cwd: path.resolve(__dirname, '..')
|
||||
});
|
||||
core.debug(stdout);
|
||||
core.error(stderr);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue