mirror of
https://github.com/cycjimmy/semantic-release-action.git
synced 2026-05-14 20:40:32 +00:00
Merge 301b06daaa into fd0b87f65a
This commit is contained in:
commit
07b7e87ae5
13 changed files with 956 additions and 901 deletions
11
index.js
11
index.js
|
|
@ -1,5 +1,9 @@
|
|||
const exec = require('./src/_exec');
|
||||
const path = require('path');
|
||||
import exec from './src/_exec.js';
|
||||
import path, {dirname} from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
const run = async () => {
|
||||
// Install Dependencies
|
||||
|
|
@ -13,7 +17,8 @@ const run = async () => {
|
|||
}
|
||||
}
|
||||
|
||||
require('./src/index')();
|
||||
const mod = await import('./src/index.js');
|
||||
await mod.default();
|
||||
};
|
||||
|
||||
run().catch(console.error);
|
||||
|
|
|
|||
1729
package-lock.json
generated
1729
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -3,6 +3,7 @@
|
|||
"version": "6.0.0",
|
||||
"description": "GitHub Action for Semantic Release",
|
||||
"main": "index.js",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
|
|
@ -21,11 +22,10 @@
|
|||
},
|
||||
"homepage": "https://github.com/cycjimmy/semantic-release-action#readme",
|
||||
"dependencies": {
|
||||
"@actions/core": "^3.0.0",
|
||||
"@actions/core": "^3.0.1",
|
||||
"@actions/io": "^3.0.2",
|
||||
"@cycjimmy/awesome-js-funcs": "^4.0.9",
|
||||
"@semantic-release/changelog": "^6.0.3",
|
||||
"@semantic-release/git": "^10.0.1",
|
||||
"semantic-release": "^25.0.2"
|
||||
"semantic-release": "^25.0.3"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = {
|
||||
export default {
|
||||
"dryRun": false,
|
||||
"plugins": [
|
||||
"@semantic-release/commit-analyzer",
|
||||
|
|
|
|||
|
|
@ -1,2 +1,4 @@
|
|||
const util = require('util');
|
||||
module.exports = util.promisify(require('child_process').exec);
|
||||
import { promisify } from 'util';
|
||||
import { exec } from 'child_process';
|
||||
|
||||
export default promisify(exec);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
const io = require('@actions/io');
|
||||
import * as io from '@actions/io';
|
||||
|
||||
/**
|
||||
* Clean up `.npmrc` file in the repo after releasing
|
||||
* @returns {Promise<never>}
|
||||
*/
|
||||
module.exports = async () => {
|
||||
export default async () => {
|
||||
await io.rmRF('.npmrc');
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
const core = require('@actions/core');
|
||||
const stringToJson = require('@cycjimmy/awesome-js-funcs/cjs/typeConversion/stringToJson.cjs').default;
|
||||
const inputs = require('./inputs.json');
|
||||
import * as core from '@actions/core';
|
||||
import stringToJson from './stringToJson.js';
|
||||
import inputs from './inputs.json' with { type: 'json' };;
|
||||
|
||||
/**
|
||||
* Handle Branches Option
|
||||
* @returns {{}|{branch: string}}
|
||||
*/
|
||||
exports.handleBranchesOption = () => {
|
||||
export const handleBranchesOption = async () => {
|
||||
const branchesOption = {};
|
||||
const branches = core.getInput(inputs.branches);
|
||||
const branch = core.getInput(inputs.branch);
|
||||
|
|
@ -14,8 +14,8 @@ exports.handleBranchesOption = () => {
|
|||
core.debug(`branches input: ${branches}`);
|
||||
core.debug(`branch input: ${branch}`);
|
||||
|
||||
const semanticVersion = require('semantic-release/package.json').version;
|
||||
const semanticMajorVersion = Number(semanticVersion.replace(/\..+/g, ''));
|
||||
const { default: { version } } = await import('semantic-release/package.json', { with: { type: 'json' } });
|
||||
const semanticMajorVersion = Number(version.replace(/\..+/g, ''));
|
||||
core.debug(`semanticMajorVersion: ${semanticMajorVersion}`);
|
||||
|
||||
// older than v16
|
||||
|
|
@ -45,7 +45,7 @@ exports.handleBranchesOption = () => {
|
|||
* Handle DryRun Option
|
||||
* @returns {{}|{dryRun: boolean}}
|
||||
*/
|
||||
exports.handleDryRunOption = () => {
|
||||
export const handleDryRunOption = () => {
|
||||
const dryRun = core.getInput(inputs.dry_run);
|
||||
core.debug(`dryRun input: ${dryRun}`);
|
||||
|
||||
|
|
@ -65,7 +65,7 @@ exports.handleDryRunOption = () => {
|
|||
* Handle Ci Option
|
||||
* @returns {{}|{ci: boolean}}
|
||||
*/
|
||||
exports.handleCiOption = () => {
|
||||
export const handleCiOption = () => {
|
||||
const ci = core.getInput(inputs.ci);
|
||||
core.debug(`ci input: ${ci}`);
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ exports.handleCiOption = () => {
|
|||
* Handle Extends Option
|
||||
* @returns {{}|{extends: Array}|{extends: String}}
|
||||
*/
|
||||
exports.handleExtends = () => {
|
||||
export const handleExtends = () => {
|
||||
const extend = core.getInput(inputs.extends);
|
||||
core.debug(`extend input: ${extend}`);
|
||||
|
||||
|
|
@ -104,7 +104,7 @@ exports.handleExtends = () => {
|
|||
* Handle TagFormat Option
|
||||
* @returns {{}|{tagFormat: String}}
|
||||
*/
|
||||
exports.handleTagFormat = () => {
|
||||
export const handleTagFormat = () => {
|
||||
const tagFormat = core.getInput(inputs.tag_format);
|
||||
core.debug(`citagFormat input: ${tagFormat}`);
|
||||
|
||||
|
|
@ -121,7 +121,7 @@ exports.handleTagFormat = () => {
|
|||
* Handle repository-url Option
|
||||
* @returns {{}|{r: String}}
|
||||
*/
|
||||
exports.handleRepositoryUrlOption = () => {
|
||||
export const handleRepositoryUrlOption = () => {
|
||||
const repositoryUrl = core.getInput(inputs.repository_url);
|
||||
core.debug(`repository_url input: ${repositoryUrl}`);
|
||||
|
||||
|
|
|
|||
20
src/index.js
20
src/index.js
|
|
@ -1,18 +1,18 @@
|
|||
const core = require('@actions/core');
|
||||
const {
|
||||
import * as core from '@actions/core';
|
||||
import {
|
||||
handleBranchesOption,
|
||||
handleDryRunOption,
|
||||
handleCiOption,
|
||||
handleExtends,
|
||||
handleTagFormat,
|
||||
handleRepositoryUrlOption,
|
||||
} = require('./handleOptions');
|
||||
const setUpJob = require('./setUpJob.task');
|
||||
const installSpecifyingVersionSemantic = require('./installSpecifyingVersionSemantic.task');
|
||||
const preInstall = require('./preInstall.task');
|
||||
const cleanupNpmrc = require('./cleanupNpmrc.task');
|
||||
const windUpJob = require('./windUpJob.task');
|
||||
const inputs = require('./inputs.json');
|
||||
} from './handleOptions.js';
|
||||
import setUpJob from './setUpJob.task.js';
|
||||
import installSpecifyingVersionSemantic from './installSpecifyingVersionSemantic.task.js';
|
||||
import preInstall from './preInstall.task.js';
|
||||
import cleanupNpmrc from './cleanupNpmrc.task.js';
|
||||
import windUpJob from './windUpJob.task.js';
|
||||
import inputs from './inputs.json' with { type: 'json' };;
|
||||
|
||||
/**
|
||||
* Release main task
|
||||
|
|
@ -46,7 +46,7 @@ const release = async () => {
|
|||
await windUpJob(result);
|
||||
};
|
||||
|
||||
module.exports = () => {
|
||||
export default async () => {
|
||||
core.debug('Initialization successful');
|
||||
release().catch(core.setFailed);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,13 +1,17 @@
|
|||
const path = require('path');
|
||||
const core = require('@actions/core');
|
||||
const exec = require('./_exec');
|
||||
const inputs = require('./inputs.json');
|
||||
import * as core from '@actions/core';
|
||||
import exec from './_exec.js';
|
||||
import inputs from './inputs.json' with { type: 'json' };;
|
||||
import path, {dirname} from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
/**
|
||||
* Install Specifying Version semantic-release
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
module.exports = async () => {
|
||||
export default async () => {
|
||||
const semantic_version = core.getInput(inputs.semantic_version);
|
||||
const versionSuffix = semantic_version
|
||||
? `@${semantic_version}`
|
||||
|
|
|
|||
|
|
@ -1,12 +1,16 @@
|
|||
const path = require('path');
|
||||
const core = require('@actions/core');
|
||||
const exec = require('./_exec');
|
||||
import path, {dirname} from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import * as core from '@actions/core';
|
||||
import exec from './_exec.js';
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
/**
|
||||
* Pre-install extra dependecies
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
module.exports = async extras => {
|
||||
export default async extras => {
|
||||
if (!extras) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,19 @@
|
|||
const path = require('path');
|
||||
const core = require('@actions/core');
|
||||
const outputs = require('./outputs.json');
|
||||
import path, { dirname } from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
import * as core from '@actions/core';
|
||||
import outputs from './outputs.json' with { type: 'json' };
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
/**
|
||||
* setUpJob
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
module.exports = async () => {
|
||||
export default async () => {
|
||||
// set outputs default
|
||||
core.setOutput(outputs.new_release_published, 'false');
|
||||
|
||||
core.debug('action_workspace: ' + path.resolve(__dirname, '..'));
|
||||
core.debug('process.cwd: ' + process.cwd());
|
||||
|
||||
return Promise.resolve();
|
||||
};
|
||||
|
|
|
|||
11
src/stringToJson.js
Normal file
11
src/stringToJson.js
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
// stringToJson.js
|
||||
const strToJsonFunc = (str) => (new Function(`return ${str}`))();
|
||||
const strToJson = (str) => {
|
||||
try {
|
||||
return strToJsonFunc(str);
|
||||
} catch (e) {
|
||||
return str;
|
||||
}
|
||||
};
|
||||
|
||||
export default (str) => strToJson(strToJson(str));
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
const core = require('@actions/core');
|
||||
const outputs = require('./outputs.json');
|
||||
import * as core from '@actions/core';
|
||||
import outputs from './outputs.json' with { type: 'json' };
|
||||
|
||||
/**
|
||||
* windUpJob
|
||||
* @param result
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
module.exports = async (result) => {
|
||||
export default async (result) => {
|
||||
const resolved = await result;
|
||||
if (!resolved) {
|
||||
core.debug('No release published.');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue