From a070ece6238c08f27d97fa5ec723ba097aaf52c9 Mon Sep 17 00:00:00 2001 From: Brad White Date: Wed, 13 Nov 2024 22:26:37 -0700 Subject: [PATCH] add date for serverless template --- src/common/github-service.ts | 11 +++++++++++ src/config/templates/serverless.ts | 2 +- src/pages/release-notes/release-note-output.tsx | 5 ++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/common/github-service.ts b/src/common/github-service.ts index 7df2020..8504854 100644 --- a/src/common/github-service.ts +++ b/src/common/github-service.ts @@ -51,6 +51,7 @@ class GitHubService { private octokit: Octokit; private repoId: number | undefined; public repoName: string; + public serverlessReleaseDate: string | undefined; constructor(config: GitHubServiceConfig) { this.octokit = config.octokit; @@ -294,6 +295,16 @@ class GitHubService { throw error; }); + const commitDate = commits.data.items[0]?.commit?.committer?.date; + + if (commitDate) { + this.serverlessReleaseDate = new Date(commitDate).toLocaleDateString('en-US', { + year: 'numeric', + month: 'long', + day: 'numeric', + }); + } + const shas = commits.data.items .slice(0, 2) .map((item) => item.commit.message.split('See elastic/kibana@')[1]); diff --git a/src/config/templates/serverless.ts b/src/config/templates/serverless.ts index 45463f1..2f8b561 100644 --- a/src/config/templates/serverless.ts +++ b/src/config/templates/serverless.ts @@ -21,7 +21,7 @@ export const serverlessTemplate: Config = { pages: { releaseNotes: `[discrete] [[release-notes-{{version}}]] -=== {{version}} +=== {{serverlessReleaseDate}} {{#prs.breaking}} [discrete] diff --git a/src/pages/release-notes/release-note-output.tsx b/src/pages/release-notes/release-note-output.tsx index 2f8f702..d348144 100644 --- a/src/pages/release-notes/release-note-output.tsx +++ b/src/pages/release-notes/release-note-output.tsx @@ -1,6 +1,6 @@ import { EuiFlexGroup, EuiFlexItem, EuiCallOut, EuiCode } from '@elastic/eui'; import { FC, useMemo } from 'react'; -import { groupByArea, groupPrs, PrItem } from '../../common'; +import { groupByArea, groupPrs, PrItem, useGitHubService } from '../../common'; import semver from 'semver'; import { renderGroupedByArea, @@ -16,6 +16,7 @@ interface Props { } export const ReleaseNoteOutput: FC = ({ prs, version: ver }) => { + const [github] = useGitHubService(); const config = useActiveConfig(); const version = ver.replace(/^v(.*)$/, '$1'); const isServerless = ver === 'serverless'; @@ -57,11 +58,13 @@ export const ReleaseNoteOutput: FC = ({ prs, version: ver }) => { prs: renderedGroups, nextMajorVersion: isServerless ? '' : `${semver.major(version) + 1}.0.0`, isPatchRelease: isPatchVersion, + serverlessReleaseDate: github.serverlessReleaseDate, } ).trim(), [ config.templates.pages.patchReleaseNotes, config.templates.pages.releaseNotes, + github.serverlessReleaseDate, isPatchVersion, isServerless, renderedGroups,