Promise was checked before resolving, so the first early return never happened (Promises are truthy) and the subsequent `if (lastRelease.version)` check produced an error in some cases(`lastRelease` undefined, "Error: TypeError: Cannot read properties of undefined (reading 'version')").
Observed for semantic-release-action 4.2.2 and 5.0.0 with semantic_version > 24.2.6 (not observed with 24.2.6).
The PR prevents reading properties of "undefined".
GitHub Action for [Semantic Release][semantic-url].
GitHub Action for [Semantic Release][semantic-url].
## Usage
## Usage
### Step1: Set any [Semantic Release Configuration](https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#configuration) in your repository.
### Step1: Set any [Semantic Release Configuration](https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#configuration) in your repository.
@ -18,16 +18,16 @@ GitHub Action for [Semantic Release][semantic-url].
```yaml
```yaml
steps:
steps:
- name: Checkout
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v5
- name: Semantic Release
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v3
uses: cycjimmy/semantic-release-action@v6
env:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
```
```
**IMPORTANT**: `GITHUB_TOKEN` does not have the required permissions to operate on protected branches.
**IMPORTANT**: `GITHUB_TOKEN` does not have the required permissions to operate on protected branches.
If you are using this action for protected branches, replace `GITHUB_TOKEN` with [Personal Access Token](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line). If using the `@semantic-release/git` plugin for protected branches, avoid persisting credentials as part of `actions/checkout@v3` by setting the parameter `persist-credentials: false`. This credential does not have the required permission to operate on protected branches.
If you are using this action for protected branches, replace `GITHUB_TOKEN` with [Personal Access Token](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line). If using the `@semantic-release/git` plugin for protected branches, avoid persisting credentials as part of `actions/checkout@v5` by setting the parameter `persist-credentials: false`. This credential does not have the required permission to operate on protected branches.
#### Private Packages
#### Private Packages
@ -45,32 +45,37 @@ then make sure that you configure this in your `package.json` file:
| semantic_version | false | Specify specifying version range for semantic-release. [[Details](#semantic_version)] |
| semantic_version | false | Specify version range for semantic-release. [[Details](#semantic_version)] |
| branches | false | The branches on which releases should happen.[[Details](#branches)]<br>Support for **semantic-release above v16**. |
| branches | false | The branches on which releases should happen.[[Details](#branches)]<br>Support for **semantic-release above v16**. |
| branch | false | The branch on which releases should happen.[[Details](#branch)]<br>Only support for **semantic-release older than v16**. |
| 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)] |
| 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**. |
| 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) |
| repository_url | false | The Git repository url. If no repository url specified, current repository will be used by default. |
#### semantic_version
#### semantic_version
> {Optional Input Parameter} Specify specifying version range for semantic-release.<br>If no version range is specified, latest version will be used by default.
> {Optional Input Parameter} Specify version range for semantic-release.
```yaml
```yaml
steps:
steps:
- name: Checkout
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v5
- name: Semantic Release
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v3
uses: cycjimmy/semantic-release-action@v6
with:
with:
semantic_version: 15.13.28 # It is recommended to specify specifying version range
semantic_version: 19.0.5 # It is recommended to specify a version range
# for semantic-release.
# for semantic-release when using
# semantic-release-action lower than @v4
env:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
```
```
*It is recommended to manually specify a version of semantic-release to prevent errors caused during the official semantic-release upgrade.*
If no version range is specified with `cycjimmy/semantic-release-action@v6` then [semantic-release](https://github.com/semantic-release/semantic-release/) version [24.2.7](https://github.com/semantic-release/semantic-release/releases/tag/v25.0.2) is used.
#### branches
#### branches
> {Optional Input Parameter} The branches on which releases should happen.<br>`branches` supports for **semantic-release above v16**.
> {Optional Input Parameter} The branches on which releases should happen.<br>`branches` supports for **semantic-release above v16**.
@ -78,24 +83,24 @@ steps:
```yaml
```yaml
steps:
steps:
- name: Checkout
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v5
- name: Semantic Release
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v3
uses: cycjimmy/semantic-release-action@v6
with:
with:
semantic_version: 16
semantic_version: 16
# you can set branches for semantic-release above v16.
# you can set branches for semantic-release above v16.
branches: |
branches: |
[
[
'+([0-9])?(.{+([0-9]),x}).x',
'+([0-9])?(.{+([0-9]),x}).x',
'master',
'master',
'next',
'next',
'next-major',
'next-major',
{
{
name: 'beta',
name: 'beta',
prerelease: true
prerelease: true
},
},
{
{
name: 'alpha',
name: 'alpha',
prerelease: true
prerelease: true
}
}
]
]
@ -104,14 +109,14 @@ steps:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
```
```
`branches` will override the `branches` attribute in your configuration file. If the attribute is not configured on both sides, the default is:
`branches` will override the `branches` attribute in your configuration file. If the attribute is not configured on both sides, the default is:
```
```
[
[
'+([0-9])?(.{+([0-9]),x}).x',
'+([0-9])?(.{+([0-9]),x}).x',
'master',
'master',
'next',
'next',
'next-major',
'next-major',
{name: 'beta', prerelease: true},
{name: 'beta', prerelease: true},
{name: 'alpha', prerelease: true}
{name: 'alpha', prerelease: true}
]
]
```
```
@ -124,9 +129,9 @@ See [configuration#branches](https://semantic-release.gitbook.io/semantic-releas
```yaml
```yaml
steps:
steps:
- name: Checkout
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v5
- name: Semantic Release
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v3
uses: cycjimmy/semantic-release-action@v6
with:
with:
semantic_version: 15.13.28
semantic_version: 15.13.28
# you can set branch for semantic-release older than v16.
# you can set branch for semantic-release older than v16.
@ -139,9 +144,9 @@ steps:
It will override the `branch` attribute in your configuration file. If the attribute is not configured on both sides, the default is `master`.
It will override the `branch` attribute in your configuration file. If the attribute is not configured on both sides, the default is `master`.
#### extra_plugins
#### extra_plugins
> {Optional Input Parameter} Extra plugins for pre-install.
> {Optional Input Parameter} Extra plugins for pre-install.
The action can be used with `extra_plugins` option to specify plugins which are not in the [default list of plugins of semantic release](https://semantic-release.gitbook.io/semantic-release/usage/plugins#default-plugins). When using this option, please make sure that these plugins are also mentioned in your [semantic release config's plugins](https://semantic-release.gitbook.io/semantic-release/usage/configuration#plugins) array.
The action can be used with `extra_plugins` option to specify plugins which are not in the [default list of plugins of semantic release](https://semantic-release.gitbook.io/semantic-release/usage/plugins#default-plugins). When using this option, please make sure that these plugins are also mentioned in your [semantic release config's plugins](https://semantic-release.gitbook.io/semantic-release/usage/configuration#plugins) array.
For example, if you want to use `@semantic-release/git` and `@semantic-release/changelog` extra plugins, these must be added to `extra_plugins` in your actions file and `plugins` in your [release config file](https://semantic-release.gitbook.io/semantic-release/usage/configuration#configuration-file) as shown bellow:
For example, if you want to use `@semantic-release/git` and `@semantic-release/changelog` extra plugins, these must be added to `extra_plugins` in your actions file and `plugins` in your [release config file](https://semantic-release.gitbook.io/semantic-release/usage/configuration#configuration-file) as shown bellow:
@ -149,13 +154,13 @@ Github Action Workflow:
```yaml
```yaml
steps:
steps:
- name: Checkout
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v5
- name: Semantic Release
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v3
uses: cycjimmy/semantic-release-action@v6
with:
with:
# You can specify specifying version range for the extra plugins if you prefer.
# You can specify specifying version range for the extra plugins if you prefer.
extra_plugins: |
extra_plugins: |
@semantic-release/changelog@3.0.0
@semantic-release/changelog@6.0.0
@semantic-release/git
@semantic-release/git
env:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@ -179,9 +184,9 @@ Release Config:
```yaml
```yaml
steps:
steps:
- name: Checkout
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v5
- name: Semantic Release
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v3
uses: cycjimmy/semantic-release-action@v6
with:
with:
dry_run: true
dry_run: true
env:
env:
@ -189,15 +194,33 @@ steps:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
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@v5
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v6
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
#### 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`.
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`.
```yaml
```yaml
steps:
steps:
- name: Checkout
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v5
- name: Semantic Release
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v3
uses: cycjimmy/semantic-release-action@v6
with:
with:
# You can extend an existing shareable configuration.
# You can extend an existing shareable configuration.
# And you can specify version range for the shareable configuration if you prefer.
# And you can specify version range for the shareable configuration if you prefer.
@ -215,9 +238,9 @@ This action run semantic release in the github provided workspace by default. Yo
```yaml
```yaml
steps:
steps:
- name: Checkout
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v5
- name: Semantic Release
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v3
uses: cycjimmy/semantic-release-action@v6
with:
with:
# You can select another working directory like a subdirectory for example.
# You can select another working directory like a subdirectory for example.
working_directory: ./code
working_directory: ./code
@ -226,6 +249,45 @@ steps:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
```
```
#### tag_format
The default tag format on semantic-release is `v{version}`. You can override that behavior using this option (helpful when you are using monorepos)
```yaml
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v6
with:
tag_format: custom-v${version}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_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.
* **deps:** update semantic-release to version 25 ([9246c0b](https://github.com/cycjimmy/semantic-release-action/commit/9246c0bd17405b1f20450501f39234912258bc50))
* further fix of result handling in windUpJob.task.js ([451bf1f](https://github.com/cycjimmy/semantic-release-action/commit/451bf1fa96343272b4efadb5731fe2e25073d24f)), closes [#264](https://github.com/cycjimmy/semantic-release-action/issues/264)
* improves result handling in windUpJob.task.js ([4267eee](https://github.com/cycjimmy/semantic-release-action/commit/4267eee56034cc3ee6f2fef9bdc3cc125ca073db))
* **cleanupNpmrc.task.js:** Use @actions/io to remove .npmrc ([b7db0cb](https://github.com/cycjimmy/semantic-release-action/commit/b7db0cbbf5f42eb8fe027828c236fbc340b5429e))
* add ability to unset GITHUB_ACTION env var ([266ea7e](https://github.com/cycjimmy/semantic-release-action/commit/266ea7eb8c90943aa9cddd3b0ed326d5e8784a26))
* **windUpJob:** set last_release outputs before returning ([91e3dc6](https://github.com/cycjimmy/semantic-release-action/commit/91e3dc6dcc39e4b462a165d85338c4e6cf1db9b6))