mirror of
https://github.com/darksaid98/auto-changelog.git
synced 2026-12-03 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
@@ -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