Skip to content

Commit

Permalink
Change changelog interval from daily to weekly
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-helmich committed Jan 17, 2025
1 parent 169f367 commit 1754198
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Generate API changelogs
on:
workflow_dispatch:
schedule:
- cron: '0 20 * * *'
- cron: '0 20 * * 5' # Friday, 20:00
jobs:
generate-changelog:
runs-on: ubuntu-latest
Expand Down
22 changes: 17 additions & 5 deletions generator/generate-changelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function groupChangelogByOperation(changelog: ChangelogEntry[]) {
}

async function generateAPIChangeIntroduction(
since: Date,
changelog: ChangelogEntry[],
): Promise<string | undefined> {
const now = new Date();
Expand All @@ -46,7 +47,9 @@ async function generateAPIChangeIntroduction(
{
role: "system",
content:
"You are an API changelog generator. Your task is to generate an introduction to a changelog entry for the mittwald API, dated " +
"You are an API changelog generator. Your task is to generate an introduction to a changelog entry for the mittwald API, dated for the week from " +
since.toLocaleDateString() +
" until " +
now.toLocaleDateString() +
"You will be provided a JSON document with a list of changes to the mittwald API. " +
"You will output an introductory sentence for a changelog entry, summarizing the API changes in a single sentence, formatted in markdown." +
Expand All @@ -59,13 +62,18 @@ async function generateAPIChangeIntroduction(
});

if (completion.choices[0].finish_reason === "length") {
const formattedDate = now.toLocaleDateString("en-US", {
const formatDateOpts: Intl.DateTimeFormatOptions = {
year: "numeric",
month: "long",
day: "numeric",
});
};
const formattedDateSince = since.toLocaleDateString(
"en-US",
formatDateOpts,
);
const formattedDateNow = now.toLocaleDateString("en-US", formatDateOpts);

return `This document contains a machine-generated summary of the API changes for ${formattedDate}. The API changes are based on the diff between the OpenAPI schemas of the two versions.`;
return `This document contains a machine-generated summary of the API changes for ${formattedDateSince} until ${formattedDateNow}. The API changes are based on the diff between the OpenAPI schemas of the two versions.`;
}

return completion.choices[0].message.content;
Expand Down Expand Up @@ -140,7 +148,10 @@ async function generateAPIChangelog(apiVersion: APIVersion) {
}

if (changelog.length > 0) {
const introduction = await generateAPIChangeIntroduction(changelog);
const introduction = await generateAPIChangeIntroduction(
baseDate,
changelog,
);
const summary = await generateAPIChangeSummary(changelog);
const clientChangelogs =
apiVersion !== "v1"
Expand All @@ -162,6 +173,7 @@ async function generateAPIChangelog(apiVersion: APIVersion) {
path.join("generator", "templates", "changelog.mdx.ejs"),
{
yaml,
since: baseDate,
today,
apiVersion,
changelog,
Expand Down
8 changes: 5 additions & 3 deletions generator/templates/changelog.mdx.ejs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
---
<%- yaml.stringify({
title: (hasBreakingChanges ? "Breaking (!) " : "") + `API changes for ${apiVersion} API, ${today.toLocaleDateString("en-US", {
year: "numeric",
title: (hasBreakingChanges ? "Breaking (!) " : "") + `API changes for ${apiVersion} API, ${since.toLocaleDateString({
month: "long",
day: "numeric",
day: "numeric"
})} to ${today.toLocaleDateString("en-US", {
month: "long",
day: "numeric"
})}`,
authors: ["machine"],
tags: [
Expand Down

0 comments on commit 1754198

Please sign in to comment.