Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions website/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import users from './showcase.json';
import versions from './versions.json';
import prismThemeDark from './core/PrismThemeDark';
import prismThemeLight from './core/PrismThemeLight';
import releaseDatesPlugin from './plugins/releaseDates';

import remarkSnackPlayer from '@react-native-website/remark-snackplayer';
import remarkCodeblockLanguageTitle from '@react-native-website/remark-codeblock-language-as-title';
Expand Down Expand Up @@ -223,6 +224,7 @@ const config: Config = {
],
plugins: [
'docusaurus-plugin-sass',
releaseDatesPlugin,
function disableExpensiveBundlerOptimizationPlugin() {
return {
name: 'disable-expensive-bundler-optimizations',
Expand Down
86 changes: 86 additions & 0 deletions website/plugins/releaseDates.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

import type {Plugin} from '@docusaurus/types';

import {RELEASES} from '../src/components/releases/releasesData';

export type ReleaseDates = Record<string, string>;

const API_URL = 'https://api.github.com/repos/react/react-native/releases';
const TAG_PATTERN = /^v(\d+\.\d+)\.\d+(-rc\.\d+)?$/;
const REQUEST_TIMEOUT_MS = 15_000;

interface GitHubRelease {
tag_name: string;
created_at: string | null;
draft: boolean;
}

/**
* Fetches every React Native GitHub release at build time and exposes the RC,
* .0 and patch dates for the series in `releasesData.ts` as global data, so
* the Release Calendar renders accurate historical dates without a runtime
* GitHub API call. Set `GITHUB_TOKEN` to avoid unauthenticated rate limits.
*/
export default function releaseDatesPlugin(): Plugin<ReleaseDates> {
return {
name: 'release-dates',

async loadContent() {
const trackedSeries = new Set(RELEASES.map(r => r.version));
const headers: Record<string, string> = {
Accept: 'application/vnd.github+json',
};
if (process.env.GITHUB_TOKEN) {
headers.Authorization = `Bearer ${process.env.GITHUB_TOKEN}`;
}

const dates: ReleaseDates = {};
try {
for (let page = 1; ; page++) {
const response = await fetch(`${API_URL}?per_page=100&page=${page}`, {
headers,
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
});
if (!response.ok) {
throw new Error(`GitHub API responded ${response.status}`);
}
const releases = (await response.json()) as GitHubRelease[];
for (const release of releases) {
const series = TAG_PATTERN.exec(release.tag_name)?.[1];
if (
release.draft ||
!release.created_at ||
!series ||
!trackedSeries.has(series)
) {
continue;
}
// `created_at` is the date of the release commit, which matches
// when the version shipped more closely than `published_at`.
dates[release.tag_name] = release.created_at.slice(0, 10);
}
if (releases.length < 100) {
break;
}
}
} catch (error) {
// Don't fail the build: the calendar falls back to its live fetch.
console.warn(
`[release-dates] Could not load GitHub release dates: ${String(error)}`
);
return {};
}
return dates;
},

async contentLoaded({content, actions}) {
actions.setGlobalData(content);
},
};
}
17 changes: 17 additions & 0 deletions website/releases/schedule.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: Release Calendar
sidebar_label: Release Calendar
hide_table_of_contents: true
---

import ReleaseScheduleCalendar from '@site/src/components/releases/ReleaseScheduleCalendar';

View upcoming and recent React Native releases, release candidate milestones, and support windows. For support level definitions and release channels, see the [Releases Overview](/releases/overview).

<ReleaseScheduleCalendar />

:::note

Release dates are shared with the [Releases Overview](/releases/overview) table and enriched with published release candidate tags from [GitHub Releases](https://github.com/react/react-native/releases). Actual dates may shift for stabilization blockers.

:::
1 change: 1 addition & 0 deletions website/sidebarsReleases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type {SidebarsConfig} from '@docusaurus/plugin-content-docs';
export default {
releases: [
'overview',
'schedule',
'branches',
'versioning-policy',
{
Expand Down
Loading