mirror of
https://github.com/darksaid98/auto-changelog.git
synced 2026-12-01 14:38:47 +00:00
feat: Include GitHub compare link in the changelog (#48)
* feat: Include GitHub compare link in the changelog * fix: Full Changelog link markdown position
This commit is contained in:
1 parent
4f2084e0da
commit
a4aa721e58
5 files changed
+22
-13
No files matched your search
+1
-1
@@ -1,4 +1,4 @@
|
||||
require('./sourcemap-register.js');(()=>{var __webpack_modules__={7412:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.generate=void 0;const a=s(1912);async function generate(e){const{octokit:t,owner:s,repo:r,sha:i,tagRef:n,inputs:o}=e;const{commitTypes:p,defaultCommitType:l}=o;const d=`https://github.com/${s}/${r}`;const c={};e:for await(const{data:e}of t.paginate.iterator(t.rest.repos.listCommits,{per_page:100,owner:s,repo:r,sha:i})){for(const{sha:t,...s}of e){if(t===n)break e;const e=s.commit.message.split("\n")[0];let{type:r,category:i,title:o,flag:m}=a.COMMIT_REGEX.exec(e)?.groups??{};if(!o)continue;m=trim(m);if(m==="ignore")continue;r=trim(r);r=p[r]??l;i=i?trim(i):"";o=trim(o).replace(a.PR_REGEX,((e,t)=>`[${e}](${d}/pull/${t})`));c[r]=c[r]??{};c[r][i]=c[r][i]??[];const u=c[r][i].findIndex((e=>e.title===o));if(u===-1)c[r][i].push({title:o,commits:[t]});else c[r][i][u].commits.push(t)}}const m=unique([...Object.values(p),l]);return m.reduce(((e,t)=>{const s=c[t];if(s==null)return e;e.push(`## ${t}`);const a=Object.keys(s).sort();for(const t of a){const a=s[t];const r=t.length===0;if(!r)e.push(`* **${t}:**`);const i=r?"":" ";for(const{title:t,commits:s}of a){e.push(`${i}* ${t} (${s.map((e=>`[${e.slice(0,8)}](${d}/commit/${e})`)).join(",")})`)}}e.push("");return e}),[]).join("\n")}t.generate=generate;function trim(e){if(e==null)return e;return e.trim().replace(/ {2,}/g," ")}function unique(e){return[...new Set(e)]}},1912:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.PR_REGEX=t.COMMIT_REGEX=void 0;t.COMMIT_REGEX=/^(?<type>[^)]*)(?:\((?<category>[^)]*?)\)|):(?<title>.*?)(?:\[(?<flag>[^\]]+?)\]|)\s*$/;t.PR_REGEX=/#([1-9]\d*)/g},7331:function(e,t,s){"use strict";var a=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 r=s(2186);const i=a(s(918));const n=a(s(4083));function getToken(){return(0,r.getInput)("github-token",{required:true})}t.getToken=getToken;async function getInputs(){const e=n.default.parse((0,r.getInput)("commit-types",{required:true}));const t=(0,r.getInput)("default-commit-type",{required:true});const s=(0,r.getInput)("release-name",{required:true});const a=(0,r.getBooleanInput)("semver",{required:true});return i.default.object().keys({commitTypes:i.default.object().pattern(i.default.string(),i.default.string()).required(),defaultCommitType:i.default.string().required(),releaseName:i.default.string().required(),semver:i.default.boolean().required()}).validateAsync({commitTypes:e,defaultCommitType:t,releaseName:s,semver:a})}t.getInputs=getInputs},9283:function(e,t,s){"use strict";var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});const r=s(2186);const i=s(5438);const n=a(s(1383));const o=s(9297);const p=s(7412);const l=s(7331);async function run(){const e=await(0,l.getInputs)();const t=(0,i.getOctokit)((0,l.getToken)());const{repo:{owner:s,repo:a},sha:d}=i.context;let c=null;if(e.semver){c=n.default.parse(e.releaseName,{includePrerelease:true});if(c==null)return(0,r.setFailed)(`Expected a semver compatible releaseName, got "${e.releaseName}" instead.`)}let m=false;if(c!=null)m=c.prerelease.length>0;const u=await(0,o.getTagSha)({octokit:t,owner:s,repo:a,sha:d,semver:c,prerelease:m});const h=await(0,p.generate)({octokit:t,owner:s,repo:a,sha:d,tagRef:u,inputs:e});(0,r.info)(h);(0,r.setOutput)("changelog",h);(0,r.info)(`prerelease: ${m}`);(0,r.setOutput)("prerelease",m)}run().catch(r.setFailed)},9297:function(e,t,s){"use strict";var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});t.getTagSha=void 0;const r=a(s(1383));async function getTagSha(e){const{octokit:t,owner:s,repo:a,sha:i,semver:n,prerelease:o}=e;for await(const{data:e}of t.paginate.iterator(t.rest.repos.listTags,{per_page:100,owner:s,repo:a})){for(const{name:t,commit:{sha:s}}of e){if(i===s)continue;if(n==null)return s;const e=r.default.parse(t,{includePrerelease:true});if(e==null||n.compare(e)<=0)continue;if(e.prerelease.length>0&&!o)continue;return s}}return undefined}t.getTagSha=getTagSha},7351:function(e,t,s){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,s,a){if(a===undefined)a=s;Object.defineProperty(e,a,{enumerable:true,get:function(){return t[s]}})}:function(e,t,s,a){if(a===undefined)a=s;e[a]=t[s]});var r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var s in e)if(s!=="default"&&Object.hasOwnProperty.call(e,s))a(t,e,s);r(t,e);return t};Object.defineProperty(t,"__esModule",{value:true});t.issue=t.issueCommand=void 0;const n=i(s(2037));const o=s(5278);function issueCommand(Line truncated
|
||||
require('./sourcemap-register.js');(()=>{var __webpack_modules__={7412:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.generate=void 0;const a=s(1912);async function generate(e){const{octokit:t,owner:s,repo:r,sha:i,tagRef:n,inputs:o}=e;const{commitTypes:p,defaultCommitType:l}=o;const d=`https://github.com/${s}/${r}`;const c={};e:for await(const{data:e}of t.paginate.iterator(t.rest.repos.listCommits,{per_page:100,owner:s,repo:r,sha:i})){for(const{sha:t,...s}of e){if(t===n)break e;const e=s.commit.message.split("\n")[0];let{type:r,category:i,title:o,flag:m}=a.COMMIT_REGEX.exec(e)?.groups??{};if(!o)continue;m=trim(m);if(m==="ignore")continue;r=trim(r);r=p[r]??l;i=i?trim(i):"";o=trim(o).replace(a.PR_REGEX,((e,t)=>`[${e}](${d}/pull/${t})`));c[r]=c[r]??{};c[r][i]=c[r][i]??[];const u=c[r][i].findIndex((e=>e.title===o));if(u===-1)c[r][i].push({title:o,commits:[t]});else c[r][i][u].commits.push(t)}}const m=unique([...Object.values(p),l]);return m.reduce(((e,t)=>{const s=c[t];if(s==null)return e;e.push(`## ${t}`);const a=Object.keys(s).sort();for(const t of a){const a=s[t];const r=t.length===0;if(!r)e.push(`* **${t}:**`);const i=r?"":" ";for(const{title:t,commits:s}of a){e.push(`${i}* ${t} (${s.map((e=>`[${e.slice(0,8)}](${d}/commit/${e})`)).join(",")})`)}}e.push("");return e}),[]).join("\n")}t.generate=generate;function trim(e){if(e==null)return e;return e.trim().replace(/ {2,}/g," ")}function unique(e){return[...new Set(e)]}},1912:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:true});t.PR_REGEX=t.COMMIT_REGEX=void 0;t.COMMIT_REGEX=/^(?<type>[^)]*)(?:\((?<category>[^)]*?)\)|):(?<title>.*?)(?:\[(?<flag>[^\]]+?)\]|)\s*$/;t.PR_REGEX=/#([1-9]\d*)/g},7331:function(e,t,s){"use strict";var a=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 r=s(2186);const i=a(s(918));const n=a(s(4083));function getToken(){return(0,r.getInput)("github-token",{required:true})}t.getToken=getToken;async function getInputs(){const e=n.default.parse((0,r.getInput)("commit-types",{required:true}));const t=(0,r.getInput)("default-commit-type",{required:true});const s=(0,r.getInput)("release-name",{required:true});const a=(0,r.getBooleanInput)("semver",{required:true});return i.default.object().keys({commitTypes:i.default.object().pattern(i.default.string(),i.default.string()).required(),defaultCommitType:i.default.string().required(),releaseName:i.default.string().required(),semver:i.default.boolean().required()}).validateAsync({commitTypes:e,defaultCommitType:t,releaseName:s,semver:a})}t.getInputs=getInputs},9283:function(e,t,s){"use strict";var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});const r=s(2186);const i=s(5438);const n=a(s(1383));const o=s(9297);const p=s(7412);const l=s(7331);async function run(){const e=await(0,l.getInputs)();const t=(0,i.getOctokit)((0,l.getToken)());const{repo:{owner:s,repo:a},sha:d}=i.context;let c=null;if(e.semver){c=n.default.parse(e.releaseName,{includePrerelease:true});if(c==null)return(0,r.setFailed)(`Expected a semver compatible releaseName, got "${e.releaseName}" instead.`)}let m=false;if(c!=null)m=c.prerelease.length>0;const{sha:u,name:h}=await(0,o.getTagSha)({octokit:t,owner:s,repo:a,sha:d,semver:c,prerelease:m});let g=await(0,p.generate)({octokit:t,owner:s,repo:a,sha:d,tagRef:u,inputs:e});if(h!=null){g+=`\n\n**Full Changelog**: https://github.com/${s}/${a}/compare/${h}...${e.releaseName}`}(0,r.info)(`-> prerelease: ${m}`);(0,r.setOutput)("prerelease",m);(0,r.info)(`-> changelog: "${g}"`);(0,r.setOutput)("changelog",g)}run().catch(r.setFailed)},9297:function(e,t,s){"use strict";var a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});t.getTagSha=void 0;const r=a(s(1383));async function getTagSha(e){const{octokit:t,owner:s,repo:a,sha:i,semver:n,prerelease:o}=e;for await(const{data:e}of t.paginate.iterator(t.rest.repos.listTags,{per_page:100,owner:s,repo:a})){for(const{name:t,commit:{sha:s}}of e){if(i===s)continue;if(n==null)return{sha:s,name:t};const e=r.default.parse(t,{includePrerelease:true});if(e==null||n.compare(e)<=0)continue;if(e.prerelease.length>0&&!o)continue;return{sha:s,name:t}}}return{}}t.getTagSha=getTagSha},7351:function(e,t,s){"use strict";var a=this&&this.__createBinding||(Object.create?function(e,t,s,a){if(a===undefined)a=s;Object.defineProperty(e,a,{enumerable:true,get:function(){return t[s]}})}:function(e,t,s,a){if(a===undefined)a=s;e[a]=t[s]});var r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var s in e)if(s!=="default"&&Object.hasOwnProperty.call(e,s))a(t,e,s);r(tLine truncated
|
||||
/*!
|
||||
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
||||
*
|
||||
|
||||
+1
-1
@@ -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/markdown-summary.js","../webpack:/auto-changelog/node_modules/@actions/core/lib/oidc-utils.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/auth.js","../webpack:/auto-changelog/node_modules/@actions/http-client/index.js","../webpack:/auto-changelog/node_modules/@actions/http-client/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/any.js","../webpack:/auto-changelog/node_modules/joi/lib/types/array.js","../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/markdown-summary.js","../webpack:/auto-changelog/node_modules/@actions/core/lib/oidc-utils.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/auth.js","../webpack:/auto-changelog/node_modules/@actions/http-client/index.js","../webpack:/auto-changelog/node_modules/@actions/http-client/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/any.js","../webpack:/auto-changelog/node_modules/joi/lib/types/array.js","../Line truncated
|
||||
@@ -29,6 +29,11 @@ export interface TagInputI {
|
||||
prerelease: boolean;
|
||||
}
|
||||
|
||||
export interface TagResultI {
|
||||
sha?: string;
|
||||
name?: string;
|
||||
}
|
||||
|
||||
export interface ChangelogInputI {
|
||||
octokit: InstanceType<typeof GitHub>;
|
||||
owner: string;
|
||||
|
||||
+10
-6
@@ -30,7 +30,7 @@ async function run() {
|
||||
|
||||
if (semver != null) prerelease = semver.prerelease.length > 0;
|
||||
|
||||
const tagRef = await getTagSha({
|
||||
const { sha: tagRef, name: tagName } = await getTagSha({
|
||||
octokit,
|
||||
owner,
|
||||
repo,
|
||||
@@ -39,7 +39,7 @@ async function run() {
|
||||
prerelease,
|
||||
});
|
||||
|
||||
const changelog = await generate({
|
||||
let changelog = await generate({
|
||||
octokit,
|
||||
owner,
|
||||
repo,
|
||||
@@ -48,13 +48,17 @@ async function run() {
|
||||
inputs,
|
||||
});
|
||||
|
||||
info(changelog);
|
||||
if (tagName != null) {
|
||||
changelog += `\n\n**Full Changelog**: https://github.com/${owner}/${repo}/compare/${tagName}...${inputs.releaseName}`;
|
||||
}
|
||||
|
||||
setOutput("changelog", changelog);
|
||||
|
||||
info(`prerelease: ${prerelease}`);
|
||||
info(`-> prerelease: ${prerelease}`);
|
||||
|
||||
setOutput("prerelease", prerelease);
|
||||
|
||||
info(`-> changelog: "${changelog}"`);
|
||||
|
||||
setOutput("changelog", changelog);
|
||||
}
|
||||
|
||||
run().catch(setFailed);
|
||||
+5
-5
@@ -1,7 +1,7 @@
|
||||
import SemVer from "semver";
|
||||
import { TagInputI } from "./constants.js";
|
||||
import type { TagInputI, TagResultI } from "./constants.js";
|
||||
|
||||
export async function getTagSha(input: TagInputI): Promise<string | undefined> {
|
||||
export async function getTagSha(input: TagInputI): Promise<TagResultI> {
|
||||
const { octokit, owner, repo, sha, semver, prerelease } = input;
|
||||
|
||||
for await (const { data } of octokit.paginate.iterator(
|
||||
@@ -18,7 +18,7 @@ export async function getTagSha(input: TagInputI): Promise<string | undefined> {
|
||||
} of data) {
|
||||
if (sha === tagSha) continue;
|
||||
|
||||
if (semver == null) return tagSha;
|
||||
if (semver == null) return { sha: tagSha, name };
|
||||
|
||||
const tagSemver = SemVer.parse(name, { includePrerelease: true });
|
||||
|
||||
@@ -26,9 +26,9 @@ export async function getTagSha(input: TagInputI): Promise<string | undefined> {
|
||||
|
||||
if (tagSemver.prerelease.length > 0 && !prerelease) continue;
|
||||
|
||||
return tagSha;
|
||||
return { sha: tagSha, name };
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
return {};
|
||||
}
|
||||
Reference in new issue
Block a user