Unverified Commit bf3b1b56 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Update release.js and release package to avoid github rate limit (#15575)

parent 4730a106
...@@ -109,7 +109,7 @@ ...@@ -109,7 +109,7 @@
"react": "16.12.0", "react": "16.12.0",
"react-dom": "16.12.0", "react-dom": "16.12.0",
"react-ssr-prepass": "1.0.8", "react-ssr-prepass": "1.0.8",
"release": "6.2.0", "release": "6.3.0",
"request-promise-core": "1.1.2", "request-promise-core": "1.1.2",
"rimraf": "2.6.3", "rimraf": "2.6.3",
"selenium-standalone": "6.18.0", "selenium-standalone": "6.18.0",
......
const fetch = require('node-fetch')
// --------------------
// Repo
const owner = 'vercel'
const repo = 'next.js'
// --------------------
// Config
// section -> label // section -> label
const sectionLabelMap = { const sectionLabelMap = {
'Core Changes': 'type: next', 'Core Changes': 'type: next',
...@@ -22,7 +11,7 @@ const fallbackSection = 'Misc Changes' ...@@ -22,7 +11,7 @@ const fallbackSection = 'Misc Changes'
const prNumberRegex = /\(#([-0-9]+)\)/ const prNumberRegex = /\(#([-0-9]+)\)/
const getCommitPullRequest = async (commit) => { const getCommitPullRequest = async (commit, github) => {
const match = prNumberRegex.exec(commit.title) const match = prNumberRegex.exec(commit.title)
if (!match) { if (!match) {
...@@ -30,15 +19,18 @@ const getCommitPullRequest = async (commit) => { ...@@ -30,15 +19,18 @@ const getCommitPullRequest = async (commit) => {
} }
const number = parseInt(match[1], 10) const number = parseInt(match[1], 10)
const url = `https://api.github.com/repos/${owner}/${repo}/pulls/${number}`
const res = await fetch(url)
if (!res.ok) { if (!number) {
console.warn(`\n\n⚠️ Failed to fetch PR #${number}\n`)
return null return null
} }
return await res.json() const { data } = await github.connection.pullRequests.get({
owner: github.repoDetails.user,
repo: github.repoDetails.repo,
number,
})
return data
} }
const getSectionForPullRequest = (pullRequest) => { const getSectionForPullRequest = (pullRequest) => {
...@@ -64,6 +56,7 @@ const groupByLabels = async (commits, github) => { ...@@ -64,6 +56,7 @@ const groupByLabels = async (commits, github) => {
for (const commit of commits) { for (const commit of commits) {
const pullRequest = await getCommitPullRequest(commit, github) const pullRequest = await getCommitPullRequest(commit, github)
console.log({ pullRequest })
if (pullRequest) { if (pullRequest) {
const section = getSectionForPullRequest(pullRequest) const section = getSectionForPullRequest(pullRequest)
...@@ -153,9 +146,11 @@ const buildChangelog = (sections, authors) => { ...@@ -153,9 +146,11 @@ const buildChangelog = (sections, authors) => {
} }
module.exports = async (markdown, metadata) => { module.exports = async (markdown, metadata) => {
const { commits, authors } = metadata const { commits, authors, githubConnection, repoDetails } = metadata
const github = { connection: githubConnection, repoDetails }
const sections = await groupByLabels(commits.all) const sections = await groupByLabels(commits.all, github)
const changelog = buildChangelog(sections, authors) const changelog = buildChangelog(sections, authors)
return changelog return changelog
......
...@@ -13455,10 +13455,10 @@ regjsparser@^0.6.4: ...@@ -13455,10 +13455,10 @@ regjsparser@^0.6.4:
dependencies: dependencies:
jsesc "~0.5.0" jsesc "~0.5.0"
release@6.2.0: release@6.3.0:
version "6.2.0" version "6.3.0"
resolved "https://registry.yarnpkg.com/release/-/release-6.2.0.tgz#47b56a77fa39f4dde47f355d91289310f46c9409" resolved "https://registry.yarnpkg.com/release/-/release-6.3.0.tgz#bbd351d7460948f1ed55ea02b4b2393f98a1637a"
integrity sha512-tYuoyD4ID5aWyfVETRUVwOsE7Xw/+lmfItr1hBdQynSJ6dMJ8z8gjYLUl88FaAO2OfW8sRQWdPMCPydKI+8lfA== integrity sha512-p2dQcsNzCwI0LMHFb/BAd49NrTbIlt2krjaDVHsjV40tScLIRHVatEtN+4MV4Xx9jKKGiZGoM2gtrSn6vJeM1g==
dependencies: dependencies:
"@octokit/rest" "15.2.6" "@octokit/rest" "15.2.6"
args "4.0.0" args "4.0.0"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment