fix: Wrong release-id output

This commit is contained in:
Ardalan Amini committed 2022-08-28 23:15:41 +04:30
1 parent cfdd243b53
commit b1f62f950a
3 files changed
+4 -3

No files matched your search

+1 -1
View File
@@ -1,4 +1,4 @@
require('./sourcemap-register.js');(()=>{var __webpack_modules__={7412:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.generate=void 0;const s=r(1912);function trim(e){if(e==null)return e;return e.trim().replace(/ {2,}/g," ")}function unique(e){return[...new Set(e)]}async function generate(e){const{octokit:t,owner:r,repo:a,sha:i,tagRef:n,inputs:o}=e;const{commitTypes:p,defaultCommitType:l,mentionAuthors:d}=o;const u=`https://github.com/${r}/${a}`;const c={};e:for await(const{data:e}of t.paginate.iterator(t.rest.repos.listCommits,{per_page:100,owner:r,repo:a,sha:i})){for(const t of e){if(t.sha===n)break e;const e=t.commit.message.split("\n")[0];let{type:r,category:a,title:i,pr:o,flag:u}=s.COMMIT_REGEX.exec(e)?.groups??{};if(!i)continue;u=trim(u);if(u==="ignore")continue;r=p[trim(r)]??l;a=a?trim(a):"";i=trim(i);let m=c[r];if(m==null)m=c[r]={};let h=m[a];if(h==null)h=m[a]=[];const g=h.find((e=>e.title===i));const v={author:d?t.author?.login:null,commit:t.sha,pr:o};if(g==null){h.push({title:i,references:[v]})}else{g.references.push(v)}}}const m=unique([...Object.values(p),l]);return m.reduce(((e,t)=>{const r=c[t];if(r==null)return e;e.push(`## ${t}`);const a=Object.keys(r).sort();for(const t of a){const a=r[t];const i=t.length===0;if(!i)e.push(`* **${t}:**`);const n=i?"":" ";for(const{title:t,references:r}of a){e.push(`${n}* ${t} (${r.map((e=>`${e.pr==null?"":`${u}/pull/${e.pr} `}${u}/commit/${e.commit}${e.author==null?"":e.author.endsWith(s.APP_AUTHOR_SUFFIX)?` by [@${e.author}](https://github.com/apps/${e.author.slice(0,-s.APP_AUTHOR_SUFFIX_LENGTH)})`:` by @${e.author}`}`)).join(", ")})`)}}e.push("");return e}),[]).join("\n")}t.generate=generate},1912:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.APP_AUTHOR_SUFFIX_LENGTH=t.APP_AUTHOR_SUFFIX=t.COMMIT_REGEX=void 0;t.COMMIT_REGEX=/^(?<type>[^:()]*)(?:\((?<category>[^()]*?)\)|): *(?<title>.+?) *(?:\(#(?<pr>[1-9]\d*?)\)|) *(?:\[(?<flag>[^[\]]*?)]|)\s*$/;t.APP_AUTHOR_SUFFIX="[bot]";t.APP_AUTHOR_SUFFIX_LENGTH=t.APP_AUTHOR_SUFFIX.length},7331:function(e,t,r){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});t.getInputs=t.getToken=void 0;const a=s(r(918));const i=s(r(4083));const n=r(2186);function getToken(){return(0,n.getInput)("github-token",{required:true})}t.getToken=getToken;async function getInputs(){const e=i.default.parse((0,n.getInput)("commit-types",{required:true}));const t=(0,n.getInput)("default-commit-type",{required:true});const r=(0,n.getInput)("release-name",{required:true});const s=(0,n.getBooleanInput)("mention-authors",{required:true});const o=(0,n.getBooleanInput)("mention-new-contributors",{required:true});const p=(0,n.getBooleanInput)("include-compare",{required:true});const l=(0,n.getBooleanInput)("semver",{required:true});return a.default.object().keys({commitTypes:a.default.object().pattern(a.default.string(),a.default.string()).required(),defaultCommitType:a.default.string().required(),releaseName:a.default.string().required(),mentionAuthors:a.default.boolean().required(),mentionNewContributors:a.default.boolean().required(),includeCompare:a.default.boolean().required(),semver:a.default.boolean().required()}).validateAsync({commitTypes:e,defaultCommitType:t,releaseName:r,mentionAuthors:s,mentionNewContributors:o,includeCompare:p,semver:l})}t.getInputs=getInputs},9283:function(e,t,r){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});const a=s(r(1383));const i=r(7412);const n=r(9297);const o=r(5741);const p=r(5438);const l=r(7331);const d=r(2186);async function run(){const e=await(0,l.getInputs)();const t=(0,p.getOctokit)((0,l.getToken)());const{repo:{owner:r,repo:s},sha:u}=p.context;let c=null;if(e.semver){c=a.default.parse(e.releaseName,{includePrerelease:true});if(c==null){(0,d.setFailed)(`Expected a semver compatible releaseName, got "${e.releaseName}" instead.`);return}}let m=false;let h="latest";if(c!=null){m=c.prerelease.length>0;h=c.prerelease[0]}const{sha:g,name:v}=await(0,n.getTagSha)({octokit:t,owner:r,repo:s,sha:u,semver:c,prerelease:m});let y=await(0,i.generate)({octokit:t,owner:r,repo:s,sha:u,tagRef:g,inputs:e});if(e.mentionNewContributors){const{data:a}=await t.rest.repos.generateReleaseNotes({owner:r,repo:s,tag_name:e.releaseName,previous_tag_name:v});const i=o.marked.lexer(a.body);const n=i.findIndex((e=>e.type==="heading"&&e.text==="New Contributors"));const p=i[n+1];if(p.type==="list")y+=`\n\n## New Contributors\n${p.raw}\n`}if(e.includeCompare&&v!=null)y+=`\n\n**Full Changelog**: https://github.com/${r}/${s}/compare/${v}...${e.releaseName}`;(0,d.info)(`-> prerelease: ${m}`);(0,d.setOutput)("prerelease",m);(0,d.info)(`-> release-id: ${h}`);(0,d.setOutput)("release-id",h);(0,d.info)(`-> changelog: "${y}"`);(0,d.setOutput)("changelog",y)}run().catch(d.setFailed)},9297:functionLine truncated
require('./sourcemap-register.js');(()=>{var __webpack_modules__={7412:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.generate=void 0;const s=r(1912);function trim(e){if(e==null)return e;return e.trim().replace(/ {2,}/g," ")}function unique(e){return[...new Set(e)]}async function generate(e){const{octokit:t,owner:r,repo:a,sha:i,tagRef:n,inputs:o}=e;const{commitTypes:p,defaultCommitType:l,mentionAuthors:d}=o;const u=`https://github.com/${r}/${a}`;const c={};e:for await(const{data:e}of t.paginate.iterator(t.rest.repos.listCommits,{per_page:100,owner:r,repo:a,sha:i})){for(const t of e){if(t.sha===n)break e;const e=t.commit.message.split("\n")[0];let{type:r,category:a,title:i,pr:o,flag:u}=s.COMMIT_REGEX.exec(e)?.groups??{};if(!i)continue;u=trim(u);if(u==="ignore")continue;r=p[trim(r)]??l;a=a?trim(a):"";i=trim(i);let m=c[r];if(m==null)m=c[r]={};let h=m[a];if(h==null)h=m[a]=[];const g=h.find((e=>e.title===i));const v={author:d?t.author?.login:null,commit:t.sha,pr:o};if(g==null){h.push({title:i,references:[v]})}else{g.references.push(v)}}}const m=unique([...Object.values(p),l]);return m.reduce(((e,t)=>{const r=c[t];if(r==null)return e;e.push(`## ${t}`);const a=Object.keys(r).sort();for(const t of a){const a=r[t];const i=t.length===0;if(!i)e.push(`* **${t}:**`);const n=i?"":" ";for(const{title:t,references:r}of a){e.push(`${n}* ${t} (${r.map((e=>`${e.pr==null?"":`${u}/pull/${e.pr} `}${u}/commit/${e.commit}${e.author==null?"":e.author.endsWith(s.APP_AUTHOR_SUFFIX)?` by [@${e.author}](https://github.com/apps/${e.author.slice(0,-s.APP_AUTHOR_SUFFIX_LENGTH)})`:` by @${e.author}`}`)).join(", ")})`)}}e.push("");return e}),[]).join("\n")}t.generate=generate},1912:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.APP_AUTHOR_SUFFIX_LENGTH=t.APP_AUTHOR_SUFFIX=t.COMMIT_REGEX=void 0;t.COMMIT_REGEX=/^(?<type>[^:()]*)(?:\((?<category>[^()]*?)\)|): *(?<title>.+?) *(?:\(#(?<pr>[1-9]\d*?)\)|) *(?:\[(?<flag>[^[\]]*?)]|)\s*$/;t.APP_AUTHOR_SUFFIX="[bot]";t.APP_AUTHOR_SUFFIX_LENGTH=t.APP_AUTHOR_SUFFIX.length},7331:function(e,t,r){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});t.getInputs=t.getToken=void 0;const a=s(r(918));const i=s(r(4083));const n=r(2186);function getToken(){return(0,n.getInput)("github-token",{required:true})}t.getToken=getToken;async function getInputs(){const e=i.default.parse((0,n.getInput)("commit-types",{required:true}));const t=(0,n.getInput)("default-commit-type",{required:true});const r=(0,n.getInput)("release-name",{required:true});const s=(0,n.getBooleanInput)("mention-authors",{required:true});const o=(0,n.getBooleanInput)("mention-new-contributors",{required:true});const p=(0,n.getBooleanInput)("include-compare",{required:true});const l=(0,n.getBooleanInput)("semver",{required:true});return a.default.object().keys({commitTypes:a.default.object().pattern(a.default.string(),a.default.string()).required(),defaultCommitType:a.default.string().required(),releaseName:a.default.string().required(),mentionAuthors:a.default.boolean().required(),mentionNewContributors:a.default.boolean().required(),includeCompare:a.default.boolean().required(),semver:a.default.boolean().required()}).validateAsync({commitTypes:e,defaultCommitType:t,releaseName:r,mentionAuthors:s,mentionNewContributors:o,includeCompare:p,semver:l})}t.getInputs=getInputs},9283:function(e,t,r){"use strict";var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});const a=s(r(1383));const i=r(7412);const n=r(9297);const o=r(5741);const p=r(5438);const l=r(7331);const d=r(2186);async function run(){const e=await(0,l.getInputs)();const t=(0,p.getOctokit)((0,l.getToken)());const{repo:{owner:r,repo:s},sha:u}=p.context;let c=null;if(e.semver){c=a.default.parse(e.releaseName,{includePrerelease:true});if(c==null){(0,d.setFailed)(`Expected a semver compatible releaseName, got "${e.releaseName}" instead.`);return}}let m=false;let h="latest";if(c!=null){m=c.prerelease.length>0;if(m)h=c.prerelease[0]}const{sha:g,name:v}=await(0,n.getTagSha)({octokit:t,owner:r,repo:s,sha:u,semver:c,prerelease:m});let y=await(0,i.generate)({octokit:t,owner:r,repo:s,sha:u,tagRef:g,inputs:e});if(e.mentionNewContributors){const{data:a}=await t.rest.repos.generateReleaseNotes({owner:r,repo:s,tag_name:e.releaseName,previous_tag_name:v});const i=o.marked.lexer(a.body);const n=i.findIndex((e=>e.type==="heading"&&e.text==="New Contributors"));const p=i[n+1];if(p.type==="list")y+=`\n\n## New Contributors\n${p.raw}\n`}if(e.includeCompare&&v!=null)y+=`\n\n**Full Changelog**: https://github.com/${r}/${s}/compare/${v}...${e.releaseName}`;(0,d.info)(`-> prerelease: ${m}`);(0,d.setOutput)("prerelease",m);(0,d.info)(`-> release-id: ${h}`);(0,d.setOutput)("release-id",h);(0,d.info)(`-> changelog: "${y}"`);(0,d.setOutput)("changelog",y)}run().catch(d.setFailed)},9297:funLine truncated
/*!
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
*
+1 -1
View File
@@ -1 +1 @@
{"version":3,"sources":["../webpack:/auto-changelog/dist/changelog.js","../webpack:/auto-changelog/dist/constants.js","../webpack:/auto-changelog/dist/context.js","../webpack:/auto-changelog/dist/index.js","../webpack:/auto-changelog/dist/tag.js","../webpack:/auto-changelog/node_modules/@actions/core/lib/command.js","../webpack:/auto-changelog/node_modules/@actions/core/lib/core.js","../webpack:/auto-changelog/node_modules/@actions/core/lib/file-command.js","../webpack:/auto-changelog/node_modules/@actions/core/lib/oidc-utils.js","../webpack:/auto-changelog/node_modules/@actions/core/lib/path-utils.js","../webpack:/auto-changelog/node_modules/@actions/core/lib/summary.js","../webpack:/auto-changelog/node_modules/@actions/core/lib/utils.js","../webpack:/auto-changelog/node_modules/@actions/github/lib/context.js","../webpack:/auto-changelog/node_modules/@actions/github/lib/github.js","../webpack:/auto-changelog/node_modules/@actions/github/lib/internal/utils.js","../webpack:/auto-changelog/node_modules/@actions/github/lib/utils.js","../webpack:/auto-changelog/node_modules/@actions/http-client/lib/auth.js","../webpack:/auto-changelog/node_modules/@actions/http-client/lib/index.js","../webpack:/auto-changelog/node_modules/@actions/http-client/lib/proxy.js","../webpack:/auto-changelog/node_modules/@hapi/hoek/lib/applyToDefaults.js","../webpack:/auto-changelog/node_modules/@hapi/hoek/lib/assert.js","../webpack:/auto-changelog/node_modules/@hapi/hoek/lib/clone.js","../webpack:/auto-changelog/node_modules/@hapi/hoek/lib/deepEqual.js","../webpack:/auto-changelog/node_modules/@hapi/hoek/lib/error.js","../webpack:/auto-changelog/node_modules/@hapi/hoek/lib/escapeHtml.js","../webpack:/auto-changelog/node_modules/@hapi/hoek/lib/escapeRegex.js","../webpack:/auto-changelog/node_modules/@hapi/hoek/lib/ignore.js","../webpack:/auto-changelog/node_modules/@hapi/hoek/lib/merge.js","../webpack:/auto-changelog/node_modules/@hapi/hoek/lib/reach.js","../webpack:/auto-changelog/node_modules/@hapi/hoek/lib/stringify.js","../webpack:/auto-changelog/node_modules/@hapi/hoek/lib/types.js","../webpack:/auto-changelog/node_modules/@hapi/hoek/lib/utils.js","../webpack:/auto-changelog/node_modules/@hapi/topo/lib/index.js","../webpack:/auto-changelog/node_modules/@octokit/auth-token/dist-node/index.js","../webpack:/auto-changelog/node_modules/@octokit/core/dist-node/index.js","../webpack:/auto-changelog/node_modules/@octokit/endpoint/dist-node/index.js","../webpack:/auto-changelog/node_modules/@octokit/graphql/dist-node/index.js","../webpack:/auto-changelog/node_modules/@octokit/plugin-paginate-rest/dist-node/index.js","../webpack:/auto-changelog/node_modules/@octokit/plugin-rest-endpoint-methods/dist-node/index.js","../webpack:/auto-changelog/node_modules/@octokit/request-error/dist-node/index.js","../webpack:/auto-changelog/node_modules/@octokit/request/dist-node/index.js","../webpack:/auto-changelog/node_modules/@sideway/address/lib/domain.js","../webpack:/auto-changelog/node_modules/@sideway/address/lib/email.js","../webpack:/auto-changelog/node_modules/@sideway/address/lib/errors.js","../webpack:/auto-changelog/node_modules/@sideway/address/lib/ip.js","../webpack:/auto-changelog/node_modules/@sideway/address/lib/tlds.js","../webpack:/auto-changelog/node_modules/@sideway/address/lib/uri.js","../webpack:/auto-changelog/node_modules/@sideway/formula/lib/index.js","../webpack:/auto-changelog/node_modules/@sideway/pinpoint/lib/index.js","../webpack:/auto-changelog/node_modules/before-after-hook/index.js","../webpack:/auto-changelog/node_modules/before-after-hook/lib/add.js","../webpack:/auto-changelog/node_modules/before-after-hook/lib/register.js","../webpack:/auto-changelog/node_modules/before-after-hook/lib/remove.js","../webpack:/auto-changelog/node_modules/deprecation/dist-node/index.js","../webpack:/auto-changelog/node_modules/is-plain-object/dist/is-plain-object.js","../webpack:/auto-changelog/node_modules/joi/lib/annotate.js","../webpack:/auto-changelog/node_modules/joi/lib/base.js","../webpack:/auto-changelog/node_modules/joi/lib/cache.js","../webpack:/auto-changelog/node_modules/joi/lib/common.js","../webpack:/auto-changelog/node_modules/joi/lib/compile.js","../webpack:/auto-changelog/node_modules/joi/lib/errors.js","../webpack:/auto-changelog/node_modules/joi/lib/extend.js","../webpack:/auto-changelog/node_modules/joi/lib/index.js","../webpack:/auto-changelog/node_modules/joi/lib/manifest.js","../webpack:/auto-changelog/node_modules/joi/lib/messages.js","../webpack:/auto-changelog/node_modules/joi/lib/modify.js","../webpack:/auto-changelog/node_modules/joi/lib/ref.js","../webpack:/auto-changelog/node_modules/joi/lib/schemas.js","../webpack:/auto-changelog/node_modules/joi/lib/state.js","../webpack:/auto-changelog/node_modules/joi/lib/template.js","../webpack:/auto-changelog/node_modules/joi/lib/trace.js","../webpack:/auto-changelog/node_modules/joi/lib/types/alternatives.js","../webpack:/auto-changelog/node_modules/joi/lib/types/Line truncated
{"version":3,"sources":["../webpack:/auto-changelog/dist/changelog.js","../webpack:/auto-changelog/dist/constants.js","../webpack:/auto-changelog/dist/context.js","../webpack:/auto-changelog/dist/index.js","../webpack:/auto-changelog/dist/tag.js","../webpack:/auto-changelog/node_modules/@actions/core/lib/command.js","../webpack:/auto-changelog/node_modules/@actions/core/lib/core.js","../webpack:/auto-changelog/node_modules/@actions/core/lib/file-command.js","../webpack:/auto-changelog/node_modules/@actions/core/lib/oidc-utils.js","../webpack:/auto-changelog/node_modules/@actions/core/lib/path-utils.js","../webpack:/auto-changelog/node_modules/@actions/core/lib/summary.js","../webpack:/auto-changelog/node_modules/@actions/core/lib/utils.js","../webpack:/auto-changelog/node_modules/@actions/github/lib/context.js","../webpack:/auto-changelog/node_modules/@actions/github/lib/github.js","../webpack:/auto-changelog/node_modules/@actions/github/lib/internal/utils.js","../webpack:/auto-changelog/node_modules/@actions/github/lib/utils.js","../webpack:/auto-changelog/node_modules/@actions/http-client/lib/auth.js","../webpack:/auto-changelog/node_modules/@actions/http-client/lib/index.js","../webpack:/auto-changelog/node_modules/@actions/http-client/lib/proxy.js","../webpack:/auto-changelog/node_modules/@hapi/hoek/lib/applyToDefaults.js","../webpack:/auto-changelog/node_modules/@hapi/hoek/lib/assert.js","../webpack:/auto-changelog/node_modules/@hapi/hoek/lib/clone.js","../webpack:/auto-changelog/node_modules/@hapi/hoek/lib/deepEqual.js","../webpack:/auto-changelog/node_modules/@hapi/hoek/lib/error.js","../webpack:/auto-changelog/node_modules/@hapi/hoek/lib/escapeHtml.js","../webpack:/auto-changelog/node_modules/@hapi/hoek/lib/escapeRegex.js","../webpack:/auto-changelog/node_modules/@hapi/hoek/lib/ignore.js","../webpack:/auto-changelog/node_modules/@hapi/hoek/lib/merge.js","../webpack:/auto-changelog/node_modules/@hapi/hoek/lib/reach.js","../webpack:/auto-changelog/node_modules/@hapi/hoek/lib/stringify.js","../webpack:/auto-changelog/node_modules/@hapi/hoek/lib/types.js","../webpack:/auto-changelog/node_modules/@hapi/hoek/lib/utils.js","../webpack:/auto-changelog/node_modules/@hapi/topo/lib/index.js","../webpack:/auto-changelog/node_modules/@octokit/auth-token/dist-node/index.js","../webpack:/auto-changelog/node_modules/@octokit/core/dist-node/index.js","../webpack:/auto-changelog/node_modules/@octokit/endpoint/dist-node/index.js","../webpack:/auto-changelog/node_modules/@octokit/graphql/dist-node/index.js","../webpack:/auto-changelog/node_modules/@octokit/plugin-paginate-rest/dist-node/index.js","../webpack:/auto-changelog/node_modules/@octokit/plugin-rest-endpoint-methods/dist-node/index.js","../webpack:/auto-changelog/node_modules/@octokit/request-error/dist-node/index.js","../webpack:/auto-changelog/node_modules/@octokit/request/dist-node/index.js","../webpack:/auto-changelog/node_modules/@sideway/address/lib/domain.js","../webpack:/auto-changelog/node_modules/@sideway/address/lib/email.js","../webpack:/auto-changelog/node_modules/@sideway/address/lib/errors.js","../webpack:/auto-changelog/node_modules/@sideway/address/lib/ip.js","../webpack:/auto-changelog/node_modules/@sideway/address/lib/tlds.js","../webpack:/auto-changelog/node_modules/@sideway/address/lib/uri.js","../webpack:/auto-changelog/node_modules/@sideway/formula/lib/index.js","../webpack:/auto-changelog/node_modules/@sideway/pinpoint/lib/index.js","../webpack:/auto-changelog/node_modules/before-after-hook/index.js","../webpack:/auto-changelog/node_modules/before-after-hook/lib/add.js","../webpack:/auto-changelog/node_modules/before-after-hook/lib/register.js","../webpack:/auto-changelog/node_modules/before-after-hook/lib/remove.js","../webpack:/auto-changelog/node_modules/deprecation/dist-node/index.js","../webpack:/auto-changelog/node_modules/is-plain-object/dist/is-plain-object.js","../webpack:/auto-changelog/node_modules/joi/lib/annotate.js","../webpack:/auto-changelog/node_modules/joi/lib/base.js","../webpack:/auto-changelog/node_modules/joi/lib/cache.js","../webpack:/auto-changelog/node_modules/joi/lib/common.js","../webpack:/auto-changelog/node_modules/joi/lib/compile.js","../webpack:/auto-changelog/node_modules/joi/lib/errors.js","../webpack:/auto-changelog/node_modules/joi/lib/extend.js","../webpack:/auto-changelog/node_modules/joi/lib/index.js","../webpack:/auto-changelog/node_modules/joi/lib/manifest.js","../webpack:/auto-changelog/node_modules/joi/lib/messages.js","../webpack:/auto-changelog/node_modules/joi/lib/modify.js","../webpack:/auto-changelog/node_modules/joi/lib/ref.js","../webpack:/auto-changelog/node_modules/joi/lib/schemas.js","../webpack:/auto-changelog/node_modules/joi/lib/state.js","../webpack:/auto-changelog/node_modules/joi/lib/template.js","../webpack:/auto-changelog/node_modules/joi/lib/trace.js","../webpack:/auto-changelog/node_modules/joi/lib/types/alternatives.js","../webpack:/auto-changelog/node_modules/joi/lib/types/Line truncated
+2 -1
View File
@@ -34,7 +34,8 @@ async function run(): Promise<void> {
if (semver != null) {
prerelease = semver.prerelease.length > 0;
releaseId = semver.prerelease[0] as string;
if (prerelease) releaseId = semver.prerelease[0] as string;
}
const { sha: tagRef, name: tagName } = await getTagSha({