Skip to content

Commit

Permalink
feat: bump to semantic-release v20, @actions/core v1.10
Browse files Browse the repository at this point in the history
  • Loading branch information
codfish committed Mar 8, 2023
1 parent cbdd966 commit 3f78bff
Show file tree
Hide file tree
Showing 7 changed files with 6,335 additions and 24,813 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
@@ -1 +1 @@
18.7.0
v18.7.0
50 changes: 30 additions & 20 deletions README.md
Expand Up @@ -66,8 +66,12 @@ to find the digest. If you prefer pulling from

### Basic Usage

> **Note**: Until [this semantic-release pr](https://github.com/semantic-release/semantic-release/pull/1737) gets merged, `main` is not a supported branch by default. If your repository is using `main` as the default branch which is extremely common, you need to pass the branches input into the action, or define it in your semantic-release config explicitly.
> See: https://github.com/semantic-release/semantic-release/pull/1737
> **Note**: Until
> [this semantic-release pr](https://github.com/semantic-release/semantic-release/pull/1737) gets
> merged, `main` is not a supported branch by default. If your repository is using `main` as the
> default branch which is extremely common, you need to pass the branches input into the action, or
> define it in your semantic-release config explicitly. See:
> https://github.com/semantic-release/semantic-release/pull/1737
```yml
steps:
Expand Down Expand Up @@ -202,32 +206,38 @@ I can easily leverage it across any project.

You can pass in `semantic-release` configuration options via GitHub Action inputs using `with`.

It's important to note, **NONE** of these inputs are required. Semantic release has a default configuration that it will use if you don't provide any.
It's important to note, **NONE** of these inputs are required. Semantic release has a default
configuration that it will use if you don't provide any.

Also of note, if you'd like to override the default configuration and you'd rather not use the inputs here, the action will automatically use any
Also of note, if you'd like to override the default configuration and you'd rather not use the
inputs here, the action will automatically use any
[`semantic-release` configuration](https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#configuration-file)
defined in your repo (`.releaserc`, `release.config.js`, `release` prop in `package.json`)

> **Note**: Each input **will take precedence** over options configured in the configuration file
> and shareable configurations.
| Input Variable | Type | Description |
| -------------- | ---- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| branches | `Array`, `String`, `Object` | The branches on which releases should happen. |
| plugins | `Array` | Define the list of plugins to use. Plugins will run in series, in the order defined, for each steps if they implement it |
| extends | `Array`, `String` | List of modules or file paths containing a shareable configuration. |
| additional_packages | `Array`, `String` | Define a list of additional plugins/configurations (official or community) to install. Use this if you 1) use any plugins other than the defaults, which are already installed along with semantic-release or 2) want to extend from a shareable configuration. |
| dry_run | `Boolean` | The objective of the dry-run mode is to get a preview of the pending release. Dry-run mode skips the following steps: prepare, publish, success and fail. |
| repository_url | `String` | The git repository URL |
| tag_format | `String` | The Git tag format used by semantic-release to identify releases. |
| Input Variable | Type | Description |
| ------------------- | --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| branches | `Array`, `String`, `Object` | The branches on which releases should happen. |
| plugins | `Array` | Define the list of plugins to use. Plugins will run in series, in the order defined, for each steps if they implement it |
| extends | `Array`, `String` | List of modules or file paths containing a shareable configuration. |
| additional_packages | `Array`, `String` | Define a list of additional plugins/configurations (official or community) to install. Use this if you 1) use any plugins other than the defaults, which are already installed along with semantic-release or 2) want to extend from a shareable configuration. |
| dry_run | `Boolean` | The objective of the dry-run mode is to get a preview of the pending release. Dry-run mode skips the following steps: prepare, publish, success and fail. |
| repository_url | `String` | The git repository URL |
| tag_format | `String` | The Git tag format used by semantic-release to identify releases. |

> **Note**: Any package specified in `extends` or `additional_packages` will be installed automatically for you as a convenience, allowing you to use this action without adding new dependencies to your application or install deps in a separate action step.
> **Note**: Any package specified in `extends` or `additional_packages` will be installed
> automatically for you as a convenience, allowing you to use this action without adding new
> dependencies to your application or install deps in a separate action step.
> **Note**: `additional_packages` won't get used automatically, setting this variable will just install them so you can use them. You'll need to actually list them in your `plugins` and/or `extends` configuration for **semantic-release** to use them.
> **Note**: `additional_packages` won't get used automatically, setting this variable will just
> install them so you can use them. You'll need to actually list them in your `plugins` and/or
> `extends` configuration for **semantic-release** to use them.
> **Note**: The `branch` input is **DEPRECATED**. Will continue to be supported for v1. Use `branches`
instead. Previously used in semantic-release v15 to set a single branch on which releases should
happen.
> **Note**: The `branch` input is **DEPRECATED**. Will continue to be supported for v1. Use
> `branches` instead. Previously used in semantic-release v15 to set a single branch on which
> releases should happen.
- **GitHub Actions Inputs:**
https://help.github.com/en/articles/metadata-syntax-for-github-actions#inputs
Expand Down Expand Up @@ -285,7 +295,7 @@ might be so this is a way to cover more cases.
| release-major | The new releases' major version number, i.e. `1` |
| release-minor | The new releases' minor version number, i.e. `8` |
| release-patch | The new releases' patch version number, i.e. `3` |
| release-notes | The release notes of the next release. |
| release-notes | The release notes of the next release. |

**Environment Variables**:

Expand All @@ -296,7 +306,7 @@ might be so this is a way to cover more cases.
| RELEASE_MAJOR | The new releases' major version number, i.e. `1` |
| RELEASE_MINOR | The new releases' minor version number, i.e. `8` |
| RELEASE_PATCH | The new releases' patch version number, i.e. `3` |
| RELEASE_NOTES | The release notes of the next release in markdown. |
| RELEASE_NOTES | The release notes of the next release in markdown. |

## Maintenance

Expand Down
6 changes: 3 additions & 3 deletions action.yml
Expand Up @@ -26,9 +26,9 @@ inputs:
additional_packages:
description:
'Define a list of additional plugins or shareable configurations (official or community) to
install. Use this if you 1) use any plugins other than commit-analyzer, release-notes-generator,
github, or npm, which are already installed along with semantic-release or 2) want to extend
from a shareable configuration.
install. Use this if you 1) use any plugins other than commit-analyzer,
release-notes-generator, github, or npm, which are already installed along with
semantic-release or 2) want to extend from a shareable configuration.
https://semantic-release.gitbook.io/semantic-release/extending/plugins-list'
required: false
dry_run:
Expand Down
18 changes: 9 additions & 9 deletions entrypoint.js
@@ -1,10 +1,10 @@
const { spawnSync } = require('child_process');
const core = require('@actions/core');
const semanticRelease = require('semantic-release');
const JSON5 = require('json5');
const arrify = require('arrify');
import * as childProcess from 'child_process';
import core from '@actions/core';
import semanticRelease from 'semantic-release';
import JSON5 from 'json5';
import arrify from 'arrify';

const parseInput = input => {
const parseInput = (input) => {
try {
return JSON5.parse(input);
} catch (err) {
Expand All @@ -18,11 +18,11 @@ const parseInput = input => {
* @param {string|string[]} packages - List of packages to install.
* @returns {object} - Response from `child_process.spawnSync()`.
*/
const installPackages = packages => {
const installPackages = (packages) => {
try {
const packagesArr = arrify(packages);
core.debug(`Installing additional packages: ${packagesArr}`);
const spawn = spawnSync('npm', ['install', '--no-save', ...packagesArr], {
const spawn = childProcess.spawnSync('npm', ['install', '--no-save', ...packagesArr], {
stdio: ['inherit', 'inherit', 'pipe'],
});
if (spawn.status !== 0) {
Expand Down Expand Up @@ -86,7 +86,7 @@ async function run() {

// remove falsey options
Object.keys(options).forEach(
key => (options[key] === undefined || options[key] === '') && delete options[key],
(key) => (options[key] === undefined || options[key] === '') && delete options[key],
);

core.debug(`options after cleanup: ${JSON.stringify(options)}`);
Expand Down
3 changes: 3 additions & 0 deletions entrypoint.spec.js
@@ -0,0 +1,3 @@
it('lib should be tested', () => {
expect({}).toBeDefined();
});

0 comments on commit 3f78bff

Please sign in to comment.