diff --git a/README.md b/README.md
index 113a468..cc57dd1 100644
--- a/README.md
+++ b/README.md
@@ -36,6 +36,7 @@ If you are using this action for protected branches, replace `GITHUB_TOKEN` with
| branch | false | The branch on which releases should happen.[[Details](#branch)]
Only support for **semantic-release older than v16**. |
| extra_plugins | false | Extra plugins for pre-install. [[Details](#extra_plugins)] |
| dry_run | false | Whether to run semantic release in `dry-run` mode. [[Details](#dry_run)] |
+| extends | false | Use a sharable configuration [[Details](#extends)] |
#### semantic_version
> {Optional Input Parameter} Specify specifying version range for semantic-release.
If no version range is specified, latest version will be used by default.
@@ -173,6 +174,26 @@ steps:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
```
+#### extends
+The action can be used with `extends` option to extend an existing [sharable configuration](https://semantic-release.gitbook.io/semantic-release/usage/shareable-configurations) of semantic-release. Can be used in combination with `extra_plugins`.
+
+_github-action_
+
+```yaml
+steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+ - name: Semantic Release
+ uses: cycjimmy/semantic-release-action@v2
+ with:
+ # You can specify specifying version range for the extra plugins if you prefer.
+ extends: |
+ @semantic-release/apm-config
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
+```
+
### Outputs
| Output Parameter | Description |
|:-------------------------:|---|
diff --git a/action.yml b/action.yml
index 07f84f6..8e82bbb 100644
--- a/action.yml
+++ b/action.yml
@@ -20,6 +20,8 @@ inputs:
dry_run:
required: false
description: 'Whether to run semantic release in `dry-run` mode. It will override the dryRun attribute in your configuration file'
+ extends:
+ description: 'One or several sharable configurations, https://semantic-release.gitbook.io/semantic-release/usage/configuration#extends'
outputs:
new_release_published:
description: 'Whether a new release was published'
diff --git a/src/handleOptions.js b/src/handleOptions.js
index 83fde14..4a939e5 100644
--- a/src/handleOptions.js
+++ b/src/handleOptions.js
@@ -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 {};
+ }
+};
diff --git a/src/index.js b/src/index.js
index 99e8d1f..3b89620 100644
--- a/src/index.js
+++ b/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();
diff --git a/src/inputs.json b/src/inputs.json
index 09dbd15..536bdac 100644
--- a/src/inputs.json
+++ b/src/inputs.json
@@ -3,5 +3,6 @@
"branches": "branches",
"branch": "branch",
"extra_plugins": "extra_plugins",
- "dry_run": "dry_run"
+ "dry_run": "dry_run",
+ "extends": "extends"
}
diff --git a/src/preInstall.task.js b/src/preInstall.task.js
new file mode 100644
index 0000000..855ac63
--- /dev/null
+++ b/src/preInstall.task.js
@@ -0,0 +1,21 @@
+const path = require('path');
+const core = require('@actions/core');
+const exec = require('./_exec');
+
+/**
+ * Pre-install extra dependecies
+ * @returns {Promise}
+ */
+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);
+};
diff --git a/src/preInstallPlugins.task.js b/src/preInstallPlugins.task.js
deleted file mode 100644
index 298a59c..0000000
--- a/src/preInstallPlugins.task.js
+++ /dev/null
@@ -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}
- */
-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);
-};