Skip to content

Commit 0c8d98a

Browse files
author
Orta Therox
authored
Merge pull request #1897 from microsoft/44
Automate the release plan
2 parents 0a00d04 + 37d374a commit 0c8d98a

File tree

4 files changed

+148
-9
lines changed

4 files changed

+148
-9
lines changed

.github/workflows/deploy-prod.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,30 @@ jobs:
1818

1919
- uses: microsoft/playwright-github-action@v1
2020

21-
# Build v2
22-
- name: Build website v2
21+
# Builds the modules, and boostraps the other modules
22+
- name: Build website
2323
run: |
2424
yarn install
2525
yarn docs-sync pull microsoft/TypeScript-Website-localizations#main 1
2626
yarn bootstrap
2727
yarn build
28-
yarn build-site
29-
cp -r packages/typescriptlang-org/public site
3028
env:
3129
YARN_CHECKSUM_BEHAVIOR: ignore
3230

31+
# Update the site plan, scoped out on its own because it gets access to secrets
32+
- run: node packages/typescriptlang-org/scripts/getTypeScriptReleasePlan.js
33+
env:
34+
GITHUB_BOT_TOKEN: ${{ secrets.GITHUB_BOT_TOKEN }}
35+
TEAMS_WEB_BOT_INCOMING_URL: ${{ secrets.TEAMS_WEB_BOT_INCOMING_URL }}
36+
37+
# Builds the site
38+
- name: Makes the site
39+
run: |
40+
yarn build-site
41+
cp -r packages/typescriptlang-org/public site
42+
env:
43+
YARN_CHECKSUM_BEHAVIOR: ignore
44+
3345
# Deploy to the prod appservice
3446
- name: Deploy + Publish to AppService
3547
uses: peaceiris/[email protected]

