2018-03-31 02:20:48 +02:00
|
|
|
#!/usr/bin/env node
|
|
|
|
const request = require('request-promise')
|
2018-04-03 21:33:40 +02:00
|
|
|
const VERSION = require('../dist/chrome/manifest.json').version
|
2018-03-31 02:20:48 +02:00
|
|
|
|
2018-04-03 21:51:18 +02:00
|
|
|
start().catch(console.error)
|
|
|
|
|
2018-07-03 00:49:33 +02:00
|
|
|
async function start () {
|
2018-04-03 21:51:18 +02:00
|
|
|
|
|
|
|
const GITHUB_COMMENT_TOKEN = process.env.GITHUB_COMMENT_TOKEN
|
|
|
|
const CIRCLE_PULL_REQUEST = process.env.CIRCLE_PULL_REQUEST
|
|
|
|
console.log('CIRCLE_PULL_REQUEST', CIRCLE_PULL_REQUEST)
|
|
|
|
const CIRCLE_SHA1 = process.env.CIRCLE_SHA1
|
|
|
|
console.log('CIRCLE_SHA1', CIRCLE_SHA1)
|
|
|
|
const CIRCLE_BUILD_NUM = process.env.CIRCLE_BUILD_NUM
|
|
|
|
console.log('CIRCLE_BUILD_NUM', CIRCLE_BUILD_NUM)
|
|
|
|
|
|
|
|
if (!CIRCLE_PULL_REQUEST) {
|
|
|
|
console.warn(`No pull request detected for commit "${CIRCLE_SHA1}"`)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
const CIRCLE_PR_NUMBER = CIRCLE_PULL_REQUEST.split('/').pop()
|
2018-07-03 00:49:33 +02:00
|
|
|
const SHORT_SHA1 = CIRCLE_SHA1.slice(0, 7)
|
2018-04-03 21:51:18 +02:00
|
|
|
const BUILD_LINK_BASE = `https://${CIRCLE_BUILD_NUM}-42009758-gh.circle-artifacts.com/0`
|
|
|
|
|
2019-09-11 17:35:30 +02:00
|
|
|
// build the github comment content
|
|
|
|
|
|
|
|
// links to extension builds
|
|
|
|
const platforms = ['chrome', 'firefox', 'opera', 'edge']
|
|
|
|
const buildLinks = platforms.map(platform => {
|
|
|
|
const url = `${BUILD_LINK_BASE}/builds/metamask-${platform}-${VERSION}.zip`
|
|
|
|
return `<a href="${url}">${platform}</a>`
|
|
|
|
}).join(', ')
|
|
|
|
|
|
|
|
// links to bundle browser builds
|
2019-09-16 19:11:01 +02:00
|
|
|
const bundles = ['background', 'ui', 'inpage', 'contentscript', 'ui-libs', 'bg-libs', 'phishing-detect']
|
2019-09-11 17:35:30 +02:00
|
|
|
const bundleLinks = bundles.map(bundle => {
|
|
|
|
const url = `${BUILD_LINK_BASE}/build-artifacts/source-map-explorer/${bundle}.html`
|
|
|
|
return `<a href="${url}">${bundle}</a>`
|
|
|
|
}).join(', ')
|
|
|
|
|
2019-09-16 06:19:15 +02:00
|
|
|
// links to bundle browser builds
|
|
|
|
const depVizUrl = `${BUILD_LINK_BASE}/build-artifacts/deps-viz/background/index.html`
|
|
|
|
const depVizLink = `<a href="${depVizUrl}">background</a>`
|
|
|
|
|
|
|
|
// link to artifacts
|
|
|
|
const allArtifactsUrl = `https://circleci.com/gh/MetaMask/metamask-extension/${CIRCLE_BUILD_NUM}#artifacts/containers/0`
|
|
|
|
|
|
|
|
const contentRows = [
|
|
|
|
`builds: ${buildLinks}`,
|
|
|
|
`bundle viz: ${bundleLinks}`,
|
|
|
|
`dep viz: ${depVizLink}`,
|
|
|
|
`<a href="${allArtifactsUrl}">all artifacts</a>`,
|
|
|
|
]
|
|
|
|
const hiddenContent = `<ul>` + contentRows.map(row => `<li>${row}</li>`).join('\n') + `</ul>`
|
2019-09-11 17:35:30 +02:00
|
|
|
const exposedContent = `Builds ready [${SHORT_SHA1}]`
|
|
|
|
const commentBody = `<details><summary>${exposedContent}</summary>${hiddenContent}</details>`
|
2018-04-03 21:51:18 +02:00
|
|
|
|
|
|
|
const JSON_PAYLOAD = JSON.stringify({ body: commentBody })
|
|
|
|
const POST_COMMENT_URI = `https://api.github.com/repos/metamask/metamask-extension/issues/${CIRCLE_PR_NUMBER}/comments`
|
|
|
|
console.log(`Announcement:\n${commentBody}`)
|
|
|
|
console.log(`Posting to: ${POST_COMMENT_URI}`)
|
|
|
|
|
|
|
|
await request({
|
2019-07-31 22:17:11 +02:00
|
|
|
method: 'POST',
|
|
|
|
uri: POST_COMMENT_URI,
|
|
|
|
body: JSON_PAYLOAD,
|
|
|
|
headers: {
|
|
|
|
'User-Agent': 'metamaskbot',
|
|
|
|
'Authorization': `token ${GITHUB_COMMENT_TOKEN}`,
|
|
|
|
},
|
2018-04-03 21:51:18 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
}
|