mirror of
https://github.com/cycjimmy/semantic-release-action.git
synced 2025-11-07 10:46:56 +00:00
Merge pull request #225 from davidspek/feat/unset-gha
feat: add ability to unset GITHUB_ACTION env var
This commit is contained in:
commit
a41958e8d5
5 changed files with 35 additions and 2 deletions
24
README.md
24
README.md
|
|
@ -51,6 +51,7 @@ then make sure that you configure this in your `package.json` file:
|
||||||
| extra_plugins | false | Extra plugins for pre-install. [[Details](#extra_plugins)] |
|
| 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)] |
|
| 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**. |
|
| ci | false | Whether to run semantic release with CI support. [[Details](#ci)]<br>Support for **semantic-release above v16**. |
|
||||||
|
| unset_gha_env | false | Whether to unset the GITHUB_ACTIONS environment variable. |
|
||||||
| extends | false | Use a sharable configuration [[Details](#extends)] |
|
| extends | false | Use a sharable configuration [[Details](#extends)] |
|
||||||
| working_directory | false | Use another working directory for semantic release [[Details](#working_directory)] |
|
| working_directory | false | Use another working directory for semantic release [[Details](#working_directory)] |
|
||||||
| tag_format | false | Specify format of tag (useful for monorepos) |
|
| tag_format | false | Specify format of tag (useful for monorepos) |
|
||||||
|
|
@ -264,6 +265,29 @@ steps:
|
||||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### unset_gha_env
|
||||||
|
Setting this to true will unset the `GITHUB_ACTIONS` environment variable. This can be useful when wanting to validate things such as merging of a PR would create a valid release.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Temporarily merge PR branch
|
||||||
|
if: ${{ github.event_name == 'pull_request' }}
|
||||||
|
run: |
|
||||||
|
git config --global user.name github-actions
|
||||||
|
git config --global user.email github-actions@github.com
|
||||||
|
git merge --no-ff origin/${{ github.event.pull_request.head.ref }} --message "${{ github.event.pull_request.title }}"
|
||||||
|
- name: Semantic Release
|
||||||
|
uses: cycjimmy/semantic-release-action@v4
|
||||||
|
with:
|
||||||
|
unset_gha_env: ${{ github.event_name == 'pull_request' }}
|
||||||
|
ci: ${{ github.event_name == 'pull_request' && false || '' }}
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||||
|
```
|
||||||
|
|
||||||
### Outputs
|
### Outputs
|
||||||
| Output Parameter | Description |
|
| Output Parameter | Description |
|
||||||
|:-------------------------:|-----------------------------------------------------------------------------------------------------------------------------------|
|
|:-------------------------:|-----------------------------------------------------------------------------------------------------------------------------------|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,9 @@ inputs:
|
||||||
ci:
|
ci:
|
||||||
required: false
|
required: false
|
||||||
description: 'Whether to run semantic release with CI support (default: true). It will override the ci attribute in your configuration file'
|
description: 'Whether to run semantic release with CI support (default: true). It will override the ci attribute in your configuration file'
|
||||||
|
unset_gha_env:
|
||||||
|
required: false
|
||||||
|
description: 'Whether to unset the GITHUB_ACTIONS environment variable. This can be useful when trying to run semantic-release as part of PR checks.'
|
||||||
extends:
|
extends:
|
||||||
required: false
|
required: false
|
||||||
description: 'One or several sharable configurations, https://semantic-release.gitbook.io/semantic-release/usage/configuration#extends'
|
description: 'One or several sharable configurations, https://semantic-release.gitbook.io/semantic-release/usage/configuration#extends'
|
||||||
|
|
|
||||||
|
|
@ -126,8 +126,8 @@ exports.handleRepositoryUrlOption = () => {
|
||||||
core.debug(`repository_url input: ${repositoryUrl}`);
|
core.debug(`repository_url input: ${repositoryUrl}`);
|
||||||
|
|
||||||
if (repositoryUrl) {
|
if (repositoryUrl) {
|
||||||
return { r: repositoryUrl };
|
return { r: repositoryUrl };
|
||||||
} else {
|
} else {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,11 @@ const release = async () => {
|
||||||
await preInstall(core.getInput(inputs.extra_plugins));
|
await preInstall(core.getInput(inputs.extra_plugins));
|
||||||
await preInstall(core.getInput(inputs.extends));
|
await preInstall(core.getInput(inputs.extends));
|
||||||
|
|
||||||
|
if (core.getInput(inputs.unset_gha_env) === 'true') {
|
||||||
|
core.debug('Unset GITHUB_ACTIONS environment variable');
|
||||||
|
delete process.env.GITHUB_ACTIONS;
|
||||||
|
}
|
||||||
|
|
||||||
const semanticRelease = await import('semantic-release');
|
const semanticRelease = await import('semantic-release');
|
||||||
const result = await semanticRelease.default({
|
const result = await semanticRelease.default({
|
||||||
...handleBranchesOption(),
|
...handleBranchesOption(),
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
"extra_plugins": "extra_plugins",
|
"extra_plugins": "extra_plugins",
|
||||||
"dry_run": "dry_run",
|
"dry_run": "dry_run",
|
||||||
"ci": "ci",
|
"ci": "ci",
|
||||||
|
"unset_gha_env": "unset_gha_env",
|
||||||
"extends": "extends",
|
"extends": "extends",
|
||||||
"working_directory": "working_directory",
|
"working_directory": "working_directory",
|
||||||
"tag_format": "tag_format",
|
"tag_format": "tag_format",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue