5
0
Fork 0
mirror of https://github.com/cycjimmy/semantic-release-action.git synced 2025-11-14 05:53:46 +00:00

Merge pull request #1 from cycjimmy/master

Merge latest cycjimmy
This commit is contained in:
Dan Hunt 2022-10-27 11:58:51 -04:00 committed by GitHub
commit 12b2495fee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 9367 additions and 101 deletions

View file

@ -1,2 +1,2 @@
# Contributing # Contributing
The repository is released under the MIT license, and follows a standard Github development process, using Github tracker for issues and merging pull requests into master. The repository is released under the MIT license, and follows a standard Github development process, using Github tracker for issues and merging pull requests into main.

View file

@ -3,7 +3,7 @@ name: Check Pull Request
on: on:
pull_request: pull_request:
branches: branches:
- master - main
jobs: jobs:
release: release:
@ -11,12 +11,12 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Semantic Release - name: Semantic Release
uses: ./ uses: ./
with: with:
branch: master branch: main
extra_plugins: | extra_plugins: |
@semantic-release/git @semantic-release/git
@semantic-release/changelog @semantic-release/changelog

View file

@ -1,12 +1,10 @@
name: Release name: Release
on: on:
pull_request:
branches:
- master
push: push:
branches: branches:
- master - master
- main
- next - next
- next-major - next-major
- alpha - alpha
@ -18,12 +16,28 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Semantic Release - name: Semantic Release
uses: cycjimmy/semantic-release-action@v2 uses: ./
id: semantic id: semantic
with: with:
branches: |
[
'+([0-9])?(.{+([0-9]),x}).x',
'master',
'main',
'next',
'next-major',
{
name: 'beta',
prerelease: true
},
{
name: 'alpha',
prerelease: true
}
]
extra_plugins: | extra_plugins: |
@semantic-release/git @semantic-release/git
@semantic-release/changelog @semantic-release/changelog
@ -32,9 +46,9 @@ jobs:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Setup Node.js with GitHub Package Registry - name: Setup Node.js with GitHub Package Registry
uses: actions/setup-node@v2 uses: actions/setup-node@v3
with: with:
node-version: 14 node-version: 16
registry-url: 'https://npm.pkg.github.com' registry-url: 'https://npm.pkg.github.com'
scope: 'cycjimmy' scope: 'cycjimmy'

View file

@ -1,17 +1,11 @@
name: Test Release name: Test Release
on: on:
push: pull_request:
branches: branches:
- master - master
- next - main
- next-major push:
- alpha
- beta
- 'feat/**'
- 'fix/**'
- 'perf/**'
- 'refactor/**'
schedule: schedule:
- cron: 0 2 * * 0 - cron: 0 2 * * 0
@ -22,7 +16,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Semantic Release - name: Semantic Release
uses: ./ uses: ./
@ -33,6 +27,7 @@ jobs:
[ [
'+([0-9])?(.{+([0-9]),x}).x', '+([0-9])?(.{+([0-9]),x}).x',
'master', 'master',
'main',
'next', 'next',
'next-major', 'next-major',
{ {
@ -44,7 +39,6 @@ jobs:
prerelease: true prerelease: true
} }
] ]
branch: master
extra_plugins: | extra_plugins: |
@semantic-release/git @semantic-release/git
@semantic-release/changelog @semantic-release/changelog
@ -65,7 +59,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Semantic Release - name: Semantic Release
uses: ./ uses: ./
@ -75,11 +69,11 @@ jobs:
dry_run: true dry_run: true
branches: | branches: |
[ [
'master', 'main',
{name: 'beta', prerelease: true}, {name: 'beta', prerelease: true},
{name: 'alpha', prerelease: true} {name: 'alpha', prerelease: true}
] ]
branch: master branch: main
extra_plugins: | extra_plugins: |
@semantic-release/git@7 @semantic-release/git@7
@semantic-release/changelog@3 @semantic-release/changelog@3

