Skip to content

Commit

Permalink
feat: add ci input parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
1nVitr0 committed Mar 14, 2023
1 parent 9a76e06 commit b356b18
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)]<br>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)]<br>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)] |

Expand Down Expand Up @@ -192,6 +193,24 @@ steps:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
```

#### ci
> {Optional Input Parameter} Whether to run semantic release with CI support (default true).<br>`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`.

Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
19 changes: 19 additions & 0 deletions src/handleOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const core = require('@actions/core');
const {
handleBranchesOption,
handleDryRunOption,
handleCiOption,
handleExtends,
} = require('./handleOptions');
const setUpJob = require('./setUpJob.task');
Expand All @@ -28,6 +29,7 @@ const release = async () => {
const result = await semanticRelease({
...handleBranchesOption(),
...handleDryRunOption(),
...handleCiOption(),
...handleExtends(),
});

Expand Down
1 change: 1 addition & 0 deletions src/inputs.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"branch": "branch",
"extra_plugins": "extra_plugins",
"dry_run": "dry_run",
"ci": "ci",
"extends": "extends",
"working_directory": "working_directory"
}

0 comments on commit b356b18

Please sign in to comment.