mirror of
https://github.com/cycjimmy/semantic-release-action.git
synced 2025-11-07 18:56:56 +00:00
feat(branches): support branches of semantic-release v16+
support branches of semantic-release v16+ #24 #25
This commit is contained in:
parent
c7a37752d9
commit
706c0ef960
8 changed files with 97 additions and 26 deletions
51
.github/workflows/testRelease.yml
vendored
51
.github/workflows/testRelease.yml
vendored
|
|
@ -9,22 +9,28 @@ on:
|
|||
- cron: 0 2 * * 0
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: release
|
||||
test-semantic-latest:
|
||||
name: test-semantic-latest
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Semantic Release
|
||||
uses: cycjimmy/semantic-release-action@v2
|
||||
uses: ./
|
||||
id: semantic
|
||||
with:
|
||||
dry_run: true
|
||||
branches: |
|
||||
[
|
||||
'master',
|
||||
{name: 'beta', prerelease: true},
|
||||
{name: 'alpha', prerelease: true}
|
||||
]
|
||||
branch: master
|
||||
extra_plugins: |
|
||||
@semantic-release/git
|
||||
@semantic-release/changelog
|
||||
dry_run: true
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
|
@ -36,5 +42,40 @@ jobs:
|
|||
echo ${{ steps.semantic.outputs.new_release_major_version }}
|
||||
echo ${{ steps.semantic.outputs.new_release_minor_version }}
|
||||
echo ${{ steps.semantic.outputs.new_release_patch_version }}
|
||||
echo ${{ steps.semantic.outputs.new_release_notes }}
|
||||
|
||||
test-semantic-v15:
|
||||
name: test-semantic-v15
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Semantic Release
|
||||
uses: ./
|
||||
id: semantic_v15
|
||||
with:
|
||||
semantic_version: 15
|
||||
dry_run: true
|
||||
branches: |
|
||||
[
|
||||
'master',
|
||||
{name: 'beta', prerelease: true},
|
||||
{name: 'alpha', prerelease: true}
|
||||
]
|
||||
branch: master
|
||||
extra_plugins: |
|
||||
@semantic-release/git@7
|
||||
@semantic-release/changelog@3
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
- name: Test Outputs
|
||||
if: steps.semantic.outputs.new_release_published == 'true'
|
||||
run: |
|
||||
echo ${{ steps.semantic.outputs.new_release_version }}
|
||||
echo ${{ steps.semantic.outputs.new_release_major_version }}
|
||||
echo ${{ steps.semantic.outputs.new_release_minor_version }}
|
||||
echo ${{ steps.semantic.outputs.new_release_patch_version }}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -17,8 +17,9 @@ GitHub Action for [Semantic Release](https://github.com/semantic-release/semanti
|
|||
|
||||
#### Step3: Add a [Workflow File](https://help.github.com/en/articles/workflow-syntax-for-github-actions) to your repository to create custom automated processes.
|
||||
* inputs:
|
||||
* `branch`: [Optional] The branch on which releases should happen. It will override the branch attribute in your configuration file. If the attribute is not configured on both sides, the default is master.
|
||||
* `semantic_version`: [Optional] Specify specifying version range for semantic-release. If no version range is specified, latest version will be used by default.
|
||||
* `branches`: [Optional] The branches on which releases should happen. It 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', 'master', 'next', 'next-major', {name: 'beta', prerelease: true}, {name: 'alpha', prerelease: true}]`. **Support for semantic-release above v16**. See https://semantic-release.gitbook.io/semantic-release/usage/configuration#branches for more information.
|
||||
* `branch`: [Optional] The branch on which releases should happen. It will override the branch attribute in your configuration file. If the attribute is not configured on both sides, the default is master. **Support for semantic-release older than v16**.
|
||||
* `extra_plugins`: [Optional] Extra plugins for pre-install. You can also specify specifying version range for the extra plugins if you prefer.
|
||||
* `dry_run`: [Optional] Whether to run semantic release in `dry-run` mode. It will override the dryRun attribute in your configuration file.
|
||||
* outputs:
|
||||
|
|
|
|||
13
action.yml
13
action.yml
|
|
@ -5,13 +5,20 @@ branding:
|
|||
icon: 'package'
|
||||
color: 'orange'
|
||||
inputs:
|
||||
branch:
|
||||
description: 'The branch on which releases should happen. It will override the branch attribute in your configuration file. If the attribute is not configured on both sides, the default is master.'
|
||||
semantic_version:
|
||||
description: 'Specify specifying version range for semantic-release. If no version range is specified, semantic-release@^15 will be used by default.'
|
||||
required: false
|
||||
description: 'Specify specifying version range for semantic-release. If no version range is specified, latest version will be used by default'
|
||||
branches:
|
||||
required: false
|
||||
description: 'The branches on which releases should happen. It will override the branches attribute in your configuration file. Support for semantic-release above v16. See https://semantic-release.gitbook.io/semantic-release/usage/configuration#branches for more information.'
|
||||
branch:
|
||||
required: false
|
||||
description: 'The branch on which releases should happen. It will override the branch attribute in your configuration file. If the attribute is not configured on both sides, the default is master. Support for semantic-release older than v16.'
|
||||
extra_plugins:
|
||||
required: false
|
||||
description: 'Extra plugins for pre-install. You can also specify specifying version range for the extra plugins if you prefer.'
|
||||
dry_run:
|
||||
required: false
|
||||
description: 'Whether to run semantic release in `dry-run` mode. It will override the dryRun attribute in your configuration file'
|
||||
outputs:
|
||||
new_release_published:
|
||||
|
|
|
|||
11
package-lock.json
generated
11
package-lock.json
generated
|
|
@ -5,9 +5,14 @@
|
|||
"requires": true,
|
||||
"dependencies": {
|
||||
"@actions/core": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.0.tgz",
|
||||
"integrity": "sha512-ZKdyhlSlyz38S6YFfPnyNgCDZuAF2T0Qv5eHflNWytPS8Qjvz39bZFMry9Bb/dpSnqWcNeav5yM2CTYpJeY+Dw=="
|
||||
"version": "1.2.3",
|
||||
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.3.tgz",
|
||||
"integrity": "sha512-Wp4xnyokakM45Uuj4WLUxdsa8fJjKVl1fDTsPbTEcTcuu0Nb26IPQbOtjmnfaCPGcaoPOOqId8H9NapZ8gii4w=="
|
||||
},
|
||||
"@cycjimmy/awesome-js-funcs": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@cycjimmy/awesome-js-funcs/-/awesome-js-funcs-2.3.0.tgz",
|
||||
"integrity": "sha512-HXJrv0S1gzjP9h2cmE57m+0XnVsGIsidPEjxUR5i50iGIxbjEe1EhL6iSh2P1LXdjjbt1U/UHj6n93yzDwt1gw=="
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
},
|
||||
"homepage": "https://github.com/cycjimmy/semantic-release-action#readme",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.2.0"
|
||||
"@actions/core": "^1.2.3",
|
||||
"@cycjimmy/awesome-js-funcs": "^2.3.0"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,29 +1,44 @@
|
|||
const core = require('@actions/core');
|
||||
const stringToJson = require('@cycjimmy/awesome-js-funcs/typeConversion/stringToJson').default;
|
||||
const inputs = require('./inputs.json');
|
||||
|
||||
/**
|
||||
* Handle Branch Option
|
||||
* Handle Branches Option
|
||||
* @returns {{}|{branch: string}}
|
||||
*/
|
||||
exports.handleBranchOption = () => {
|
||||
const branchOption = {};
|
||||
exports.handleBranchesOption = () => {
|
||||
const branchesOption = {};
|
||||
const branches = core.getInput(inputs.branches);
|
||||
const branch = core.getInput(inputs.branch);
|
||||
|
||||
if (!branch) {
|
||||
return branchOption;
|
||||
}
|
||||
core.debug(`branches input: ${branches}`);
|
||||
core.debug(`branch input: ${branch}`);
|
||||
|
||||
const semanticVersion = require('semantic-release/package.json').version;
|
||||
const semanticMajorVersion = Number(semanticVersion.replace(/\..+/g, ''));
|
||||
core.debug(`semanticMajorVersion: ${semanticMajorVersion}`);
|
||||
|
||||
// older than v16
|
||||
if (semanticMajorVersion < 16) {
|
||||
branchOption.branch = branch;
|
||||
} else {
|
||||
branchOption.branches = [branch];
|
||||
if (!branch) {
|
||||
return branchesOption;
|
||||
}
|
||||
|
||||
return branchOption;
|
||||
branchesOption.branch = branch;
|
||||
return branchesOption;
|
||||
}
|
||||
|
||||
// above v16
|
||||
const strNeedConvertToJson = branches || branch || '';
|
||||
|
||||
if (!strNeedConvertToJson) {
|
||||
return branchesOption;
|
||||
}
|
||||
|
||||
const jsonOrStr = stringToJson('' + strNeedConvertToJson);
|
||||
core.debug(`Converted branches attribute: ${JSON.stringify(jsonOrStr)}`);
|
||||
branchesOption.branches = jsonOrStr;
|
||||
return branchesOption;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
const core = require('@actions/core');
|
||||
const {handleBranchOption, handleDryRunOption} = require('./handleOptions');
|
||||
const {handleBranchesOption, handleDryRunOption} = require('./handleOptions');
|
||||
const setUpJob = require('./setUpJob.task');
|
||||
const installSpecifyingVersionSemantic = require('./installSpecifyingVersionSemantic.task');
|
||||
const preInstallPlugins = require('./preInstallPlugins.task');
|
||||
|
|
@ -17,7 +17,7 @@ const release = async () => {
|
|||
|
||||
const semanticRelease = require('semantic-release');
|
||||
const result = await semanticRelease({
|
||||
...(handleBranchOption()),
|
||||
...(handleBranchesOption()),
|
||||
...(handleDryRunOption()),
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
"branch": "branch",
|
||||
"semantic_version": "semantic_version",
|
||||
"branches": "branches",
|
||||
"branch": "branch",
|
||||
"extra_plugins": "extra_plugins",
|
||||
"dry_run": "dry_run"
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue