Merge branch 'master' of https://github.com/MetaMask/metamask-extension into cb-254
commit
34e608e9dc
@ -1,51 +1,62 @@ |
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
const request = require('request-promise') |
const request = require('request-promise') |
||||||
const { version } = require('../dist/chrome/manifest.json') |
const VERSION = require('../dist/chrome/manifest.json').version |
||||||
|
|
||||||
const GITHUB_COMMENT_TOKEN = process.env.GITHUB_COMMENT_TOKEN |
start().catch(console.error) |
||||||
const CIRCLE_PULL_REQUEST = process.env.CIRCLE_PULL_REQUEST |
|
||||||
console.log('CIRCLE_PULL_REQUEST', CIRCLE_PULL_REQUEST) |
async function start() { |
||||||
const CIRCLE_SHA1 = process.env.CIRCLE_SHA1 |
|
||||||
console.log('CIRCLE_SHA1', CIRCLE_SHA1) |
const GITHUB_COMMENT_TOKEN = process.env.GITHUB_COMMENT_TOKEN |
||||||
const CIRCLE_BUILD_NUM = process.env.CIRCLE_BUILD_NUM |
const CIRCLE_PULL_REQUEST = process.env.CIRCLE_PULL_REQUEST |
||||||
console.log('CIRCLE_BUILD_NUM', CIRCLE_BUILD_NUM) |
console.log('CIRCLE_PULL_REQUEST', CIRCLE_PULL_REQUEST) |
||||||
|
const CIRCLE_SHA1 = process.env.CIRCLE_SHA1 |
||||||
const CIRCLE_PR_NUMBER = CIRCLE_PULL_REQUEST.split('/').pop() |
console.log('CIRCLE_SHA1', CIRCLE_SHA1) |
||||||
const SHORT_SHA1 = CIRCLE_SHA1.slice(0,7) |
const CIRCLE_BUILD_NUM = process.env.CIRCLE_BUILD_NUM |
||||||
const BUILD_LINK_BASE = `https://${CIRCLE_BUILD_NUM}-42009758-gh.circle-artifacts.com/0` |
console.log('CIRCLE_BUILD_NUM', CIRCLE_BUILD_NUM) |
||||||
|
|
||||||
const MASCARA = `${BUILD_LINK_BASE}/builds/mascara/home.html` |
if (!CIRCLE_PULL_REQUEST) { |
||||||
const CHROME = `${BUILD_LINK_BASE}/builds/metamask-chrome-${version}.zip` |
console.warn(`No pull request detected for commit "${CIRCLE_SHA1}"`) |
||||||
const FIREFOX = `${BUILD_LINK_BASE}/builds/metamask-firefox-${version}.zip` |
return |
||||||
const EDGE = `${BUILD_LINK_BASE}/builds/metamask-edge-${version}.zip` |
} |
||||||
const OPERA = `${BUILD_LINK_BASE}/builds/metamask-opera-${version}.zip` |
|
||||||
const WALKTHROUGH = `${BUILD_LINK_BASE}/test-artifacts/screens/walkthrough%20%28en%29.gif` |
const CIRCLE_PR_NUMBER = CIRCLE_PULL_REQUEST.split('/').pop() |
||||||
|
const SHORT_SHA1 = CIRCLE_SHA1.slice(0,7) |
||||||
const commentBody = ` |
const BUILD_LINK_BASE = `https://${CIRCLE_BUILD_NUM}-42009758-gh.circle-artifacts.com/0` |
||||||
<details> |
|
||||||
<summary> |
const MASCARA = `${BUILD_LINK_BASE}/builds/mascara/home.html` |
||||||
Builds ready [${SHORT_SHA1}]: |
const CHROME = `${BUILD_LINK_BASE}/builds/metamask-chrome-${VERSION}.zip` |
||||||
<a href="${MASCARA}">mascara</a>, |
const FIREFOX = `${BUILD_LINK_BASE}/builds/metamask-firefox-${VERSION}.zip` |
||||||
<a href="${CHROME}">chrome</a>, |
const EDGE = `${BUILD_LINK_BASE}/builds/metamask-edge-${VERSION}.zip` |
||||||
<a href="${FIREFOX}">firefox</a>, |
const OPERA = `${BUILD_LINK_BASE}/builds/metamask-opera-${VERSION}.zip` |
||||||
<a href="${EDGE}">edge</a>, |
const WALKTHROUGH = `${BUILD_LINK_BASE}/test-artifacts/screens/walkthrough%20%28en%29.gif` |
||||||
<a href="${OPERA}">opera</a> |
|
||||||
</summary> |
const commentBody = ` |
||||||
<image src="${WALKTHROUGH}"> |
<details> |
||||||
</details> |
<summary> |
||||||
` |
Builds ready [${SHORT_SHA1}]: |
||||||
|
<a href="${MASCARA}">mascara</a>, |
||||||
const JSON_PAYLOAD = JSON.stringify({ body: commentBody }) |
<a href="${CHROME}">chrome</a>, |
||||||
const POST_COMMENT_URI = `https://api.github.com/repos/metamask/metamask-extension/issues/${CIRCLE_PR_NUMBER}/comments` |
<a href="${FIREFOX}">firefox</a>, |
||||||
console.log(`Announcement:\n${commentBody}`) |
<a href="${EDGE}">edge</a>, |
||||||
console.log(`Posting to: ${POST_COMMENT_URI}`) |
<a href="${OPERA}">opera</a> |
||||||
|
</summary> |
||||||
request({ |
<image src="${WALKTHROUGH}"> |
||||||
method: 'POST', |
</details> |
||||||
uri: POST_COMMENT_URI, |
` |
||||||
body: JSON_PAYLOAD, |
|
||||||
headers: { |
const JSON_PAYLOAD = JSON.stringify({ body: commentBody }) |
||||||
'User-Agent': 'metamaskbot', |
const POST_COMMENT_URI = `https://api.github.com/repos/metamask/metamask-extension/issues/${CIRCLE_PR_NUMBER}/comments` |
||||||
'Authorization': `token ${GITHUB_COMMENT_TOKEN}`, |
console.log(`Announcement:\n${commentBody}`) |
||||||
}, |
console.log(`Posting to: ${POST_COMMENT_URI}`) |
||||||
}) |
|
||||||
|
await request({ |
||||||
|
method: 'POST', |
||||||
|
uri: POST_COMMENT_URI, |
||||||
|
body: JSON_PAYLOAD, |
||||||
|
headers: { |
||||||
|
'User-Agent': 'metamaskbot', |
||||||
|
'Authorization': `token ${GITHUB_COMMENT_TOKEN}`, |
||||||
|
}, |
||||||
|
}) |
||||||
|
|
||||||
|
} |
||||||
|
@ -0,0 +1,55 @@ |
|||||||
|
#!/usr/bin/env node
|
||||||
|
const pify = require('pify') |
||||||
|
const exec = pify(require('child_process').exec, { multiArgs: true }) |
||||||
|
const VERSION = require('../dist/chrome/manifest.json').version |
||||||
|
|
||||||
|
start().catch(console.error) |
||||||
|
|
||||||
|
async function start(){ |
||||||
|
const authWorked = await checkIfAuthWorks() |
||||||
|
if (!authWorked) { |
||||||
|
console.log(`Sentry auth failed...`) |
||||||
|
} |
||||||
|
// check if version exists or not
|
||||||
|
const versionAlreadyExists = await checkIfVersionExists() |
||||||
|
// abort if versions exists
|
||||||
|
if (versionAlreadyExists) { |
||||||
|
console.log(`Version "${VERSION}" already exists on Sentry, aborting sourcemap upload.`) |
||||||
|
return |
||||||
|
} |
||||||
|
|
||||||
|
// create sentry release
|
||||||
|
console.log(`creating Sentry release for "${VERSION}"...`) |
||||||
|
await exec(`sentry-cli releases --org 'metamask' --project 'metamask' new ${VERSION}`) |
||||||
|
console.log(`removing any existing files from Sentry release "${VERSION}"...`) |
||||||
|
await exec(`sentry-cli releases --org 'metamask' --project 'metamask' files ${VERSION} delete --all`) |
||||||
|
// upload sentry source and sourcemaps
|
||||||
|
console.log(`uploading source files Sentry release "${VERSION}"...`) |
||||||
|
await exec(`for FILEPATH in ./dist/chrome/*.js; do [ -e $FILEPATH ] || continue; export FILE=\`basename $FILEPATH\` && echo uploading $FILE && sentry-cli releases --org 'metamask' --project 'metamask' files ${VERSION} upload $FILEPATH metamask/$FILE; done;`) |
||||||
|
console.log(`uploading sourcemaps Sentry release "${VERSION}"...`) |
||||||
|
await exec(`sentry-cli releases --org 'metamask' --project 'metamask' files ${VERSION} upload-sourcemaps ./dist/sourcemaps/ --url-prefix 'sourcemaps'`) |
||||||
|
console.log('all done!') |
||||||
|
} |
||||||
|
|
||||||
|
async function checkIfAuthWorks() { |
||||||
|
const itWorked = await doesNotFail(async () => { |
||||||
|
await exec(`sentry-cli releases --org 'metamask' --project 'metamask' list`) |
||||||
|
}) |
||||||
|
return itWorked |
||||||
|
} |
||||||
|
|
||||||
|
async function checkIfVersionExists() { |
||||||
|
const versionAlreadyExists = await doesNotFail(async () => { |
||||||
|
await exec(`sentry-cli releases --org 'metamask' --project 'metamask' info ${VERSION}`) |
||||||
|
}) |
||||||
|
return versionAlreadyExists |
||||||
|
} |
||||||
|
|
||||||
|
async function doesNotFail(asyncFn) { |
||||||
|
try { |
||||||
|
await asyncFn() |
||||||
|
return true |
||||||
|
} catch (err) { |
||||||
|
return false |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue