Skip to content

Commit

Permalink
Merge pull request #192 from codfish/upgrade
Browse files Browse the repository at this point in the history
Upgrade semantic to v22, use node v20
  • Loading branch information
codfish committed Nov 9, 2023
2 parents f712bd4 + 3e26d45 commit ee5b4af
Show file tree
Hide file tree
Showing 8 changed files with 3,019 additions and 1,364 deletions.
22 changes: 3 additions & 19 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ jobs:
prerelease: true
}
]
repository_url: https://github.com/codfish/semantic-release-action.git
tag_format: 'v${version}'
repository-url: https://github.com/codfish/semantic-release-action.git
tag-format: 'v${version}'
extends: '@semantic-release/apm-config'
additional_packages: |
additional-packages: |
['@semantic-release/apm', '@semantic-release/git']
plugins: |
['@semantic-release/commit-analyzer', '@semantic-release/release-notes-generator', '@semantic-release/github', '@semantic-release/apm', '@semantic-release/git']
Expand All @@ -52,22 +52,6 @@ jobs:
- name: semantic-release with no inputs
id: semantic
uses: ./
with:
branches: |
[
'+([0-9])?(.{+([0-9]),x}).x',
'main',
'next',
'next-major',
{
name: 'beta',
prerelease: true
},
{
name: 'alpha',
prerelease: true
}
]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v18.7.0
v20.9.0
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:18.7.0
FROM node:20.9.0

# nice clean home for our action files
RUN mkdir /action
Expand Down
58 changes: 29 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ steps:
# Reference a docker image from GitHub Container Registry (recommended for speed & security)
- uses: docker://ghcr.io/codfish/semantic-release-action@sha256:9d1428bb40cb801b9c64e5cb7d105f4d4b94e5f47c61fa388cddee6bb8378b83
# Reference the major version of a release
- uses: codfish/semantic-release-action@v2
- uses: codfish/semantic-release-action@v3
# Reference a specific commit
- uses: codfish/semantic-release-action@4e0079a1e7511dab622628e1bf298e572a9f3d22
- uses: codfish/semantic-release-action@3607258ae5976084750909dbda50a850cb76ec3a
# Reference a minor version of a release
- uses: codfish/semantic-release-action@v1.10
- uses: codfish/semantic-release-action@v3.2.1
# Reference a branch
- uses: codfish/semantic-release-action@main
```
Expand All @@ -46,9 +46,9 @@ steps:
```yml
steps:
# Reference a docker image from GitHub Container Registry
- uses: docker://ghcr.io/codfish/semantic-release-action:v2
- uses: docker://ghcr.io/codfish/semantic-release-action:v3
# Reference a docker image from Dockerhub
- uses: docker://codfish/semantic-release-action:v2
- uses: docker://codfish/semantic-release-action:v3
```

**If you're security conscious**, you can
Expand All @@ -57,7 +57,7 @@ instead of using an image tag, which is a mutable reference.

```yml
steps:
# Reference a docker image from GitHub Container Registry (example for v2.0.0)
# Reference a docker image from GitHub Container Registry
- uses: docker://ghcr.io/codfish/semantic-release-action@<digest>
```

Expand All @@ -77,7 +77,7 @@ Where `<digest>` is any
steps:
- uses: actions/checkout@v3

- uses: codfish/semantic-release-action@v2
- uses: codfish/semantic-release-action@v3
with:
# specify default branches to add support for the `main` branch
# which semantic-release doesn't have as a default yet.
Expand Down Expand Up @@ -108,7 +108,7 @@ steps:
- uses: actions/checkout@v3

# you'll need to add an `id` in order to access output variables
- uses: codfish/semantic-release-action@v2
- uses: codfish/semantic-release-action@v3
id: semantic
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -132,7 +132,7 @@ steps:
- uses: actions/checkout@v3

# you'll need to add an `id` in order to access output variables
- uses: codfish/semantic-release-action@v2
- uses: codfish/semantic-release-action@v3
id: semantic
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -153,7 +153,7 @@ steps:
steps:
- uses: actions/checkout@v3

- uses: codfish/semantic-release-action@v2
- uses: codfish/semantic-release-action@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand Down Expand Up @@ -217,21 +217,21 @@ defined in your repo (`.releaserc`, `release.config.js`, `release` prop in `pack
> **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. |

