diff --git a/.github/workflows/buildpack.yml b/.github/workflows/buildpack.yml index d0338e4..99bdd4b 100644 --- a/.github/workflows/buildpack.yml +++ b/.github/workflows/buildpack.yml @@ -30,7 +30,7 @@ on: required: false type: string 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 type: string separate_upload: diff --git a/.github/workflows/createchangelog.yml b/.github/workflows/createchangelog.yml index aee4597..f1d87f9 100644 --- a/.github/workflows/createchangelog.yml +++ b/.github/workflows/createchangelog.yml @@ -16,7 +16,7 @@ on: - 'Beta Release' - 'Alpha Release' 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 branch: description: Branch to push changelog to. If not set, changelog will just be uploaded as an artifact. diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 147f7b8..0061515 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -29,7 +29,7 @@ on: required: false type: string 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 type: string deploy_to_gh: diff --git a/.github/workflows/releasechangelog.yml b/.github/workflows/releasechangelog.yml index a0c3dd6..c9bede7 100644 --- a/.github/workflows/releasechangelog.yml +++ b/.github/workflows/releasechangelog.yml @@ -16,7 +16,7 @@ on: - 'Beta Release' - 'Alpha Release' 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 branch: description: Branch to push changelog to. If not set, changelog will just be uploaded as an artifact. diff --git a/.github/workflows/releasedeploy.yml b/.github/workflows/releasedeploy.yml index 06fc567..e24847f 100644 --- a/.github/workflows/releasedeploy.yml +++ b/.github/workflows/releasedeploy.yml @@ -17,7 +17,7 @@ on: - 'Beta Release' - 'Alpha Release' 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 type: string deploy_to_gh: diff --git a/tools/tasks/changelog/changelogData.ts b/tools/tasks/changelog/changelogData.ts index 41a2815..76340ec 100644 --- a/tools/tasks/changelog/changelogData.ts +++ b/tools/tasks/changelog/changelogData.ts @@ -19,6 +19,9 @@ export default class ChangelogData { // Set of tags tags: Set; + /** + * A normal initialisation. + */ async init(): Promise { this.since = getLastGitTag(); this.to = "HEAD"; @@ -54,4 +57,38 @@ export default class ChangelogData { this.tags = new Set(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(); + this.shaList = new Set(); + this.combineList = new Map(); + + // Tags list is fine because the `to` stays the same + } } diff --git a/tools/tasks/changelog/createChangelog.ts b/tools/tasks/changelog/createChangelog.ts index eda3fc2..e1c9181 100644 --- a/tools/tasks/changelog/createChangelog.ts +++ b/tools/tasks/changelog/createChangelog.ts @@ -9,7 +9,7 @@ import { parsers } from "./definitions"; import parse from "./parser"; import { specialParserSetup } from "./specialParser"; 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. @@ -18,6 +18,32 @@ async function createChangelog(): Promise { const data: ChangelogData = new ChangelogData(); 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(); specialParserSetup(data); diff --git a/tools/tasks/changelog/pusher.ts b/tools/tasks/changelog/pusher.ts index f89755b..847d2fe 100644 --- a/tools/tasks/changelog/pusher.ts +++ b/tools/tasks/changelog/pusher.ts @@ -6,7 +6,13 @@ import { repoLink } from "./definitions"; let data: ChangelogData; export default function pushAll(inputData: ChangelogData): void { + pushTitle(inputData); + pushChangelog(inputData); +} + +export function pushTitle(inputData: ChangelogData): void { data = inputData; + // Push the titles. // 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. @@ -27,6 +33,11 @@ export default function pushAll(inputData: ChangelogData): void { data.builder.push(`

${data.releaseType} ${data.to}

`, ""); data.builder.push("{{{ CF_REDIRECT }}}", ""); } +} + +export function pushChangelog(inputData: ChangelogData): void { + data = inputData; + data.builder.push(`# Changes Since ${data.since}`, ""); // 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("", "
", ""); +} + /** * Pushes a given category to the builders. */ diff --git a/tools/util/util.ts b/tools/util/util.ts index 5a5a04b..997fa57 100644 --- a/tools/util/util.ts +++ b/tools/util/util.ts @@ -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. * @returns string Git tag. * @throws */ export function getLastGitTag(before?: string): string { - if (isEnvVariableSet("COMPARE_TAG")) { - checkGitTag(process.env["COMPARE_TAG"]); - - return process.env["COMPARE_TAG"]; - } - if (before) { before = `"${before}^"`; }