Skip to content

Commit

Permalink
add date for serverless template
Browse files Browse the repository at this point in the history
  • Loading branch information
Ikuni17 committed Nov 14, 2024
1 parent 0b291e0 commit a070ece
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/common/github-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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]);
Expand Down
2 changes: 1 addition & 1 deletion src/config/templates/serverless.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const serverlessTemplate: Config = {
pages: {
releaseNotes: `[discrete]
[[release-notes-{{version}}]]
=== {{version}}
=== {{serverlessReleaseDate}}
{{#prs.breaking}}
[discrete]
Expand Down
5 changes: 4 additions & 1 deletion src/pages/release-notes/release-note-output.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -16,6 +16,7 @@ interface Props {
}

export const ReleaseNoteOutput: FC<Props> = ({ prs, version: ver }) => {
const [github] = useGitHubService();
const config = useActiveConfig();
const version = ver.replace(/^v(.*)$/, '$1');
const isServerless = ver === 'serverless';
Expand Down Expand Up @@ -57,11 +58,13 @@ export const ReleaseNoteOutput: FC<Props> = ({ 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,
Expand Down

0 comments on commit a070ece

Please sign in to comment.