> **Note**: Any package specified in `extends` or `additional_packages` will be installed
| Input Variable | Type | Description | Default |
| --------------------- | --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------- |
| `branches` | `Array`, `String`, `Object` | The branches on which releases should happen. Our default mimic's semantic-release's, with one major inclusion: the `main` branch. | `['+([0-9])?(.{+([0-9]),x}).x', 'master', 'main', 'next', 'next-major', {name: 'beta', prerelease: true}, {name: 'alpha', prerelease: true}]` |
| `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 | [Semantic default](https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#plugins) |
| `extends` | `Array`, `String` | List of modules or file paths containing a shareable configuration. | [Semantic default](https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#extends) |
| `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. | [Semantic default](https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#dryrun) |
| `repository-url` | `String` | The git repository URL | [Semantic default](https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#repositoryurl) |
| `tag-format` | `String` | The Git tag format used by semantic-release to identify releases. | [Semantic default](https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#tagformat) |

> **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
> **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.
Expand All @@ -248,9 +248,9 @@ defined in your repo (`.releaserc`, `release.config.js`, `release` prop in `pack

```yml
steps:
- run: codfish/semantic-release-action@v2
- run: codfish/semantic-release-action@v3
with:
dry_run: true
dry-run: true
branches: |
[
'+([0-9])?(.{+([0-9]),x}).x',
Expand All @@ -266,10 +266,10 @@ steps:
prerelease: true
}
]
repository_url: https://github.com/codfish/semantic-release-action.git
tag_format: 'v${version}'
repository-url: https://github.com/codfish/semantic-release-action.git
tag-format: 'v${version}'
extends: '@semantic-release/apm-config'
additional_packages: |
additional-packages: |
['@semantic-release/apm@4.0.0', '@semantic-release/git']
plugins: |
['@semantic-release/commit-analyzer', '@semantic-release/release-notes-generator', '@semantic-release/github', '@semantic-release/apm', '@semantic-release/git']
Expand Down Expand Up @@ -321,12 +321,12 @@ might be so this is a way to cover more cases.
## Maintenance

> Make the new release available to those binding to the major version tag: Move the major version
> tag (v1, v2, etc.) to point to the ref of the current release. This will act as the stable release
> tag (v2, v3, etc.) to point to the ref of the current release. This will act as the stable release
> for that major version. You should keep this tag updated to the most recent stable minor/patch
> release.
```sh
git tag -fa v2 -m "Update v2 tag" && git push origin v2 --force
git tag -fa v3 -m "Update v3 tag" && git push origin v3 --force
```

**Reference**:
Expand Down
31 changes: 21 additions & 10 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ inputs:
'The branches on which releases should happen.
https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#branches'
required: false
default: |
[
'master',
'main',
'next',
'next-major',
'+([0-9])?(.{+([0-9]),x}).x',
{ name: 'beta', prerelease: true },
{ name: 'alpha', prerelease: true },
{ name: 'canary', prerelease: true },
]
extends:
description:
'String or array of modules or file paths containing a shareable configuration.
Expand All @@ -23,26 +34,26 @@ inputs:
steps if they implement it.
https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#plugins'
required: false
additional_packages:
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.
https://semantic-release.gitbook.io/semantic-release/extending/plugins-list'
required: false
dry_run:
dry-run:
description:
'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.
https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#dryrun'
required: false
repository_url:
repository-url:
description:
'The git repository URL.
https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#repositoryurl'
required: false
tag_format:
tag-format:
description:
'The Git tag format used by semantic-release to identify releases.
https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#tagformat'
Expand All @@ -66,17 +77,17 @@ outputs:
release-patch:
description: "The new releases' patch version number, i.e. `3`."
release-notes:
description: "The release notes of the next release."
description: 'The release notes of the next release.'
type:
description: "The semver export type of the release, e.g. `major`, `prerelease`, etc."
description: 'The semver export type of the release, e.g. `major`, `prerelease`, etc.'
channel:
description: "The release channel of the release."
description: 'The release channel of the release.'
git-head:
description: "The git hash of the release."
description: 'The git hash of the release.'
git-tag:
description: "The version with v prefix."
description: 'The version with v prefix.'
name:
description: "The release name."
description: 'The release name.'
runs:
using: 'docker'
image: 'Dockerfile'
44 changes: 36 additions & 8 deletions entrypoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,32 @@ const installPackages = (packages) => {
}
};

/**
* Sets the github workspace as a safe directory in the global git config.
*
* @returns {object} - Response from `child_process.spawnSync()`.
*/
const setGitConfigSafeDirectory = () => {
try {
core.debug(`Enabling github workspace as a git safe directory`);
const spawn = childProcess.spawnSync('git', [
'config',
'--global',
'--add',
'safe.directory',
process.env.GITHUB_WORKSPACE,
]);
if (spawn.status !== 0) {
throw new Error(spawn.stderr);
}
core.debug(`Set ${process.env.GITHUB_WORKSPACE} as a safe directory.`);
return spawn;
} catch (err) {
core.debug(`Error setting ${process.env.GITHUB_WORKSPACE} as a safe directory.`);
throw err;
}
};

/**
* Run semantic-release.
*
Expand All @@ -51,21 +77,23 @@ async function run() {
const branches = parseInput(core.getInput('branches', { required: false }));
const plugins = parseInput(core.getInput('plugins', { required: false }));
const additionalPackages =
parseInput(core.getInput('additional_packages', { required: false })) || [];
parseInput(core.getInput('additional-packages', { required: false })) || [];
const extendsInput = parseInput(core.getInput('extends', { required: false }));
let dryRun = core.getInput('dry_run', { required: false });
let dryRun = core.getInput('dry-run', { required: false });
dryRun = dryRun !== '' ? dryRun === 'true' : '';
const repositoryUrl = core.getInput('repository_url', { required: false });
const tagFormat = core.getInput('tag_format', { required: false });
const repositoryUrl = core.getInput('repository-url', { required: false });
const tagFormat = core.getInput('tag-format', { required: false });

core.debug(`branch input: ${branch}`);
core.debug(`branches input: ${branches}`);
core.debug(`plugins input: ${plugins}`);
core.debug(`additional_packages input: ${additionalPackages}`);
core.debug(`additional-packages input: ${additionalPackages}`);
core.debug(`extends input: ${extendsInput}`);
core.debug(`dry_run input: ${dryRun}`);
core.debug(`repository_url input: ${repositoryUrl}`);
core.debug(`tag_format input: ${tagFormat}`);
core.debug(`dry-run input: ${dryRun}`);
core.debug(`repository-url input: ${repositoryUrl}`);
core.debug(`tag-format input: ${tagFormat}`);

setGitConfigSafeDirectory();

// install additional plugins/configurations
if (extendsInput) {
Expand Down

0 comments on commit ee5b4af

Please sign in to comment.