Browse Source

Test on Circle CI

master
Leo Lamprecht 7 years ago
parent
commit
6efdb0fb9d
  1. 29
      circle.yml
  2. 1
      package.json
  3. 70
      scripts/slack.js
  4. 56
      yarn.lock

29
circle.yml

@ -0,0 +1,29 @@
machine:
node:
version: node
compile:
override:
- npm run pack
post:
- cp packed/* $CIRCLE_ARTIFACTS
deployment:
default:
branch: /.*/
owner: zeit
commands:
- node ./scripts/slack.js
release:
tag: /.*/
owner: zeit
commands:
- ghr -t $GITHUB_TOKEN -u $CIRCLE_PROJECT_USERNAME -r $CIRCLE_PROJECT_REPONAME -replace $CIRCLE_TAG packed
- npm publish
dependencies:
pre:
- echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc
post:
- go get github.com/tcnksm/ghr
- npm install -g slackup

1
package.json

@ -126,6 +126,7 @@
"progress": "2.0.0",
"resumer": "0.0.0",
"shebang-loader": "0.0.1",
"slackup": "2.2.0",
"socket.io-client": "2.0.3",
"split-array": "1.0.1",
"strip-ansi": "4.0.0",

70
scripts/slack.js

@ -0,0 +1,70 @@
#!/usr/bin/env node
const slackup = require('slackup')
const fetch = require('node-fetch')
const { CIRCLE_PROJECT_USERNAME, CIRCLE_PROJECT_REPONAME } = process.env
const repo = CIRCLE_PROJECT_USERNAME + '/' + CIRCLE_PROJECT_REPONAME
const commit = process.env.CIRCLE_SHA1
const branch = process.env.CIRCLE_BRANCH
const apiKey = process.env.SLACK_TOKEN
const channel = process.env.SLACK_CHANNEL
const githubToken = process.env.GITHUB_TOKEN
// Skip if not on a zeit repo
if (!/^zeit\//.test(repo)) {
console.log('not a zeit repo')
process.exit(0)
}
if (!apiKey) {
console.log('$SLACKUP_TOKEN not found')
process.exit(0)
}
if (!channel) {
console.log('$SLACKUP_CHANNEL not found')
process.exit(0)
}
if (!githubToken) {
console.log('$GITHUB_TOKEN not found')
process.exit(0)
}
const opts = {
headers: {
authorization: `token ${githubToken}`
}
}
fetch(`https://api.github.com/repos/${repo}/commits/${commit}`, opts)
.then(res => res.json())
.then(res => ({
message: res.commit.message,
authorName: res.commit.author.name,
authorUrl: res.author.html_url
}))
.then(async res => {
const message = `:package: Here are the binaries for the branch *${branch}* of *${repo}* (commit <https://github.com/${repo}/commit/${commit}|${commit.substr(
0,
7
)}> by <${res.authorUrl}|${res.authorName}>):`
const binaries = [
`${__dirname}/../packed/now-macos`,
`${__dirname}/../packed/now-linux`,
`${__dirname}/../packed/now-win.exe`
]
try {
await slackup({ apiKey, channel, type: 'message', message })
await slackup({ apiKey, channel, type: 'file', filePath: binaries[0] })
await slackup({ apiKey, channel, type: 'file', filePath: binaries[1] })
await slackup({ apiKey, channel, type: 'file', filePath: binaries[2] })
} catch (err) {
console.log(`Couldn't send messages/files to Slack`, err)
}
})
.catch(console.error)

56
yarn.lock

