Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct upcoming release date after patch releases #557

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/_data/stats.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"currentVersion": "v9.1.1",
"currentVersionDate": "2024-04-22T19:23:14Z",
"currentVersionIsPrerelease": false,
"stars": 24270,
"lastCommitDate": "2024-04-23T02:08:58Z",
"projectDependents": 19255405,
"stars": 24271,
"lastCommitDate": "2024-04-23T10:56:02Z",
"projectDependents": 19264226,
"weeklyDownloads": 38275199,
"nextVersion": "v9.2.0",
"nextVersionDate": "2024-05-10"
"nextVersionDate": "2024-05-03"
}
18 changes: 15 additions & 3 deletions tools/fetch-stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,21 @@ async function fetchGitHubNetworkStats() {

stats.nextVersion = `v${nextVersion}`;

// approximate next release date
stats.nextVersionDate = DateTime.fromISO(stats.currentVersionDate)
.plus({ weeks: 2 }).endOf("week").minus({ days: 2 }).toISODate();
/*
* Calculate next release date.
* We do scheduled releases every two weeks, on Fridays.
* One of the scheduled release dates was Friday, 2024-01-12. We'll use that date as the baseline.
* So, all planned releases are expected to be on 2024-01-12 + n * 14 days.
* Now we'll find the first such day after the current version date.
*/
const baseDate = DateTime.fromISO("2024-01-12");
const currentVersionDate = DateTime.fromISO(stats.currentVersionDate);

stats.nextVersionDate = currentVersionDate
.plus({
days: 14 - currentVersionDate.diff(baseDate, "days").days % 14
})
.toISODate();

await fs.writeFile(statsFilePath, JSON.stringify(stats, null, 4), { encoding: "utf8" });

Expand Down