View file

@ -8,9 +8,9 @@
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/main/docs/usage/configuration.md#configuration) in your repository.
### Step2: [Add Secrets](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets) in your repository for the [Semantic Release Authentication](https://github.com/semantic-release/semantic-release/blob/master/docs/usage/ci-configuration.md#authentication) Environment Variables. ### Step2: [Add Secrets](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets) in your repository for the [Semantic Release Authentication](https://github.com/semantic-release/semantic-release/blob/main/docs/usage/ci-configuration.md#authentication) Environment Variables.
### Step3: Add a [Workflow File](https://help.github.com/en/articles/workflow-syntax-for-github-actions) to your repository to create custom automated processes. ### Step3: Add a [Workflow File](https://help.github.com/en/articles/workflow-syntax-for-github-actions) to your repository to create custom automated processes.
@ -18,16 +18,16 @@ GitHub Action for [Semantic Release][semantic-url].
```yaml ```yaml
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Semantic Release - name: Semantic Release
uses: cycjimmy/semantic-release-action@v2 uses: cycjimmy/semantic-release-action@v3
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@v2` 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@v3` by setting the parameter `persist-credentials: false`. This credential does not have the required permission to operate on protected branches.
#### Private Packages #### Private Packages
@ -44,7 +44,7 @@ then make sure that you configure this in your `package.json` file:
### Inputs ### Inputs
| Input Parameter | Required | Description | | Input Parameter | Required | Description |
|:-----------------:|:--------:|-------------| |:-----------------:|:--------:|--------------------------------------------------------------------------------------------------------------------------|
| semantic_version | false | Specify specifying version range for semantic-release. [[Details](#semantic_version)] | | semantic_version | false | Specify specifying 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**. |
@ -59,9 +59,9 @@ then make sure that you configure this in your `package.json` file:
```yaml ```yaml
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Semantic Release - name: Semantic Release
uses: cycjimmy/semantic-release-action@v2 uses: cycjimmy/semantic-release-action@v3
with: with:
semantic_version: 15.13.28 # It is recommended to specify specifying version range semantic_version: 15.13.28 # It is recommended to specify specifying version range
# for semantic-release. # for semantic-release.
@ -78,9 +78,9 @@ steps:
```yaml ```yaml
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Semantic Release - name: Semantic Release
uses: cycjimmy/semantic-release-action@v2 uses: cycjimmy/semantic-release-action@v3
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.
@ -124,9 +124,9 @@ See [configuration#branches](https://semantic-release.gitbook.io/semantic-releas
```yaml ```yaml
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Semantic Release - name: Semantic Release
uses: cycjimmy/semantic-release-action@v2 uses: cycjimmy/semantic-release-action@v3
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.
@ -149,9 +149,9 @@ Github Action Workflow:
```yaml ```yaml
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Semantic Release - name: Semantic Release
uses: cycjimmy/semantic-release-action@v2 uses: cycjimmy/semantic-release-action@v3
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: |
@ -179,9 +179,9 @@ Release Config:
```yaml ```yaml
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Semantic Release - name: Semantic Release
uses: cycjimmy/semantic-release-action@v2 uses: cycjimmy/semantic-release-action@v3
with: with:
dry_run: true dry_run: true
env: env:
@ -195,13 +195,15 @@ The action can be used with `extends` option to extend an existing [sharable con
```yaml ```yaml
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Semantic Release - name: Semantic Release
uses: cycjimmy/semantic-release-action@v2 uses: cycjimmy/semantic-release-action@v3
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.
extends: | extends: |
@semantic-release/apm-config @semantic-release/apm-config@^9.0.0
@mycompany/override-config
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
@ -213,9 +215,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@v2 uses: actions/checkout@v3
- name: Semantic Release - name: Semantic Release
uses: cycjimmy/semantic-release-action@v2 uses: cycjimmy/semantic-release-action@v3
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,23 +228,23 @@ steps:
### Outputs ### Outputs
| Output Parameter | Description | | Output Parameter | Description |
|:-------------------------:|---| |:-------------------------:|-----------------------------------------------------------------------------------------------------------------------------------|
| new_release_published | Whether a new release was published (`true` or `false`) | | new_release_published | Whether a new release was published. The return value is in the form of a string. (`"true"` or `"false"`) |
| new_release_version | Version of the new release. (e.g. `1.3.0`) | | new_release_version | Version of the new release. (e.g. `"1.3.0"`) |
| new_release_major_version | Major version of the new release. (e.g. `1`) | | new_release_major_version | Major version of the new release. (e.g. `"1"`) |
| new_release_minor_version | Minor version of the new release. (e.g. `3`) | | new_release_minor_version | Minor version of the new release. (e.g. `"3"`) |
| new_release_patch_version | Patch version of the new release. (e.g. `0`) | | new_release_patch_version | Patch version of the new release. (e.g. `"0"`) |
| new_release_channel | The distribution channel on which the last release was initially made available (undefined for the default distribution channel). | | new_release_channel | The distribution channel on which the last release was initially made available (undefined for the default distribution channel). |
| new_release_notes | The release notes for the new release. | | new_release_notes | The release notes for the new release. |
| last_release_version | Version of the previous release, if there was one. (e.g. `1.2.0`) | | last_release_version | Version of the previous release, if there was one. (e.g. `"1.2.0"`) |
#### Using Output Variables: #### Using Output Variables:
```yaml ```yaml
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v3
- name: Semantic Release - name: Semantic Release
uses: cycjimmy/semantic-release-action@v2 uses: cycjimmy/semantic-release-action@v3
id: semantic # Need an `id` for output variables id: semantic # Need an `id` for output variables
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@ -275,8 +277,8 @@ This project is released under the [MIT License][license-url].
[semantic-url]: https://github.com/semantic-release/semantic-release [semantic-url]: https://github.com/semantic-release/semantic-release
[license-image]: https://img.shields.io/npm/l/@cycjimmy/semantic-release-action.svg [license-image]: https://img.shields.io/npm/l/@cycjimmy/semantic-release-action.svg
[license-url]: https://github.com/cycjimmy/semantic-release-action/blob/master/LICENSE [license-url]: https://github.com/cycjimmy/semantic-release-action/blob/main/LICENSE
[changelog-url]: https://github.com/cycjimmy/semantic-release-action/blob/master/docs/CHANGELOG.md [changelog-url]: https://github.com/cycjimmy/semantic-release-action/blob/main/docs/CHANGELOG.md
[github-packages-registry]: https://github.com/features/packages [github-packages-registry]: https://github.com/features/packages

View file

@ -44,5 +44,5 @@ outputs:
last_release_version: last_release_version:
description: 'Version of the previous release, if there was one.' description: 'Version of the previous release, if there was one.'
runs: runs:
using: 'node12' using: 'node16'
main: 'index.js' main: 'index.js'

View file

@ -1,3 +1,29 @@
## [3.1.1](https://github.com/cycjimmy/semantic-release-action/compare/v3.1.0...v3.1.1) (2022-08-30)
### Bug Fixes
* set last_release_version output even if no release has been published ([b1467cd](https://github.com/cycjimmy/semantic-release-action/commit/b1467cd17e70d963d7925a60266adb249ee2223d))
# [3.1.0](https://github.com/cycjimmy/semantic-release-action/compare/v3.0.0...v3.1.0) (2022-08-05)
### Features
* handle versioned extends inputs correctly ([4a51b9f](https://github.com/cycjimmy/semantic-release-action/commit/4a51b9fada7267737750fded8b8edfb275acbbbb))
# [3.0.0](https://github.com/cycjimmy/semantic-release-action/compare/v2.7.0...v3.0.0) (2022-03-03)
### Features
* switch operating environment to node16 ([b5f16ae](https://github.com/cycjimmy/semantic-release-action/commit/b5f16ae54b21667e3af8a1bd015ec069c8237674)), closes [#92](https://github.com/cycjimmy/semantic-release-action/issues/92) [#96](https://github.com/cycjimmy/semantic-release-action/issues/96)
### BREAKING CHANGES
* switch operating environment to node16
# [2.7.0](https://github.com/cycjimmy/semantic-release-action/compare/v2.6.0...v2.7.0) (2021-12-12) # [2.7.0](https://github.com/cycjimmy/semantic-release-action/compare/v2.6.0...v2.7.0) (2021-12-12)

9269
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
{ {
"name": "@cycjimmy/semantic-release-action", "name": "@cycjimmy/semantic-release-action",
"version": "2.7.0", "version": "3.1.1",
"description": "GitHub Action for Semantic Release", "description": "GitHub Action for Semantic Release",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
@ -22,6 +22,9 @@
"homepage": "https://github.com/cycjimmy/semantic-release-action#readme", "homepage": "https://github.com/cycjimmy/semantic-release-action#readme",
"dependencies": { "dependencies": {
"@actions/core": "^1.6.0", "@actions/core": "^1.6.0",
"@cycjimmy/awesome-js-funcs": "^3.1.0" "@cycjimmy/awesome-js-funcs": "^4.0.4",
"@semantic-release/changelog": "^6.0.1",
"@semantic-release/git": "^10.0.1",
"semantic-release": "^19.0.5"
} }
} }

View file

@ -1,5 +1,5 @@
const core = require('@actions/core'); const core = require('@actions/core');
const stringToJson = require('@cycjimmy/awesome-js-funcs/cjs/typeConversion/stringToJson').default; const stringToJson = require('@cycjimmy/awesome-js-funcs/cjs/typeConversion/stringToJson.cjs').default;
const inputs = require('./inputs.json'); const inputs = require('./inputs.json');
/** /**
@ -68,7 +68,11 @@ exports.handleExtends = () => {
const extend = core.getInput(inputs.extends); const extend = core.getInput(inputs.extends);
if (extend) { if (extend) {
return { extends: extend }; const extendModuleNames = extend.split(/\r?\n/)
.map((name) => name.replace(/(?<!^)@.+/, ''))
return {
extends: extendModuleNames
};
} else { } else {
return {}; return {};
} }

View file

@ -14,6 +14,11 @@ module.exports = async (result) => {
const {lastRelease, commits, nextRelease, releases} = result; const {lastRelease, commits, nextRelease, releases} = result;
if (lastRelease.version) {
core.debug(`The last release was "${lastRelease.version}".`);
core.setOutput(outputs.last_release_version, lastRelease.version)
}
if (!nextRelease) { if (!nextRelease) {
core.debug('No release published.'); core.debug('No release published.');
return Promise.resolve(); return Promise.resolve();
@ -21,10 +26,6 @@ module.exports = async (result) => {
core.debug(`Published ${nextRelease.type} release version ${nextRelease.version} containing ${commits.length} commits.`); core.debug(`Published ${nextRelease.type} release version ${nextRelease.version} containing ${commits.length} commits.`);
if (lastRelease.version) {
core.debug(`The last release was "${lastRelease.version}".`);
}
for (const release of releases) { for (const release of releases) {
core.debug(`The release was published with plugin "${release.pluginName}".`); core.debug(`The release was published with plugin "${release.pluginName}".`);
} }
@ -40,5 +41,4 @@ module.exports = async (result) => {
core.setOutput(outputs.new_release_patch_version, patch); core.setOutput(outputs.new_release_patch_version, patch);
core.setOutput(outputs.new_release_channel, channel); core.setOutput(outputs.new_release_channel, channel);
core.setOutput(outputs.new_release_notes, notes); core.setOutput(outputs.new_release_notes, notes);
core.setOutput(outputs.last_release_version, lastRelease.version)
}; };