From b356b18b5f474bb4b9fe4bb5801b364ce24aa8f6 Mon Sep 17 00:00:00 2001 From: Aram Becker Date: Mon, 6 Mar 2023 13:09:48 +0100 Subject: [PATCH] feat: add `ci` input parameter --- README.md | 19 +++++++++++++++++++ action.yml | 3 +++ src/handleOptions.js | 19 +++++++++++++++++++ src/index.js | 2 ++ src/inputs.json | 1 + 5 files changed, 44 insertions(+) diff --git a/README.md b/README.md index 1da2a20b..1d89243f 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ then make sure that you configure this in your `package.json` file: | 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)] | +| ci | false | Whether to run semantic release with CI support. [[Details](#ci)]
Support for **semantic-release above v16**. | | extends | false | Use a sharable configuration [[Details](#extends)] | | working_directory | false | Use another working directory for semantic release [[Details](#working_directory)] | @@ -192,6 +193,24 @@ steps: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} ``` +#### ci +> {Optional Input Parameter} Whether to run semantic release with CI support (default true).
`ci` supports for **semantic-release above v16**. + +```yaml +steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Semantic Release + uses: cycjimmy/semantic-release-action@v3 + with: + ci: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} +``` + +`ci` can be used, e.g in combination with `dry_run` when generating the next release version in pull requests, where `semantic_release` would normally block the execution. + #### 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`. diff --git a/action.yml b/action.yml index c6c32432..53724b36 100644 --- a/action.yml +++ b/action.yml @@ -20,6 +20,9 @@ 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' + ci: + required: false + description: 'Whether to run semantic release with CI support (default: true). It will override the ci attribute in your configuration file' extends: required: false description: 'One or several sharable configurations, https://semantic-release.gitbook.io/semantic-release/usage/configuration#extends' diff --git a/src/handleOptions.js b/src/handleOptions.js index 1c598150..12d8b1a1 100644 --- a/src/handleOptions.js +++ b/src/handleOptions.js @@ -60,6 +60,25 @@ exports.handleDryRunOption = () => { } }; +/** + * Handle Ci Option + * @returns {{}|{ci: boolean}} + */ +exports.handleCiOption = () => { + const ci = core.getInput(inputs.ci); + + switch (ci) { + case 'true': + return { ci: true, noCi: false }; + + case 'false': + return { ci: false, noCi: true }; + + default: + return {}; + } +}; + /** * Handle Extends Option * @returns {{}|{extends: Array}|{extends: String}} diff --git a/src/index.js b/src/index.js index 01d112d0..d9a4c039 100644 --- a/src/index.js +++ b/src/index.js @@ -2,6 +2,7 @@ const core = require('@actions/core'); const { handleBranchesOption, handleDryRunOption, + handleCiOption, handleExtends, } = require('./handleOptions'); const setUpJob = require('./setUpJob.task'); @@ -28,6 +29,7 @@ const release = async () => { const result = await semanticRelease({ ...handleBranchesOption(), ...handleDryRunOption(), + ...handleCiOption(), ...handleExtends(), }); diff --git a/src/inputs.json b/src/inputs.json index 74a84b91..00591976 100644 --- a/src/inputs.json +++ b/src/inputs.json @@ -4,6 +4,7 @@ "branch": "branch", "extra_plugins": "extra_plugins", "dry_run": "dry_run", + "ci": "ci", "extends": "extends", "working_directory": "working_directory" }