Unverified Commit 6e5eb2c4 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Update publish canary to undraft automatically (#47775)

x-ref: [slack
thread](https://vercel.slack.com/archives/C04DUD7EB1B/p1680313038895799?thread_ts=1680303743.811339&cid=C04DUD7EB1B)
parent d66236f2
...@@ -2,6 +2,7 @@ const path = require('path') ...@@ -2,6 +2,7 @@ const path = require('path')
const execa = require('execa') const execa = require('execa')
const resolveFrom = require('resolve-from') const resolveFrom = require('resolve-from')
const ansiEscapes = require('ansi-escapes') const ansiEscapes = require('ansi-escapes')
const fetch = require('node-fetch')
async function main() { async function main() {
const args = process.argv const args = process.argv
...@@ -72,6 +73,41 @@ async function main() { ...@@ -72,6 +73,41 @@ async function main() {
child.stdin.write('\n') child.stdin.write('\n')
} }
await child await child
if (isCanary) {
try {
const ghHeaders = {
Accept: 'application/vnd.github+json',
Authorization: `Bearer ${githubToken}`,
'X-GitHub-Api-Version': '2022-11-28',
}
const { version } = require('../lerna.json')
const releaseUrlRes = await fetch(
`https://api.github.com/repos/vercel/next.js/releases/tag/${version}`,
{
headers: ghHeaders,
}
)
const { url } = await releaseUrlRes.json()
const undraftRes = await fetch(url, {
headers: ghHeaders,
method: 'PATCH',
body: JSON.stringify({
draft: false,
name: version,
}),
})
if (undraftRes.ok) {
console.log('undrafted canary release successfuly')
} else {
console.log(`Failed to undraft`, await undraftRes.text())
}
} catch (err) {
console.error(`Failed to undraft release`, err)
}
}
} }
main() main()
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