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 6306a0e
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 37 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
67 changes: 36 additions & 31 deletions generator/templates/changelog.mdx.ejs
Original file line number Diff line number Diff line change
@@ -1,76 +1,81 @@
---
<%- 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: [
"api" + apiVersion,
hasBreakingChanges ? "breaking" : undefined,
...(new Set(changelog.map(l => getOperationById(spec, l.operationId)?.operation.tags[0]).filter(t => t !== undefined)))
"api" + apiVersion,
hasBreakingChanges ? "breaking" : undefined,
...(new Set(changelog.map(l => getOperationById(spec, l.operationId)?.operation.tags[0]).filter(t => t !== undefined)))
].filter(s => s !== undefined)
}) %>
}); %>
---
import OperationHint from "@site/src/components/OperationHint";
import OperationLink from "@site/src/components/OperationLink";
<%- introduction %>
<%- introduction; %>
{/* truncate */}
<% if (hasBreakingChanges) { %>
:::caution Breaking changes
:::caution Breaking changes
This document contains changes that can under certain circumstances be considered breaking. Please review the changes carefully.
This document contains changes that can under certain circumstances be considered breaking. Please review the changes carefully.
While we generally strive to avoid breaking changes in accordance with our [API stability guarantees](../../../../../docs/v2/api/stability), we occasionally might perform changes that would be considered breaking in the strictest sense of the term, but we do not consider as breaking in a practical sense. We will always provide ample notice and documentation for such changes.
While we generally strive to avoid breaking changes in accordance with our [API stability guarantees](../../../../../docs/v2/api/stability), we occasionally might perform changes that would be considered breaking in the strictest sense of the term, but we do not consider as breaking in a practical sense. We will always provide ample notice and documentation for such changes.
:::
:::
<% } %>
## Summary
<% if (summary) { %>
<%- summary %>
<%- summary; %>
_Disclaimer: This summary is AI-generated. If you find any discrepancies, please refer to the detailed changes below._
_Disclaimer: This summary is AI-generated. If you find any discrepancies, please refer to the detailed changes below._
<% } else { %>
The following API endpoints have changed:
The following API endpoints have changed:
<% for ([operationId, changes] of groupedChangelog.entries()) { %>
<% if (changes.find(c => c.level === 3)) { %>
- ⚠️ **Breaking changes** to the <OperationLink operation="<%= operationId %>" apiVersion="<%= apiVersion %>" /> endpoint.
<% } else { %>
- Changes to the <OperationLink operation="<%= operationId %>" apiVersion="<%= apiVersion %>" /> endpoint.
<% } %>
<% } %>
<% for ([operationId, changes] of groupedChangelog.entries()) { %>
<% if (changes.find(c => c.level === 3)) { %>
- ⚠️ **Breaking changes** to the
<OperationLink operation="<%= operationId ;%>" apiVersion="<%= apiVersion ;%>" /> endpoint.
<% } else { %>
- Changes to the
<OperationLink operation="<%= operationId ;%>" apiVersion="<%= apiVersion ;%>" /> endpoint.
<% } %>
<% } %>
<% } %>
## Detailed changes
<% for ([operationId, changes] of groupedChangelog.entries()) { %>
### Changes in "<%- canonicalizeTitle(getOperationById(spec, operationId)?.operation.summary) ?? operationId %>"
### Changes in "<%- canonicalizeTitle(getOperationById(spec, operationId)?.operation.summary) ?? operationId; %>"
<% for (change of changes) { %>
- <% if (change.level === 3) { %>⚠️ **Breaking:** <% } %><%- change.text %>
<% } %>
<% for (change of changes) { %>
- <% if (change.level === 3) { %>⚠️ **Breaking:** <% } %><%- change.text; %>
<% } %>
For details, refer to the <OperationLink operation="<%= operationId %>" apiVersion="<%= apiVersion %>" /> endpoint.
For details, refer to the
<OperationLink operation="<%= operationId ;%>" apiVersion="<%= apiVersion ;%>" /> endpoint.
<% } %>
<% if (clientChangelogs && clientChangelogs.length > 0) { %>
## Client package releases
## Client package releases
<% for (const release of clientChangelogs) { %>
<%- release %>
<% } %>
<% for (const release of clientChangelogs) { %>
<%- release; %>
<% } %>
<% } %>

0 comments on commit 6306a0e

Please sign in to comment.