From 0caf7fc08a437dde767568c4f24755c64982980d Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Thu, 6 Jun 2024 11:28:12 +0800 Subject: [PATCH] fix: fix draft input param --- dist/main.js | 4 ++-- src/main.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/main.js b/dist/main.js index 4d62c18..234330e 100644 --- a/dist/main.js +++ b/dist/main.js @@ -41021,9 +41021,9 @@ var semver_default = /*#__PURE__*/__webpack_require__.n(semver); ;// CONCATENATED MODULE: ./src/utils.ts var getVersion=function getVersion(ver){var currentVersion='';ver.replace(/([v|V]\d(\.\d+){0,2})/i,function(str){currentVersion=str;return str;});return currentVersion;}; ;// CONCATENATED MODULE: ./src/main.ts -function run(){return _run.apply(this,arguments);}function _run(){_run=(0,asyncToGenerator/* default */.A)(/*#__PURE__*/(0,regeneratorRuntime/* default */.A)().mark(function _callee(){var _github$context$paylo,_github$context$paylo2,myToken,test,body,release,prerelease,draft,packagePath,inputVersion,octokit,_github$context$repo,owner,repo,commit,latestRelease,preTag,_semver$coerce,_semver$coerce2,preversion,preversionNumber,_semver$coerce3,tagSha,version,resolvePackagePath,pkg,listRelease,_iterator,_step,item,tag_name,_tagSha,_semver$coerce4,_semver$coerce5,_tagSha2;return (0,regeneratorRuntime/* default */.A)().wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:_context.prev=0;myToken=core.getInput('token');/** The regular expression matches the submitted content. */test=core.getInput('test');/** An optional body for the release. */body=core.getInput('body')||'';/** Optionally marks this tag as `release`. Set to `true` to enable. */release=core.getInput('release');/** Optionally marks this release as `prerelease`. Set to `true` to enable. */prerelease=core.getInput('prerelease');/** Optionally marks this release as a draft release. Set to true to enable. */draft=core.getInput('draft');/** The path of the `package.json` file. Default `package.json`. */packagePath=core.getInput('package-path');// Example: v1.0.0 +function run(){return _run.apply(this,arguments);}function _run(){_run=(0,asyncToGenerator/* default */.A)(/*#__PURE__*/(0,regeneratorRuntime/* default */.A)().mark(function _callee(){var _core$getInput,_github$context$paylo,_github$context$paylo2,myToken,test,body,release,prerelease,draft,packagePath,inputVersion,octokit,_github$context$repo,owner,repo,commit,latestRelease,preTag,_semver$coerce,_semver$coerce2,preversion,preversionNumber,_semver$coerce3,tagSha,version,resolvePackagePath,pkg,listRelease,_iterator,_step,item,tag_name,_tagSha,_semver$coerce4,_semver$coerce5,_tagSha2;return (0,regeneratorRuntime/* default */.A)().wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:_context.prev=0;myToken=core.getInput('token');/** The regular expression matches the submitted content. */test=core.getInput('test');/** An optional body for the release. */body=core.getInput('body')||'';/** Optionally marks this tag as `release`. Set to `true` to enable. */release=core.getInput('release');/** Optionally marks this release as `prerelease`. Set to `true` to enable. */prerelease=core.getInput('prerelease');/** Optionally marks this release as a draft release. Set to true to enable. */draft=(_core$getInput=core.getInput('draft'))!==null&&_core$getInput!==void 0?_core$getInput:"false";/** The path of the `package.json` file. Default `package.json`. */packagePath=core.getInput('package-path');// Example: v1.0.0 inputVersion=core.getInput('version');octokit=github.getOctokit(myToken);_github$context$repo=github.context.repo,owner=_github$context$repo.owner,repo=_github$context$repo.repo;commit=((_github$context$paylo=github.context.payload)===null||_github$context$paylo===void 0?void 0:(_github$context$paylo2=_github$context$paylo.head_commit)===null||_github$context$paylo2===void 0?void 0:_github$context$paylo2.message)||'';core.info("commit: ".concat(commit||'\x1b[31;1mNo commit found\x1b[0m'));_context.next=15;return octokit.rest.repos.getLatestRelease({owner:owner,repo:repo});case 15:latestRelease=_context.sent;core.setOutput('successful',false);if(!(latestRelease.status!==200)){_context.next=20;break;}core.setFailed("Failed to get latest release (status=".concat(latestRelease.status,")"));return _context.abrupt("return");case 20:core.startGroup("Latest Release Info: (\x1B[33;1m".concat(latestRelease.data.tag_name,"\x1B[0m) created_at(\x1B[37;1m").concat(latestRelease.data.created_at,"\x1B[0m)"));core.info("".concat(JSON.stringify(latestRelease.data,null,2)));core.endGroup();core.startGroup("Payload Info:");core.info("".concat(JSON.stringify(github.context.payload,null,2)));core.endGroup();core.info("Repos ".concat(owner,"/").concat(repo," List Tag"));// Example: v1.2.1 -preTag=latestRelease.data.tag_name||'';if(preTag&&semver_default().valid(preTag)){preversion=((_semver$coerce=semver_default().coerce(preTag))===null||_semver$coerce===void 0?void 0:_semver$coerce.version)||'';preversionNumber=((_semver$coerce2=semver_default().coerce(preTag))===null||_semver$coerce2===void 0?void 0:_semver$coerce2.raw)||'';core.setOutput('version',preversion);core.setOutput('preversion',preversion);core.setOutput('preversionNumber',preversionNumber);core.setOutput('majorVersion',semver_default().major(preTag));core.setOutput('minorVersion',semver_default().minor(preTag));core.setOutput('patchVersion',semver_default().patch(preTag));}if(preTag&&!semver_default().valid(preTag)){core.warning("Invalid version number \x1B[31;1m\"".concat(preTag,"\"\x1B[0m."));}if(!(inputVersion&&!semver_default().valid(inputVersion))){_context.next=33;break;}core.setFailed("Invalid version number \x1B[31;1m\"".concat(inputVersion,"\"\x1B[0m."));return _context.abrupt("return");case 33:if(!(inputVersion&&semver_default().valid(inputVersion))){_context.next=58;break;}core.setOutput('version',inputVersion);core.setOutput('versionNumber',(_semver$coerce3=semver_default().coerce(inputVersion))===null||_semver$coerce3===void 0?void 0:_semver$coerce3.raw);core.setOutput('majorVersion',semver_default().major(inputVersion));core.setOutput('minorVersion',semver_default().minor(inputVersion));core.setOutput('patchVersion',semver_default().patch(inputVersion));core.info("".concat(owner," ").concat(repo," ").concat(inputVersion," - ").concat(preTag," -").concat(!!prerelease));core.info("Tagged \x1B[32m".concat(inputVersion,"\x1B[0m!, Pre Tag: \x1B[33m").concat(preTag,"\x1B[0m "));if(!(inputVersion&&semver_default().gt(inputVersion,preTag))){_context.next=45;break;}core.info("The new tag \x1B[33m".concat(inputVersion,"\x1B[0m is greater than \x1B[32m").concat(preTag,"\x1B[0m.\x1B[33m Create tag.\x1B[0m"));core.setOutput('successful',false);return _context.abrupt("return");case 45:if(!release){_context.next=52;break;}_context.next=48;return octokit.rest.repos.createRelease({owner:owner,repo:repo,prerelease:!!prerelease,draft:!!draft,tag_name:inputVersion,body:body||''});case 48:core.info("Created Released \x1B[32m".concat(inputVersion||' - ',"\x1B[0m"));core.setOutput('successful',true);_context.next=57;break;case 52:_context.next=54;return createTag(myToken,inputVersion);case 54:tagSha=_context.sent;core.info("Tagged \x1B[32m".concat(tagSha||' - ',"\x1B[0m as \x1B[32m").concat(inputVersion,"\x1B[0m!, Pre Tag: \x1B[33m").concat(preTag,"\x1B[0m"));core.setOutput('successful',true);case 57:return _context.abrupt("return");case 58:if(!(!test&&!packagePath)){_context.next=61;break;}core.setFailed('Please setting\x1b[33m test\x1b[0m/\x1b[33m package-path\x1b[0m or Specify\x1b[33m version\x1b[0m! \n Please configure\x1b[33m package-path\x1b[0m');return _context.abrupt("return");case 61:/** current version, example: `v1.0.1` */version='';core.info("Commit Content: \x1B[34m".concat(commit,"\x1B[0m"));if(!(test&&!new RegExp(test).test(commit))){_context.next=66;break;}core.info("This is the feature of\x1B[35;1m \"test\" + \"last commit\"\x1B[0m to automatically create tags. \x1B[33mThis is not a tagged push.\x1B[0m ".concat(commit));return _context.abrupt("return");case 66:if(!(test&&new RegExp(test).test(commit))){_context.next=73;break;}version=getVersion(commit);if(version){_context.next=70;break;}return _context.abrupt("return");case 70:if(!(preTag&&!semver_default().gt(version,preTag))){_context.next=73;break;}core.info("The new tag \x1B[33m".concat(version,"\x1B[0m is smaller than \x1B[32m").concat(preTag,"\x1B[0m.\x1B[33m Do not create tag.\x1B[0m"));return _context.abrupt("return");case 73:if(!(!test&&packagePath)){_context.next=128;break;}resolvePackagePath=external_path_default().resolve(process.cwd(),packagePath);if(/^package.json$/.test(external_path_default().basename(resolvePackagePath))){_context.next=78;break;}core.setFailed("Must specify\x1B[31m package.json\x1B[0m file!");return _context.abrupt("return");case 78:if(lib_default().existsSync(resolvePackagePath)){_context.next=81;break;}core.setFailed("File \x1B[31m".concat(resolvePackagePath,"\x1B[0m does not exist!"));return _context.abrupt("return");case 81:_context.next=83;return lib_default().readJson(resolvePackagePath);case 83:pkg=_context.sent;core.info("Package Name: \x1B[33m".concat(pkg.name||'-',"\x1B[0m"));core.info("Package Description: \x1B[33m".concat(pkg.description||'-',"\x1B[0m"));core.startGroup("Package Data: \x1B[33m".concat(pkg.name||'-',"@\x1B[0m\x1B[33m").concat(pkg.version||'-',"\x1B[0m"));core.info("".concat(JSON.stringify(pkg,null,2)));core.endGroup();if(pkg.version){_context.next=92;break;}core.setFailed("The \x1B[31mversion\x1B[0m feild in package.json does not exist!");return _context.abrupt("return");case 92:version="v".concat(pkg.version);if(!(semver_default().valid(preTag)&&!semver_default().gt(pkg.version,preTag))){_context.next=127;break;}_context.next=96;return octokit.rest.repos.listReleases({owner:owner,repo:repo});case 96:listRelease=_context.sent;core.startGroup("Get Release List:");if(listRelease.data&&listRelease.data.length>0){_iterator=(0,createForOfIteratorHelper/* default */.A)(listRelease.data);try{for(_iterator.s();!(_step=_iterator.n()).done;){item=_step.value;core.info("".concat(item.tag_name," -> ").concat(item.name));}}catch(err){_iterator.e(err);}finally{_iterator.f();}}core.endGroup();core.info("The new tag \x1B[33m".concat(pkg.version,"\x1B[0m is smaller than \x1B[32m").concat(preTag,"\x1B[0m.\x1B[33m Do not create tag.\x1B[0m"));if(!(listRelease.data&&listRelease.data.length>0)){_context.next=124;break;}tag_name=listRelease.data[0].tag_name;core.info("The new Released \x1B[33m".concat(pkg.version,"\x1B[0m >= \x1B[32m").concat(tag_name,"\x1B[0m."));core.info("CreateRelease: - ".concat(preTag," - ").concat(!!prerelease));core.info("v1 > v2: ".concat(semver_default().gt("v".concat(pkg.version),tag_name||''),", v").concat(pkg.version," -> ").concat(tag_name||'',", ").concat(release));core.info("v1 v2: ".concat(semver_default().eq("v".concat(pkg.version),tag_name||''),", v").concat(pkg.version," -> ").concat(tag_name||'',", ").concat(release));if(!(tag_name&&!semver_default().eq("v".concat(pkg.version),tag_name))){_context.next=124;break;}if(!release){_context.next=116;break;}_context.next=111;return octokit.rest.repos.createRelease({owner:owner,repo:repo,prerelease:!!prerelease,tag_name:"v".concat(pkg.version),body:body||''});case 111:core.info("Created Released: - v".concat(pkg.version));core.info("Created Released \x1B[32m".concat(tag_name||' - ',"\x1B[0m"));core.info("Created Released Body: \x1B[32m".concat(body||' - ',"\x1B[0m"));_context.next=124;break;case 116:_context.next=118;return createTag(myToken,version);case 118:_tagSha=_context.sent;core.info("Tagged \x1B[32m".concat(_tagSha||' - ',"\x1B[0m as \x1B[32m").concat(version,"\x1B[0m!, Pre Tag: \x1B[33m").concat(preTag,"\x1B[0m"));core.info("Created Tag: - pkg.version: v".concat(pkg.version,", version: ").concat(version));core.info("Created Tag \x1B[32m".concat(tag_name||' - ',"\x1B[0m"));core.info("Created Tag Body: \x1B[32m".concat(body||' - ',"\x1B[0m"));core.info("Pre Tag: \x1B[32m".concat(preTag||' - ',"\x1B[0m"));case 124:core.info("version: ".concat(owner," ").concat(repo," ").concat(version," - ").concat(preTag));core.setOutput('version',version||preTag);return _context.abrupt("return");case 127:core.info("Resolve Package Path \x1B[33m".concat(resolvePackagePath,"\x1B[0m"));case 128:if(version){_context.next=130;break;}return _context.abrupt("return");case 130:if(preTag){core.info("Create tag \x1B[33m".concat(preTag,"\x1B[0m => \x1B[32m").concat(version,"\x1B[0m"));}else{core.info("Create tag \x1B[32m".concat(version,"\x1B[0m"));}core.info("".concat(owner," ").concat(repo," ").concat(version," - ").concat(preTag));core.setOutput('version',version||preTag);core.info("output version: \x1B[33m".concat(version||preTag,"\x1B[0m"));if(semver_default().valid(version||preTag)){core.setOutput('versionNumber',(_semver$coerce4=semver_default().coerce(version||preTag))===null||_semver$coerce4===void 0?void 0:_semver$coerce4.raw);core.info("output versionNumber: \x1B[33m".concat((_semver$coerce5=semver_default().coerce(version||preTag))===null||_semver$coerce5===void 0?void 0:_semver$coerce5.raw,"\x1B[0m"));}core.setOutput('successful',true);core.info("output successful: \x1B[33m".concat(true,"\x1B[0m"));core.setOutput('majorVersion',semver_default().major(version));core.info("output majorVersion: \x1B[33m".concat(semver_default().major(version),"\x1B[0m"));core.setOutput('minorVersion',semver_default().minor(version));core.info("output minorVersion: \x1B[33m".concat(semver_default().minor(version),"\x1B[0m"));core.setOutput('patchVersion',semver_default().patch(version));core.info("output patchVersion: \x1B[33m".concat(semver_default().patch(version),"\x1B[0m"));if(!release){_context.next=150;break;}_context.next=146;return octokit.rest.repos.createRelease({owner:owner,repo:repo,prerelease:!!prerelease,tag_name:version||preTag,body:body||''});case 146:core.info("Created Released \x1B[32m".concat(inputVersion||' - ',"\x1B[0m"));core.info("Tagged \x1B[32m".concat(version||'-',"\x1B[0m!, Pre Tag: \x1B[33m").concat(preTag,"\x1B[0m"));_context.next=154;break;case 150:_context.next=152;return createTag(myToken,version);case 152:_tagSha2=_context.sent;core.info("Tagged \x1B[32m".concat(_tagSha2||' - ',"\x1B[0m as \x1B[32m").concat(version,"\x1B[0m!, Pre Tag: \x1B[33m").concat(preTag,"\x1B[0m"));case 154:_context.next=159;break;case 156:_context.prev=156;_context.t0=_context["catch"](0);if(_context.t0 instanceof Error){core.setFailed("ERROR:".concat(_context.t0.name,":").concat(_context.t0.message));}else{core.setFailed("ERROR:".concat(_context.t0));}case 159:case"end":return _context.stop();}},_callee,null,[[0,156]]);}));return _run.apply(this,arguments);}function createTag(_x,_x2){return _createTag.apply(this,arguments);}function _createTag(){_createTag=(0,asyncToGenerator/* default */.A)(/*#__PURE__*/(0,regeneratorRuntime/* default */.A)().mark(function _callee2(token,version){var octokit,tag_rsp,ref_rsp;return (0,regeneratorRuntime/* default */.A)().wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:_context2.prev=0;octokit=github.getOctokit(token);_context2.next=4;return octokit.rest.git.createTag((0,objectSpread2/* default */.A)((0,objectSpread2/* default */.A)({},github.context.repo),{},{tag:version,message:core.getInput('message'),object:github.context.sha,type:'commit'}));case 4:tag_rsp=_context2.sent;if(!(tag_rsp.status!==201)){_context2.next=8;break;}core.setFailed("Failed to create tag object (status=".concat(tag_rsp.status,")"));return _context2.abrupt("return");case 8:core.startGroup("CreateTag Result Data (".concat(github.context.repo.owner,"/").concat(github.context.repo.repo,"): \x1B[33m").concat(tag_rsp.status||'-',"\x1B[0m "));core.info("".concat(JSON.stringify(tag_rsp,null,2)));core.endGroup();_context2.next=13;return octokit.rest.git.createRef((0,objectSpread2/* default */.A)((0,objectSpread2/* default */.A)({},github.context.repo),{},{ref:"refs/tags/".concat(version),sha:tag_rsp.data.sha}));case 13:ref_rsp=_context2.sent;if(!(ref_rsp.status!==201)){_context2.next=17;break;}core.setFailed("Failed to create tag ref(status = ".concat(tag_rsp.status,")"));return _context2.abrupt("return");case 17:core.startGroup("CreateRef Result Data: \x1B[33m".concat(tag_rsp.status||'-',"\x1B[0m "));core.info("".concat(JSON.stringify(tag_rsp,null,2)));core.endGroup();return _context2.abrupt("return",tag_rsp.data.sha);case 23:_context2.prev=23;_context2.t0=_context2["catch"](0);if(_context2.t0 instanceof Error){core.warning("CREATER_ERROR: ".concat(version,": ").concat(_context2.t0.message));}else{core.setFailed("CREATER_ERR:".concat(_context2.t0));}case 26:case"end":return _context2.stop();}},_callee2,null,[[0,23]]);}));return _createTag.apply(this,arguments);}try{run();}catch(error){if(error instanceof Error){core.setFailed("CREATE_TAG_ERROR:".concat(error.message));}else{core.setFailed("CREATE_TAG_ERR:".concat(error));}} +preTag=latestRelease.data.tag_name||'';if(preTag&&semver_default().valid(preTag)){preversion=((_semver$coerce=semver_default().coerce(preTag))===null||_semver$coerce===void 0?void 0:_semver$coerce.version)||'';preversionNumber=((_semver$coerce2=semver_default().coerce(preTag))===null||_semver$coerce2===void 0?void 0:_semver$coerce2.raw)||'';core.setOutput('version',preversion);core.setOutput('preversion',preversion);core.setOutput('preversionNumber',preversionNumber);core.setOutput('majorVersion',semver_default().major(preTag));core.setOutput('minorVersion',semver_default().minor(preTag));core.setOutput('patchVersion',semver_default().patch(preTag));}if(preTag&&!semver_default().valid(preTag)){core.warning("Invalid version number \x1B[31;1m\"".concat(preTag,"\"\x1B[0m."));}if(!(inputVersion&&!semver_default().valid(inputVersion))){_context.next=33;break;}core.setFailed("Invalid version number \x1B[31;1m\"".concat(inputVersion,"\"\x1B[0m."));return _context.abrupt("return");case 33:if(!(inputVersion&&semver_default().valid(inputVersion))){_context.next=58;break;}core.setOutput('version',inputVersion);core.setOutput('versionNumber',(_semver$coerce3=semver_default().coerce(inputVersion))===null||_semver$coerce3===void 0?void 0:_semver$coerce3.raw);core.setOutput('majorVersion',semver_default().major(inputVersion));core.setOutput('minorVersion',semver_default().minor(inputVersion));core.setOutput('patchVersion',semver_default().patch(inputVersion));core.info("".concat(owner," ").concat(repo," ").concat(inputVersion," - ").concat(preTag," -").concat(!!prerelease));core.info("Tagged \x1B[32m".concat(inputVersion,"\x1B[0m!, Pre Tag: \x1B[33m").concat(preTag,"\x1B[0m "));if(!(inputVersion&&semver_default().gt(inputVersion,preTag))){_context.next=45;break;}core.info("The new tag \x1B[33m".concat(inputVersion,"\x1B[0m is greater than \x1B[32m").concat(preTag,"\x1B[0m.\x1B[33m Create tag.\x1B[0m"));core.setOutput('successful',false);return _context.abrupt("return");case 45:if(!release){_context.next=52;break;}_context.next=48;return octokit.rest.repos.createRelease({owner:owner,repo:repo,prerelease:!!prerelease,draft:draft=="false"?false:true,tag_name:inputVersion,body:body||''});case 48:core.info("Created Released \x1B[32m".concat(inputVersion||' - ',"\x1B[0m"));core.setOutput('successful',true);_context.next=57;break;case 52:_context.next=54;return createTag(myToken,inputVersion);case 54:tagSha=_context.sent;core.info("Tagged \x1B[32m".concat(tagSha||' - ',"\x1B[0m as \x1B[32m").concat(inputVersion,"\x1B[0m!, Pre Tag: \x1B[33m").concat(preTag,"\x1B[0m"));core.setOutput('successful',true);case 57:return _context.abrupt("return");case 58:if(!(!test&&!packagePath)){_context.next=61;break;}core.setFailed('Please setting\x1b[33m test\x1b[0m/\x1b[33m package-path\x1b[0m or Specify\x1b[33m version\x1b[0m! \n Please configure\x1b[33m package-path\x1b[0m');return _context.abrupt("return");case 61:/** current version, example: `v1.0.1` */version='';core.info("Commit Content: \x1B[34m".concat(commit,"\x1B[0m"));if(!(test&&!new RegExp(test).test(commit))){_context.next=66;break;}core.info("This is the feature of\x1B[35;1m \"test\" + \"last commit\"\x1B[0m to automatically create tags. \x1B[33mThis is not a tagged push.\x1B[0m ".concat(commit));return _context.abrupt("return");case 66:if(!(test&&new RegExp(test).test(commit))){_context.next=73;break;}version=getVersion(commit);if(version){_context.next=70;break;}return _context.abrupt("return");case 70:if(!(preTag&&!semver_default().gt(version,preTag))){_context.next=73;break;}core.info("The new tag \x1B[33m".concat(version,"\x1B[0m is smaller than \x1B[32m").concat(preTag,"\x1B[0m.\x1B[33m Do not create tag.\x1B[0m"));return _context.abrupt("return");case 73:if(!(!test&&packagePath)){_context.next=128;break;}resolvePackagePath=external_path_default().resolve(process.cwd(),packagePath);if(/^package.json$/.test(external_path_default().basename(resolvePackagePath))){_context.next=78;break;}core.setFailed("Must specify\x1B[31m package.json\x1B[0m file!");return _context.abrupt("return");case 78:if(lib_default().existsSync(resolvePackagePath)){_context.next=81;break;}core.setFailed("File \x1B[31m".concat(resolvePackagePath,"\x1B[0m does not exist!"));return _context.abrupt("return");case 81:_context.next=83;return lib_default().readJson(resolvePackagePath);case 83:pkg=_context.sent;core.info("Package Name: \x1B[33m".concat(pkg.name||'-',"\x1B[0m"));core.info("Package Description: \x1B[33m".concat(pkg.description||'-',"\x1B[0m"));core.startGroup("Package Data: \x1B[33m".concat(pkg.name||'-',"@\x1B[0m\x1B[33m").concat(pkg.version||'-',"\x1B[0m"));core.info("".concat(JSON.stringify(pkg,null,2)));core.endGroup();if(pkg.version){_context.next=92;break;}core.setFailed("The \x1B[31mversion\x1B[0m feild in package.json does not exist!");return _context.abrupt("return");case 92:version="v".concat(pkg.version);if(!(semver_default().valid(preTag)&&!semver_default().gt(pkg.version,preTag))){_context.next=127;break;}_context.next=96;return octokit.rest.repos.listReleases({owner:owner,repo:repo});case 96:listRelease=_context.sent;core.startGroup("Get Release List:");if(listRelease.data&&listRelease.data.length>0){_iterator=(0,createForOfIteratorHelper/* default */.A)(listRelease.data);try{for(_iterator.s();!(_step=_iterator.n()).done;){item=_step.value;core.info("".concat(item.tag_name," -> ").concat(item.name));}}catch(err){_iterator.e(err);}finally{_iterator.f();}}core.endGroup();core.info("The new tag \x1B[33m".concat(pkg.version,"\x1B[0m is smaller than \x1B[32m").concat(preTag,"\x1B[0m.\x1B[33m Do not create tag.\x1B[0m"));if(!(listRelease.data&&listRelease.data.length>0)){_context.next=124;break;}tag_name=listRelease.data[0].tag_name;core.info("The new Released \x1B[33m".concat(pkg.version,"\x1B[0m >= \x1B[32m").concat(tag_name,"\x1B[0m."));core.info("CreateRelease: - ".concat(preTag," - ").concat(!!prerelease));core.info("v1 > v2: ".concat(semver_default().gt("v".concat(pkg.version),tag_name||''),", v").concat(pkg.version," -> ").concat(tag_name||'',", ").concat(release));core.info("v1 v2: ".concat(semver_default().eq("v".concat(pkg.version),tag_name||''),", v").concat(pkg.version," -> ").concat(tag_name||'',", ").concat(release));if(!(tag_name&&!semver_default().eq("v".concat(pkg.version),tag_name))){_context.next=124;break;}if(!release){_context.next=116;break;}_context.next=111;return octokit.rest.repos.createRelease({owner:owner,repo:repo,prerelease:!!prerelease,tag_name:"v".concat(pkg.version),body:body||''});case 111:core.info("Created Released: - v".concat(pkg.version));core.info("Created Released \x1B[32m".concat(tag_name||' - ',"\x1B[0m"));core.info("Created Released Body: \x1B[32m".concat(body||' - ',"\x1B[0m"));_context.next=124;break;case 116:_context.next=118;return createTag(myToken,version);case 118:_tagSha=_context.sent;core.info("Tagged \x1B[32m".concat(_tagSha||' - ',"\x1B[0m as \x1B[32m").concat(version,"\x1B[0m!, Pre Tag: \x1B[33m").concat(preTag,"\x1B[0m"));core.info("Created Tag: - pkg.version: v".concat(pkg.version,", version: ").concat(version));core.info("Created Tag \x1B[32m".concat(tag_name||' - ',"\x1B[0m"));core.info("Created Tag Body: \x1B[32m".concat(body||' - ',"\x1B[0m"));core.info("Pre Tag: \x1B[32m".concat(preTag||' - ',"\x1B[0m"));case 124:core.info("version: ".concat(owner," ").concat(repo," ").concat(version," - ").concat(preTag));core.setOutput('version',version||preTag);return _context.abrupt("return");case 127:core.info("Resolve Package Path \x1B[33m".concat(resolvePackagePath,"\x1B[0m"));case 128:if(version){_context.next=130;break;}return _context.abrupt("return");case 130:if(preTag){core.info("Create tag \x1B[33m".concat(preTag,"\x1B[0m => \x1B[32m").concat(version,"\x1B[0m"));}else{core.info("Create tag \x1B[32m".concat(version,"\x1B[0m"));}core.info("".concat(owner," ").concat(repo," ").concat(version," - ").concat(preTag));core.setOutput('version',version||preTag);core.info("output version: \x1B[33m".concat(version||preTag,"\x1B[0m"));if(semver_default().valid(version||preTag)){core.setOutput('versionNumber',(_semver$coerce4=semver_default().coerce(version||preTag))===null||_semver$coerce4===void 0?void 0:_semver$coerce4.raw);core.info("output versionNumber: \x1B[33m".concat((_semver$coerce5=semver_default().coerce(version||preTag))===null||_semver$coerce5===void 0?void 0:_semver$coerce5.raw,"\x1B[0m"));}core.setOutput('successful',true);core.info("output successful: \x1B[33m".concat(true,"\x1B[0m"));core.setOutput('majorVersion',semver_default().major(version));core.info("output majorVersion: \x1B[33m".concat(semver_default().major(version),"\x1B[0m"));core.setOutput('minorVersion',semver_default().minor(version));core.info("output minorVersion: \x1B[33m".concat(semver_default().minor(version),"\x1B[0m"));core.setOutput('patchVersion',semver_default().patch(version));core.info("output patchVersion: \x1B[33m".concat(semver_default().patch(version),"\x1B[0m"));if(!release){_context.next=150;break;}_context.next=146;return octokit.rest.repos.createRelease({owner:owner,repo:repo,prerelease:!!prerelease,tag_name:version||preTag,body:body||''});case 146:core.info("Created Released \x1B[32m".concat(inputVersion||' - ',"\x1B[0m"));core.info("Tagged \x1B[32m".concat(version||'-',"\x1B[0m!, Pre Tag: \x1B[33m").concat(preTag,"\x1B[0m"));_context.next=154;break;case 150:_context.next=152;return createTag(myToken,version);case 152:_tagSha2=_context.sent;core.info("Tagged \x1B[32m".concat(_tagSha2||' - ',"\x1B[0m as \x1B[32m").concat(version,"\x1B[0m!, Pre Tag: \x1B[33m").concat(preTag,"\x1B[0m"));case 154:_context.next=159;break;case 156:_context.prev=156;_context.t0=_context["catch"](0);if(_context.t0 instanceof Error){core.setFailed("ERROR:".concat(_context.t0.name,":").concat(_context.t0.message));}else{core.setFailed("ERROR:".concat(_context.t0));}case 159:case"end":return _context.stop();}},_callee,null,[[0,156]]);}));return _run.apply(this,arguments);}function createTag(_x,_x2){return _createTag.apply(this,arguments);}function _createTag(){_createTag=(0,asyncToGenerator/* default */.A)(/*#__PURE__*/(0,regeneratorRuntime/* default */.A)().mark(function _callee2(token,version){var octokit,tag_rsp,ref_rsp;return (0,regeneratorRuntime/* default */.A)().wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:_context2.prev=0;octokit=github.getOctokit(token);_context2.next=4;return octokit.rest.git.createTag((0,objectSpread2/* default */.A)((0,objectSpread2/* default */.A)({},github.context.repo),{},{tag:version,message:core.getInput('message'),object:github.context.sha,type:'commit'}));case 4:tag_rsp=_context2.sent;if(!(tag_rsp.status!==201)){_context2.next=8;break;}core.setFailed("Failed to create tag object (status=".concat(tag_rsp.status,")"));return _context2.abrupt("return");case 8:core.startGroup("CreateTag Result Data (".concat(github.context.repo.owner,"/").concat(github.context.repo.repo,"): \x1B[33m").concat(tag_rsp.status||'-',"\x1B[0m "));core.info("".concat(JSON.stringify(tag_rsp,null,2)));core.endGroup();_context2.next=13;return octokit.rest.git.createRef((0,objectSpread2/* default */.A)((0,objectSpread2/* default */.A)({},github.context.repo),{},{ref:"refs/tags/".concat(version),sha:tag_rsp.data.sha}));case 13:ref_rsp=_context2.sent;if(!(ref_rsp.status!==201)){_context2.next=17;break;}core.setFailed("Failed to create tag ref(status = ".concat(tag_rsp.status,")"));return _context2.abrupt("return");case 17:core.startGroup("CreateRef Result Data: \x1B[33m".concat(tag_rsp.status||'-',"\x1B[0m "));core.info("".concat(JSON.stringify(tag_rsp,null,2)));core.endGroup();return _context2.abrupt("return",tag_rsp.data.sha);case 23:_context2.prev=23;_context2.t0=_context2["catch"](0);if(_context2.t0 instanceof Error){core.warning("CREATER_ERROR: ".concat(version,": ").concat(_context2.t0.message));}else{core.setFailed("CREATER_ERR:".concat(_context2.t0));}case 26:case"end":return _context2.stop();}},_callee2,null,[[0,23]]);}));return _createTag.apply(this,arguments);}try{run();}catch(error){if(error instanceof Error){core.setFailed("CREATE_TAG_ERROR:".concat(error.message));}else{core.setFailed("CREATE_TAG_ERR:".concat(error));}} })(); module.exports = __webpack_exports__; diff --git a/src/main.ts b/src/main.ts index 769bff2..0e0e48a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -17,7 +17,7 @@ async function run(): Promise { /** Optionally marks this release as `prerelease`. Set to `true` to enable. */ const prerelease = core.getInput('prerelease') /** Optionally marks this release as a draft release. Set to true to enable. */ - const draft = core.getInput('draft') + const draft = core.getInput('draft') ?? "false" /** The path of the `package.json` file. Default `package.json`. */ const packagePath = core.getInput('package-path') // Example: v1.0.0 @@ -94,7 +94,7 @@ async function run(): Promise { owner, repo, prerelease: !!prerelease, - draft: !!draft, + draft: draft == "false" ? false : true, tag_name: inputVersion, body: body || '' })