From c1d4f0cca88cb81ee2611f463de49492102d99ea Mon Sep 17 00:00:00 2001 From: Zadkiel Date: Thu, 2 Jan 2020 15:18:45 +0100 Subject: [PATCH] feat: add extends parameter --- README.md | 2 ++ action.yml | 2 ++ src/handleOptions.js | 15 +++++++++++++++ src/index.js | 3 ++- src/inputs.json | 3 ++- 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f33b0aa..e816d8e 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ GitHub Action for [Semantic Release](https://github.com/semantic-release/semanti * `semantic_version`: [Optional] Specify specifying version range for semantic-release. If no version range is specified, semantic-release@^15 will be used by default. * `extra_plugins`: [Optional] Extra plugins for pre-install. You can also specify specifying version range for the extra plugins if you prefer. * `dry_run`: [Optional] Whether to run semantic release in `dry-run` mode. It will override the dryRun attribute in your configuration file. + * `extends`: [Optional] Shareable configuration to use. It will override the extends attribute in your configuration file. * outputs: * `new_release_published`: Whether a new release was published. `true` or `false` * `new_release_version`: Version of the new release @@ -55,6 +56,7 @@ steps: extra_plugins: | @semantic-release/git @semantic-release/changelog@3.0.0 + extends: .github/release.config.js env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/action.yml b/action.yml index c52afd2..7955576 100644 --- a/action.yml +++ b/action.yml @@ -13,6 +13,8 @@ inputs: description: 'Extra plugins for pre-install. You can also specify specifying version range for the extra plugins if you prefer.' dry_run: description: 'Whether to run semantic release in `dry-run` mode. It will override the dryRun attribute in your configuration file' + extends: + description: 'Shareable configuration to use. It will override the extends attribute in your configuration file.' outputs: new_release_published: description: 'Whether a new release was published' diff --git a/src/handleOptions.js b/src/handleOptions.js index 281a03d..e4ef12c 100644 --- a/src/handleOptions.js +++ b/src/handleOptions.js @@ -34,3 +34,18 @@ exports.handleDryRunOption = () => { return {}; } }; + +/** + * Handle Extends Option + * @returns {{}|{extends: string}} + */ +exports.handleExtendsOption = () => { + const extendsOption = {}; + const extends = core.getInput(inputs.extends); + + if (extends) { + extendsOption.extends = extends; + } + + return extendsOption; +}; diff --git a/src/index.js b/src/index.js index 90ff105..ec7d3ed 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,5 @@ const core = require('@actions/core'); -const {handleBranchOption, handleDryRunOption} = require('./handleOptions'); +const {handleBranchOption, handleDryRunOption, handleExtendsOption} = require('./handleOptions'); const setUpJob = require('./setUpJob.task'); const installSpecifyingVersionSemantic = require('./installSpecifyingVersionSemantic.task'); const preInstallPlugins = require('./preInstallPlugins.task'); @@ -19,6 +19,7 @@ const release = async () => { const result = await semanticRelease({ ...(handleBranchOption()), ...(handleDryRunOption()), + ...(handleExtendsOption()), }); await cleanupNpmrc(); diff --git a/src/inputs.json b/src/inputs.json index 5f32226..cdcec11 100644 --- a/src/inputs.json +++ b/src/inputs.json @@ -2,5 +2,6 @@ "branch": "branch", "semantic_version": "semantic_version", "extra_plugins": "extra_plugins", - "dry_run": "dry_run" + "dry_run": "dry_run", + "extends": "extends" }