@ -155,6 +155,16 @@ argparse@^1.0.7:
dependencies:
sprintf-js "~1.0.2"
args@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/args/-/args-3.0.4.tgz#8f98de16f14547e061ba8ccec82d7f660195c583"
dependencies:
camelcase "4.1.0"
chalk "2.0.1"
minimist "1.2.0"
pkginfo "0.4.0"
string-similarity "1.2.0"
arr-diff@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-2.0.0.tgz#8f3b827f955a8bd669697e4a4256ac3ceae356cf"
@ -924,14 +934,14 @@ callsites@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/callsites/-/callsites-0.2.0.tgz#afab96262910a7f33c19a5775825c69f34e350ca"
camelcase@4.1.0, camelcase@^4.0.0, camelcase@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd"
camelcase@^1.0.2:
version "1.2.1"
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-1.2.1.tgz#9bb5304d2e0b56698b2c758b08a3eaa9daa58a39"
camelcase@^4.0.0, camelcase@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd"
capture-stack-trace@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/capture-stack-trace/-/capture-stack-trace-1.0.0.tgz#4a6fa07399c26bba47f0b2496b4d0fb408c5550d"
@ -966,6 +976,14 @@ chalk@1.1.3, chalk@^1.0.0, chalk@^1.1.0, chalk@^1.1.1, chalk@^1.1.3:
strip-ansi "^3.0.0"
supports-color "^2.0.0"
chalk@2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.0.1.tgz#dbec49436d2ae15f536114e76d14656cdbc0f44d"
dependencies:
ansi-styles "^3.1.0"
escape-string-regexp "^1.0.5"
supports-color "^4.0.0"
chalk@2.1.0, chalk@^2.0.0, chalk@^2.0.1:
version "2.1.0"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.1.0.tgz#ac5becf14fa21b99c6c92ca7a7d7cfd5b17e743e"
@ -1946,6 +1964,14 @@ forever-agent@~0.6.1:
version "0.6.1"
resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91"
form-data@^2.1.2:
version "2.2.0"
resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.2.0.tgz#9a5e3b9295f980b2623cf64fa238b14cebca707b"
dependencies:
asynckit "^0.4.0"
combined-stream "^1.0.5"
mime-types "^2.1.12"
form-data@~2.1.1:
version "2.1.4"
resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.1.4.tgz#33c183acf193276ecaa98143a69e94bfee1750d1"
@ -2729,7 +2755,7 @@ lodash.merge@^4.6.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.0.tgz#69884ba144ac33fe699737a6086deffadd0f89c5"
lodash@^4.0.0, lodash@^4.14.0, lodash@^4.15.0, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.3.0, lodash@^4.8.0:
lodash@^4.0.0, lodash@^4.13.1, lodash@^4.14.0, lodash@^4.15.0, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.3.0, lodash@^4.8.0:
version "4.17.4"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
@ -2883,7 +2909,7 @@ natural-compare@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
node-fetch@1.7.2:
node-fetch@1.7.2, node-fetch@^1.6.3:
version "1.7.2"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.2.tgz#c54e9aac57e432875233525f3c891c4159ffefd7"
dependencies:
@ -3260,6 +3286,10 @@ pkg-dir@^2.0.0:
dependencies:
find-up "^2.1.0"
pkginfo@0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/pkginfo/-/pkginfo-0.4.0.tgz#349dbb7ffd38081fcadc0853df687f0c7744cd65"
pluralize@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-4.0.0.tgz#59b708c1c0190a2f692f1c7618c446b052fd1762"
@ -3666,6 +3696,14 @@ signal-exit@^3.0.0, signal-exit@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d"
slackup@2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/slackup/-/slackup-2.2.0.tgz#7908379f884b8f2b2a8c382cb409755ec29568e3"
dependencies:
args "^3.0.4"
form-data "^2.1.2"
node-fetch "^1.6.3"
slash@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55"
@ -3818,6 +3856,12 @@ stream-to-promise@^1.0.4:
bluebird "~3.0.6"
stream-to-array "~2.3.0"
string-similarity@1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/string-similarity/-/string-similarity-1.2.0.tgz#d75153cb383846318b7a39a8d9292bb4db4e9c30"
dependencies:
lodash "^4.13.1"
string-width@^1.0.1, string-width@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-1.0.2.tgz#118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3"

Loading…
Cancel
Save