packages/typescriptlang-org/scripts/getTypeScriptNPMVersions.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ const getTypeScriptNPMVersions = async () => {
126126
? siteReleaseNotesURL
127127
: releasePostURL
128128

129+
const next =
130+
semver.minor(stable) == 9
131+
? `${semver.major(stable) + 1}.${semver.minor(stable)}`
132+
: `${semver.major(stable)}.${semver.minor(stable) + 1}`
133+
129134
return {
130135
tags: {
131136
stableMajMin: `${semver.major(stable)}.${semver.minor(stable)}`,
@@ -134,6 +139,7 @@ const getTypeScriptNPMVersions = async () => {
134139
beta,
135140
rc,
136141
rcMajMin: `${semver.major(rc)}.${semver.minor(rc)}`,
142+
next,
137143
},
138144
isRC,
139145
isBeta,
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
// This script relies on getTypeScriptNPMVersions.js having been ran already
2+
// it will grab the latest TypeScript issue with info about the iteration plan
3+
// and turn that into structured data.
4+
5+
// node packages/typescriptlang-org/scripts/getTypeScriptReleasePlan.js
6+
7+
const Octokit = require("@octokit/rest")
8+
const versionMeta = require("../src/lib/release-info.json")
9+
const fetch = require("node-fetch")
10+
const { format } = require("prettier")
11+
const { writeFileSync } = require("fs")
12+
const { join } = require("path")
13+
14+
const token = process.env.GITHUB_BOT_TOKEN || process.env.GITHUB_TOKEN
15+
if (!token) throw new Error("No GitHub Token at process.env.GITHUB_BOT_TOKEN")
16+
17+
const go = async () => {
18+
const octokit = new Octokit({
19+
auth: token,
20+
userAgent: "TS Website Issue Searcher",
21+
})
22+
23+
const issues = await octokit.search.issuesAndPullRequests({
24+
q: "iteration plan repo:microsoft/typescript state:open type:issues",
25+
})
26+
27+
const upcoming = issues.data.items.find(
28+
i =>
29+
i.title.toLowerCase().includes(versionMeta.tags.next) &&
30+
i.labels.find(l => l.name === "Planning")
31+
)
32+
33+
// Couldn't find the issue, bail,
34+
if (!upcoming) {
35+
return sendTeamsFail(
36+
`Could not find an iteration plan issue for ${versionMeta.tags.next} during the most recent site deploy - see https://github.com/microsoft/TypeScript-website/blob/v2/packages/typescriptlang-org/scripts/getTypeScriptReleaseInfo.js`
37+
)
38+
}
39+
40+
const lines = upcoming.body.toLowerCase().split("\n")
41+
const lastRelease = lines.find(
42+
l =>
43+
l.includes(`${versionMeta.tags.stableMajMin} release`) && l.includes("|")
44+
)
45+
const beta = lines.find(
46+
l => l.includes(`${versionMeta.tags.next} beta release`) && l.includes("|")
47+
)
48+
49+
const rc = lines.find(
50+
l => l.includes(`${versionMeta.tags.next} rc release`) && l.includes("|")
51+
)
52+
53+
const release = lines.find(
54+
l => l.includes(`${versionMeta.tags.next} final release`) && l.includes("|")
55+
)
56+
57+
// Making sure we got good data
58+
const dates = {
59+
lastRelease,
60+
beta,
61+
rc,
62+
release,
63+
}
64+
const missing = []
65+
Object.keys(dates).forEach(key => {
66+
if (!dates[key]) {
67+
missing.push(key)
68+
}
69+
})
70+
if (missing.length) {
71+
// prettier-ignore
72+
return sendTeamsFail(`Could not parse the md table for ${missing.join(",")} in https://github.com/microsoft/TypeScript/issues/${upcoming.number} - see https://github.com/microsoft/TypeScript-website/blob/v2/packages/typescriptlang-org/scripts/getTypeScriptReleaseInfo.js`)
73+
}
74+
75+
// "june 29th | **typescript 4.4 beta release**\r" -> Date
76+
const toDate = str => {
77+
const date = str.split("|")[0].trim()
78+
const components = date.split(" ")
79+
const month = components[0]
80+
const day = components[1].replace("th", "").replace("st", "")
81+
const thisYear = new Date().getFullYear()
82+
const year = parseInt(components[2]) || thisYear
83+
return new Date(`${month} ${day} ${year}`).toISOString()
84+
}
85+
86+
const results = {
87+
"_generated by":
88+
"node packages/typescriptlang-org/scripts/getTypeScriptReleasePlan.js",
89+
upcoming_version: versionMeta.tags.next,
90+
iteration_plan_url: `https://github.com/microsoft/TypeScript/issues/${upcoming.number}`,
91+
last_release_date: toDate(lastRelease),
92+
upcoming_beta_date: toDate(beta),
93+
upcoming_rc_date: toDate(rc),
94+
upcoming_release_date: toDate(release),
95+
}
96+
const jsonPath = join(__dirname, "..", "src", "lib", "release-plan.json")
97+
98+
writeFileSync(
99+
jsonPath,
100+
format(JSON.stringify(results), { filepath: jsonPath })
101+
)
102+
}
103+
104+
go()
105+
106+
const sendTeamsFail = title => {
107+
const teamsURL = process.env.TEAMS_WEB_BOT_INCOMING_URL
108+
const message = {
109+
"@type": "MessageCard",
110+
"@context": "https://schema.org/extensions",
111+
summary: "Website issue",
112+
themeColor: "0078D7",
113+
title,
114+
}
115+
116+
fetch(teamsURL, {
117+
method: "post",
118+
body: JSON.stringify(message),
119+
headers: { "Content-Type": "application/json" },
120+
})
121+
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"_format": "mm/dd/yyyy - these get put into new Date()",
2+
"_generated by": "node packages/typescriptlang-org/scripts/getTypeScriptReleaseInfo.js",
33
"upcoming_version": "4.4",
44
"iteration_plan_url": "https://github.com/microsoft/TypeScript/issues/44237",
5-
"last_release_date": "05/25/2021",
6-
"upcoming_beta_date": "06/25/2021",
7-
"upcoming_rc_date": "07/06/2021",
8-
"upcoming_release_date": "07/24/2021"
5+
"last_release_date": "2021-05-24T23:00:00.000Z",
6+
"upcoming_beta_date": "2021-06-28T23:00:00.000Z",
7+
"upcoming_rc_date": "2021-08-09T23:00:00.000Z",
8+
"upcoming_release_date": "2021-08-23T23:00:00.000Z"
99
}

0 commit comments

Comments
 (0)