mirror of
https://github.com/cycjimmy/semantic-release-action.git
synced 2025-11-07 10:46:56 +00:00
feat(inputs): add semantic_version to specify version range(#3)
semantic_version: Specify specifying version range for semantic-release. If no version range is specified, semantic-release@^15 will be used by default.
This commit is contained in:
parent
56fc83231a
commit
55e8862f17
5 changed files with 33 additions and 1 deletions
|
|
@ -18,6 +18,7 @@ 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.
|
#### 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:
|
* 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.
|
* `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, semantic-release@^15 will be used by default.
|
||||||
* `extra_plugins`: [Optional] Extra plugins for pre-install. You can also specify specifying version range for the extra plugins if you prefer.
|
* `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.
|
* `dry_run`: [Optional] Whether to run semantic release in "dry-run" mode. It will override the dryRun attribute in your configuration file.
|
||||||
* outputs:
|
* outputs:
|
||||||
|
|
@ -45,6 +46,7 @@ steps:
|
||||||
id: semantic # Need an `id` for output variables
|
id: semantic # Need an `id` for output variables
|
||||||
with:
|
with:
|
||||||
branch: master
|
branch: master
|
||||||
|
semantic_version: 15.13.28
|
||||||
# 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/git
|
@semantic-release/git
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@ branding:
|
||||||
inputs:
|
inputs:
|
||||||
branch:
|
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.'
|
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.'
|
||||||
extra_plugins:
|
extra_plugins:
|
||||||
description: 'Extra plugins for pre-install. You can also specify specifying version range for the extra plugins if you prefer.'
|
description: 'Extra plugins for pre-install. You can also specify specifying version range for the extra plugins if you prefer.'
|
||||||
dry_run:
|
dry_run:
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
const core = require('@actions/core');
|
const core = require('@actions/core');
|
||||||
const semanticRelease = require('semantic-release');
|
|
||||||
const {handleBranchOption, handleDryRunOption} = require('./handleOptions');
|
const {handleBranchOption, handleDryRunOption} = require('./handleOptions');
|
||||||
const setUpJob = require('./setUpJob.task');
|
const setUpJob = require('./setUpJob.task');
|
||||||
|
const installSpecifyingVersionSemantic = require('./installSpecifyingVersionSemantic.task');
|
||||||
const preInstallPlugins = require('./preInstallPlugins.task');
|
const preInstallPlugins = require('./preInstallPlugins.task');
|
||||||
const cleanupNpmrc = require('./cleanupNpmrc.task');
|
const cleanupNpmrc = require('./cleanupNpmrc.task');
|
||||||
const windUpJob = require('./windUpJob.task');
|
const windUpJob = require('./windUpJob.task');
|
||||||
|
|
@ -12,8 +12,10 @@ const windUpJob = require('./windUpJob.task');
|
||||||
*/
|
*/
|
||||||
const release = async () => {
|
const release = async () => {
|
||||||
await setUpJob();
|
await setUpJob();
|
||||||
|
await installSpecifyingVersionSemantic();
|
||||||
await preInstallPlugins();
|
await preInstallPlugins();
|
||||||
|
|
||||||
|
const semanticRelease = require('semantic-release');
|
||||||
const result = await semanticRelease({
|
const result = await semanticRelease({
|
||||||
...(handleBranchOption()),
|
...(handleBranchOption()),
|
||||||
...(handleDryRunOption()),
|
...(handleDryRunOption()),
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"branch": "branch",
|
"branch": "branch",
|
||||||
|
"semantic_version": "semantic_version",
|
||||||
"extra_plugins": "extra_plugins",
|
"extra_plugins": "extra_plugins",
|
||||||
"dry_run": "dry_run"
|
"dry_run": "dry_run"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
25
src/installSpecifyingVersionSemantic.task.js
Normal file
25
src/installSpecifyingVersionSemantic.task.js
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
const path = require('path');
|
||||||
|
const core = require('@actions/core');
|
||||||
|
const exec = require('./_exec');
|
||||||
|
const inputs = require('./inputs.json');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Install Specifying Version semantic-release
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
module.exports = async () => {
|
||||||
|
const semantic_version = core.getInput(inputs.semantic_version);
|
||||||
|
|
||||||
|
if (!semantic_version) {
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
|
const {stdout, stderr} = await exec(`npm install semantic-release@${semantic_version}`, {
|
||||||
|
cwd: path.resolve(__dirname)
|
||||||
|
});
|
||||||
|
core.debug(stdout);
|
||||||
|
|
||||||
|
if (stderr) {
|
||||||
|
return Promise.reject(stderr);
|
||||||
|
}
|
||||||
|
};
|
||||||
Loading…
Reference in a new issue