Allow for Multiple Changelogs (#488)

Allows for generating multiple changelogs, useful in further alphas/betas.

[COMBINE]
commits = ["fbd1584e7baed4a3603e3c810066603185f1b230"]
[COMBINE]

[FIXUP]
[[fixes]]
sha = "8fc1c45080f3247f973308aa8824629b98b18a91"
newTitle = "Fix Draconic Evolution Crash (#484)"
newBody = """
[BUG]
[IGNORE]
after = "1.7-alpha-2"
[IGNORE]
"""
[FIXUP]
This commit is contained in:
Integer Limit 2023-10-26 20:25:26 +11:00 committed by GitHub
parent 74597941ad
commit 542655bcfb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 87 additions and 13 deletions

View File

@ -30,7 +30,7 @@ on:
required: false required: false
type: string type: string
compare_tag: compare_tag:
description: Tag to compare to. See CONTRIBUTING.md for more information. description: Tag(s) to compare against. If specifying multiple, seperate by commas. (Spaces allowed). See CONTRIBUTING.md for more information.
required: false required: false
type: string type: string
separate_upload: separate_upload:

View File

@ -16,7 +16,7 @@ on:
- 'Beta Release' - 'Beta Release'
- 'Alpha Release' - 'Alpha Release'
compare_tag: compare_tag:
description: Tag to compare against. If not set, will use the tag before `Tag`. description: Tag(s) to compare against. If not set, will use the tag before `Tag`. If specifying multiple, seperate by commas. (Spaces allowed).
required: false required: false
branch: branch:
description: Branch to push changelog to. If not set, changelog will just be uploaded as an artifact. description: Branch to push changelog to. If not set, changelog will just be uploaded as an artifact.

View File

@ -29,7 +29,7 @@ on:
required: false required: false
type: string type: string
compare_tag: compare_tag:
description: Tag to compare to. See CONTRIBUTING.md for more information. description: Tag(s) to compare against. If specifying multiple, seperate by commas. (Spaces allowed). See CONTRIBUTING.md for more information.
required: false required: false
type: string type: string
deploy_to_gh: deploy_to_gh:

View File

@ -16,7 +16,7 @@ on:
- 'Beta Release' - 'Beta Release'
- 'Alpha Release' - 'Alpha Release'
compare_tag: compare_tag:
description: Tag to compare against. description: Tag(s) to compare against. If not set, will use the tag before `Tag`. If specifying multiple, seperate by commas. (Spaces allowed).
required: false required: false
branch: branch:
description: Branch to push changelog to. If not set, changelog will just be uploaded as an artifact. description: Branch to push changelog to. If not set, changelog will just be uploaded as an artifact.

View File

@ -17,7 +17,7 @@ on:
- 'Beta Release' - 'Beta Release'
- 'Alpha Release' - 'Alpha Release'
compare_tag: compare_tag:
description: Tag to compare to. See CONTRIBUTING.md for more information. description: Tag(s) to compare against. If specifying multiple, seperate by commas. (Spaces allowed). See CONTRIBUTING.md for more information.
required: false required: false
type: string type: string
deploy_to_gh: deploy_to_gh:

View File

@ -19,6 +19,9 @@ export default class ChangelogData {
// Set of tags // Set of tags
tags: Set<string>; tags: Set<string>;
/**
* A normal initialisation.
*/
async init(): Promise<void> { async init(): Promise<void> {
this.since = getLastGitTag(); this.since = getLastGitTag();
this.to = "HEAD"; this.to = "HEAD";
@ -54,4 +57,38 @@ export default class ChangelogData {
this.tags = new Set<string>(await getTags(this.to)); this.tags = new Set<string>(await getTags(this.to));
} }
shouldIterate(): boolean {
return isEnvVariableSet("COMPARE_TAG");
}
/**
* Gets the compare tags, or iterations. Also sets up the iteration environment.
* @return tags The Compare Tags
*/
getIterations(): string[] {
const iterations = process.env.COMPARE_TAG;
return iterations.split(",").map((tag) => tag.trim());
}
/**
* Setups the state for a iteration. Init must be called first.
*/
setupIteration(compareTag: string): void {
this.since = compareTag;
}
/**
* Resets the state for a future iteration. Init must be called first.
*/
resetForIteration(): void {
// Reset all lists, except builder
this.commitList = [];
this.commitFixes = new Map<string, FixUpInfo>();
this.shaList = new Set<string>();
this.combineList = new Map<string, Commit[]>();
// Tags list is fine because the `to` stays the same
}
} }

View File

@ -9,7 +9,7 @@ import { parsers } from "./definitions";
import parse from "./parser"; import parse from "./parser";
import { specialParserSetup } from "./specialParser"; import { specialParserSetup } from "./specialParser";
import generateModChanges from "./generateModChanges"; import generateModChanges from "./generateModChanges";
import pushAll from "./pusher"; import pushAll, { pushChangelog, pushSeperator, pushTitle } from "./pusher";
/** /**
* Generates a changelog based on environmental variables, and saves it a changelog data class. * Generates a changelog based on environmental variables, and saves it a changelog data class.
@ -18,6 +18,32 @@ async function createChangelog(): Promise<ChangelogData> {
const data: ChangelogData = new ChangelogData(); const data: ChangelogData = new ChangelogData();
await data.init(); await data.init();
// Handle Iterations
if (data.shouldIterate()) {
const tags = data.getIterations();
pushTitle(data);
for (const tag of tags) {
data.setupIteration(tag);
categoriesSetup();
specialParserSetup(data);
for (const parser of parsers) {
await parse(data, parser);
}
await generateModChanges(data);
pushChangelog(data);
if (tags.indexOf(tag) < tags.length - 1) {
// More to go
pushSeperator(data);
data.resetForIteration();
}
}
return data;
}
categoriesSetup(); categoriesSetup();
specialParserSetup(data); specialParserSetup(data);

View File

@ -6,7 +6,13 @@ import { repoLink } from "./definitions";
let data: ChangelogData; let data: ChangelogData;
export default function pushAll(inputData: ChangelogData): void { export default function pushAll(inputData: ChangelogData): void {
pushTitle(inputData);
pushChangelog(inputData);
}
export function pushTitle(inputData: ChangelogData): void {
data = inputData; data = inputData;
// Push the titles. // Push the titles.
// Center Align is replaced by the correct center align style in the respective deployments. // Center Align is replaced by the correct center align style in the respective deployments.
// Must be triple bracketed, to make mustache not html escape it. // Must be triple bracketed, to make mustache not html escape it.
@ -27,6 +33,11 @@ export default function pushAll(inputData: ChangelogData): void {
data.builder.push(`<h1 {{{ CENTER_ALIGN }}}>${data.releaseType} ${data.to}</h1>`, ""); data.builder.push(`<h1 {{{ CENTER_ALIGN }}}>${data.releaseType} ${data.to}</h1>`, "");
data.builder.push("{{{ CF_REDIRECT }}}", ""); data.builder.push("{{{ CF_REDIRECT }}}", "");
} }
}
export function pushChangelog(inputData: ChangelogData): void {
data = inputData;
data.builder.push(`# Changes Since ${data.since}`, ""); data.builder.push(`# Changes Since ${data.since}`, "");
// Push Sections of Changelog // Push Sections of Changelog
@ -55,6 +66,12 @@ export default function pushAll(inputData: ChangelogData): void {
); );
} }
export function pushSeperator(inputData: ChangelogData): void {
data = inputData;
data.builder.push("", "<hr>", "");
}
/** /**
* Pushes a given category to the builders. * Pushes a given category to the builders.
*/ */

View File

@ -205,18 +205,12 @@ export function makeArtifactNameBody(baseName: string): string {
} }
/** /**
* Returns the COMPARE_TAG env if set, else fetches the last tag known to Git using the current branch. * Returns and fetches the last tag known to Git using the current branch.
* @param before Tag to get the tag before. * @param before Tag to get the tag before.
* @returns string Git tag. * @returns string Git tag.
* @throws * @throws
*/ */
export function getLastGitTag(before?: string): string { export function getLastGitTag(before?: string): string {
if (isEnvVariableSet("COMPARE_TAG")) {
checkGitTag(process.env["COMPARE_TAG"]);
return process.env["COMPARE_TAG"];
}
if (before) { if (before) {
before = `"${before}^"`; before = `"${before}^"`;
} }