From 74567e2c8638849a6bdf0afec1a3f261009ecb70 Mon Sep 17 00:00:00 2001 From: Luca Zeug Date: Thu, 12 Jan 2017 02:46:01 +0100 Subject: [PATCH 1/5] add gulp-task 'upload-binaries' --- .travis.yml | 1 + gulpfile.js | 64 +++++++++++++++++++++++++++++++++++++++++++++++++--- package.json | 1 + yarn.lock | 22 ++++++++++++++---- 4 files changed, 81 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index abfda8b8d..b50e50c9e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,7 @@ cache: branches: only: - develop + - master addons: apt: diff --git a/gulpfile.js b/gulpfile.js index fe3b4efd2..d9c27e55e 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -21,6 +21,8 @@ const mocha = require('gulp-spawn-mocha'); const minimist = require('minimist'); const fs = require('fs'); const got = require('got'); +const Q = require('bluebird'); +const githubUpload = Q.promisify(require('gh-release-assets')); const options = minimist(process.argv.slice(2), { string: ['platform', 'walletSource'], @@ -347,6 +349,52 @@ gulp.task('release-dist', ['build-dist'], (done) => { done(); }); +gulp.task('upload-binaries', (cb) => { + // token must be set using travis' ENVs + const GITHUB_TOKEN = process.env.GITHUB_TOKEN; + + // query github releases + return got(`https://api.github.com/repos/luclu/mist/releases?access_token=${GITHUB_TOKEN}`, { + json: true, + }) + // filter draft with current version's tag + .then((res) => { + let draft; + res.body.forEach((release) => { + if (release.tag_name.match(version) + && release.draft === true + ) { + draft = release; + } + }); + + return draft; + }) + // upload binaries from release folders + .then((draft) => { + if (draft && draft.assets.length !== 0) throw new Error('Github release draft already contains assets; will not upload'); + + const dir = `dist_${type}/release`; + const binaries = _.map(fs.readdirSync(dir), (file) => { return path.join(dir, file); }); + + return githubUpload({ + url: `https://uploads.github.com/repos/luclu/mist/releases/${draft.id}/assets{?name}`, + token: [GITHUB_TOKEN], + assets: binaries, + }).then((res) => { + console.log(`Successfully uploaded ${res}`); + + cb(); + }); + }) + .catch((err) => { + if (err.message === "Cannot read property 'id' of undefined") { + console.log(Error(`Couldn't find github release draft for v${version} release tag`)); + } else { + console.log(err); + } + }); +}); gulp.task('get-release-checksums', (done) => { const releasePath = `./dist_${type}/release`; @@ -388,9 +436,13 @@ gulp.task('download-signatures', (cb) => { .catch(cb); }); -gulp.task('taskQueue', [ - 'release-dist', -]); +gulp.task('taskQueue', ['release-dist'], () => { + console.log(`TRAVIS_BRANCH: ${process.env.TRAVIS_BRANCH}`) + console.log(`TRAVIS_PULL_REQUEST_BRANCH: ${process.env.TRAVIS_PULL_REQUEST_BRANCH}`) + if (process.env.CI && process.env.TRAVIS_BRANCH === 'master') { + runSeq('upload-binaries'); + } +}); // MIST task gulp.task('mist', (cb) => { @@ -402,6 +454,12 @@ gulp.task('wallet', (cb) => { runSeq('set-variables-wallet', 'taskQueue', cb); }); +// CI task +gulp.task('ci', (cb) => { + runSeq('set-variables-mist', 'taskQueue', cb); + runSeq('set-variables-wallet', 'taskQueue', cb); +}); + // WALLET task gulp.task('mist-checksums', (cb) => { runSeq('set-variables-mist', 'get-release-checksums', cb); diff --git a/package.json b/package.json index c4e5817c1..78ac6d5e5 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "eslint-plugin-import": "^1.16.0", "genomatic": "^1.0.0", "geth-private": "^1.3.0", + "gh-release-assets": "^1.1.0", "gulp": "^3.9.0", "gulp-flatten": "^0.3.0", "gulp-spawn-mocha": "^2.2.2", diff --git a/yarn.lock b/yarn.lock index ec86b88a9..719767931 100644 --- a/yarn.lock +++ b/yarn.lock @@ -212,6 +212,10 @@ async@>=0.1.0, async@^2.0.0, async@^2.0.1: dependencies: lodash "^4.8.0" +async@^0.9.0: + version "0.9.2" + resolved "https://registry.yarnpkg.com/async/-/async-0.9.2.tgz#aea74d5e61c1f899613bf64bda66d4c78f2fd17d" + async@~0.2.6: version "0.2.10" resolved "https://registry.yarnpkg.com/async/-/async-0.2.10.tgz#b6bbe0b0674b9d719708ca38de8c237cb526c3d1" @@ -1656,6 +1660,16 @@ getpass@^0.1.1: dependencies: assert-plus "^1.0.0" +gh-release-assets@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/gh-release-assets/-/gh-release-assets-1.1.0.tgz#00f76bd151d020032de10712f525d2a944814595" + dependencies: + async "^0.9.0" + mime "^1.3.4" + progress-stream "^1.1.1" + request "^2.55.0" + util-extend "^1.0.1" + glob-base@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/glob-base/-/glob-base-0.3.0.tgz#dbb164f6221b1c0b1ccf82aea328b497df0ea3c4" @@ -1863,11 +1877,11 @@ graceful-fs@^3.0.0, graceful-fs@~3.0.2: dependencies: natives "^1.1.0" -graceful-fs@^4.0.0, graceful-fs@^4.1.10, graceful-fs@^4.1.6, graceful-fs@^4.1.9: +graceful-fs@^4.0.0, graceful-fs@^4.1.10: version "4.1.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" -graceful-fs@^4.1.0, graceful-fs@^4.1.2: +graceful-fs@^4.1.0, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9: version "4.1.9" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.9.tgz#baacba37d19d11f9d146d3578bc99958c3787e29" @@ -3411,7 +3425,7 @@ process-nextick-args@~1.0.6: version "1.0.7" resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3" -progress-stream@^1.1.0, progress-stream@^1.2.0: +progress-stream@^1.1.0, progress-stream@^1.1.1, progress-stream@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/progress-stream/-/progress-stream-1.2.0.tgz#2cd3cfea33ba3a89c9c121ec3347abe9ab125f77" dependencies: @@ -3660,7 +3674,7 @@ request@2.74.0: tough-cookie "~2.3.0" tunnel-agent "~0.4.1" -request@^2.45.0, request@^2.65.0: +request@^2.45.0, request@^2.55.0, request@^2.65.0: version "2.75.0" resolved "https://registry.yarnpkg.com/request/-/request-2.75.0.tgz#d2b8268a286da13eaa5d01adf5d18cc90f657d93" dependencies: From a7f0e5702ea855f22bf1b97999959541ed5a61eb Mon Sep 17 00:00:00 2001 From: Luca Zeug Date: Thu, 12 Jan 2017 02:46:15 +0100 Subject: [PATCH 2/5] fix ESLint errors --- gulpfile.js | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index d9c27e55e..794600f71 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -112,8 +112,10 @@ gulp.task('copy-app-source-files', ['clean:dist'], () => { './*.js', './clientBinaries.json', '!gulpfile.js', - ], { base: './' }) - .pipe(gulp.dest(`./dist_${type}/app`)); + ], { + base: './' + }) + .pipe(gulp.dest(`./dist_${type}/app`)); }); @@ -136,9 +138,11 @@ gulp.task('copy-build-folder-files', ['clean:dist', 'copy-app-folder-files'], () return gulp.src([ `./icons/${type}/*`, './interface/public/images/dmg-background.jpg', - ], { base: './' }) - .pipe(flatten()) - .pipe(gulp.dest(`./dist_${type}/build`)); + ], { + base: './' + }) + .pipe(flatten()) + .pipe(gulp.dest(`./dist_${type}/build`)); }); @@ -151,7 +155,7 @@ gulp.task('copy-node-folder-files', ['clean:dist'], () => { streams.push(gulp.src([ `./nodes/eth/${osArch}/*`, ]) - .pipe(gulp.dest(`./dist_${type}/app/nodes/eth/${osArch}`))); + .pipe(gulp.dest(`./dist_${type}/app/nodes/eth/${osArch}`))); } }); @@ -190,7 +194,7 @@ gulp.task('bundling-interface', ['switch-production'], (cb) => { if (options.walletSource === 'local') { console.log('Use local wallet at ../meteor-dapp-wallet/app'); exec(`cd interface/ && meteor-build-client ../dist_${type}/app/interface/ -p "" &&` + - `cd ../../meteor-dapp-wallet/app && meteor-build-client ../../mist/dist_${type}/app/interface/wallet -p ""`, (err, stdout) => { + `cd ../../meteor-dapp-wallet/app && meteor-build-client ../../mist/dist_${type}/app/interface/wallet -p ""`, (err, stdout) => { console.log(stdout); cb(err); @@ -198,7 +202,7 @@ gulp.task('bundling-interface', ['switch-production'], (cb) => { } else { console.log(`Pulling https://github.com/ethereum/meteor-dapp-wallet/tree/${options.walletSource} "${options.walletSource}" branch...`); exec(`cd interface/ && meteor-build-client ../dist_${type}/app/interface/ -p "" &&` + - `cd ../dist_${type}/ && git clone --depth 1 https://github.com/ethereum/meteor-dapp-wallet.git && cd meteor-dapp-wallet/app && meteor-build-client ../../app/interface/wallet -p "" && cd ../../ && rm -rf meteor-dapp-wallet`, (err, stdout) => { + `cd ../dist_${type}/ && git clone --depth 1 https://github.com/ethereum/meteor-dapp-wallet.git && cd meteor-dapp-wallet/app && meteor-build-client ../../app/interface/wallet -p "" && cd ../../ && rm -rf meteor-dapp-wallet`, (err, stdout) => { console.log(stdout); cb(err); @@ -213,8 +217,10 @@ gulp.task('copy-i18n', ['bundling-interface'], () => { return gulp.src([ './interface/i18n/*.*', './interface/project-tap.i18n', - ], { base: './' }) - .pipe(gulp.dest(`./dist_${type}/app`)); + ], { + base: './' + }) + .pipe(gulp.dest(`./dist_${type}/app`)); }); @@ -236,7 +242,7 @@ gulp.task('build-dist', ['download-signatures', 'copy-i18n'], (cb) => { 'build-dist.js', ], extraFiles: [ - 'nodes/eth/${os}-${arch}', // eslint-disable-line no-template-curly-in-string + 'nodes/eth/${os}-${arch}', // eslint-disable-line no-template-curly-in-string ], linux: { target: [ @@ -263,7 +269,8 @@ gulp.task('build-dist', ['download-signatures', 'copy-i18n'], (cb) => { x: 441, y: 142, type: 'file', - }], + } + ], }, }, directories: { @@ -322,7 +329,7 @@ gulp.task('release-dist', ['build-dist'], (done) => { _.each(osArchList, (osArch) => { if (platformIsActive(osArch)) { - switch (osArch) { // eslint-disable-line default-case + switch (osArch) { // eslint-disable-line default-case case 'win-ia32': // cp(path.join('win-ia32', `${applicationName} Setup ${version}-ia32.exe`), `${appNameHypen}-win32-${versionDashed}.exe`); cp(`${applicationName}-${version}-ia32-win.zip`, `${appNameHypen}-win32-${versionDashed}.zip`); @@ -402,7 +409,9 @@ gulp.task('get-release-checksums', (done) => { const files = fs.readdirSync(releasePath); for (const file of files) { - const sha = shell.exec(`shasum -a 256 "${file}"`, { cwd: releasePath }); + const sha = shell.exec(`shasum -a 256 "${file}"`, { + cwd: releasePath + }); if (sha.code !== 0) { return done(new Error(`Error executing shasum: ${sha.stderr}`)); From 29b322074ab3935ac8a6bbf118cc1d986af9c6f8 Mon Sep 17 00:00:00 2001 From: Luca Zeug Date: Thu, 12 Jan 2017 04:45:04 +0100 Subject: [PATCH 3/5] improvements and fixes --- gulpfile.js | 45 +++++++++++++++++---------------------------- 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 794600f71..778fe7359 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -356,7 +356,7 @@ gulp.task('release-dist', ['build-dist'], (done) => { done(); }); -gulp.task('upload-binaries', (cb) => { +gulp.task('upload-binaries', () => { // token must be set using travis' ENVs const GITHUB_TOKEN = process.env.GITHUB_TOKEN; @@ -366,40 +366,32 @@ gulp.task('upload-binaries', (cb) => { }) // filter draft with current version's tag .then((res) => { - let draft; - res.body.forEach((release) => { - if (release.tag_name.match(version) - && release.draft === true - ) { - draft = release; - } - }); + const draft = res.body[_.indexOf(_.pluck(res.body, 'tag_name'), `v${version}`)]; + + if (draft === undefined) throw new Error(`Couldn't find github release draft for v${version} release tag`); return draft; }) // upload binaries from release folders .then((draft) => { - if (draft && draft.assets.length !== 0) throw new Error('Github release draft already contains assets; will not upload'); - const dir = `dist_${type}/release`; - const binaries = _.map(fs.readdirSync(dir), (file) => { return path.join(dir, file); }); + const files = fs.readdirSync(dir); + const filePaths = _.map(files, (file) => { return path.join(dir, file); }); + + // check if draft already contains target binaries + const existingAssets = _.intersection(files, _.pluck(draft.assets, 'name')); + if (!_.isEmpty(existingAssets)) throw new Error(`Github release draft already contains assets (${existingAssets}); will not upload, please remove and trigger rebuild`); return githubUpload({ url: `https://uploads.github.com/repos/luclu/mist/releases/${draft.id}/assets{?name}`, token: [GITHUB_TOKEN], - assets: binaries, + assets: filePaths, }).then((res) => { - console.log(`Successfully uploaded ${res}`); - - cb(); + console.log(`Successfully uploaded ${res} to v${version} release draft.`); }); }) .catch((err) => { - if (err.message === "Cannot read property 'id' of undefined") { - console.log(Error(`Couldn't find github release draft for v${version} release tag`)); - } else { - console.log(err); - } + console.log(err); }); }); @@ -445,11 +437,9 @@ gulp.task('download-signatures', (cb) => { .catch(cb); }); -gulp.task('taskQueue', ['release-dist'], () => { - console.log(`TRAVIS_BRANCH: ${process.env.TRAVIS_BRANCH}`) - console.log(`TRAVIS_PULL_REQUEST_BRANCH: ${process.env.TRAVIS_PULL_REQUEST_BRANCH}`) - if (process.env.CI && process.env.TRAVIS_BRANCH === 'master') { - runSeq('upload-binaries'); +gulp.task('taskQueue', ['release-dist'], (cb) => { + if (process.env.TRAVIS_BRANCH === 'master') { + runSeq('upload-binaries', cb); } }); @@ -465,8 +455,7 @@ gulp.task('wallet', (cb) => { // CI task gulp.task('ci', (cb) => { - runSeq('set-variables-mist', 'taskQueue', cb); - runSeq('set-variables-wallet', 'taskQueue', cb); + runSeq('set-variables-mist', 'taskQueue', 'set-variables-wallet', 'taskQueue', cb); }); // WALLET task From c09437321080d6d7161d14b4d85bc69b2da1131d Mon Sep 17 00:00:00 2001 From: Luca Zeug Date: Thu, 12 Jan 2017 13:48:50 +0100 Subject: [PATCH 4/5] switch URLs to ethereum/mist repo --- gulpfile.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 778fe7359..9a06ffba5 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -361,7 +361,7 @@ gulp.task('upload-binaries', () => { const GITHUB_TOKEN = process.env.GITHUB_TOKEN; // query github releases - return got(`https://api.github.com/repos/luclu/mist/releases?access_token=${GITHUB_TOKEN}`, { + return got(`https://api.github.com/repos/ethereum/mist/releases?access_token=${GITHUB_TOKEN}`, { json: true, }) // filter draft with current version's tag @@ -383,7 +383,7 @@ gulp.task('upload-binaries', () => { if (!_.isEmpty(existingAssets)) throw new Error(`Github release draft already contains assets (${existingAssets}); will not upload, please remove and trigger rebuild`); return githubUpload({ - url: `https://uploads.github.com/repos/luclu/mist/releases/${draft.id}/assets{?name}`, + url: `https://uploads.github.com/repos/ethereum/mist/releases/${draft.id}/assets{?name}`, token: [GITHUB_TOKEN], assets: filePaths, }).then((res) => { From 7795309dd4223145678adf2e69f76a7d3d7db308 Mon Sep 17 00:00:00 2001 From: Luca Zeug Date: Fri, 20 Jan 2017 14:48:40 +0100 Subject: [PATCH 5/5] also build wallet if on master branch --- .travis.yml | 2 ++ gulpfile.js | 5 ----- package.json | 3 +-- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 49e9d3539..f167f91c7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -67,9 +67,11 @@ install: script: - if [[ $TRAVIS_BRANCH != "master" ]]; then unset CSC_LINK CSC_KEY_PASSWORD; fi # disable macOS code-signing (production certificate) on develop branch - travis_wait 60 gulp mist --platform $GULP_PLATFORM + - if [[ $TRAVIS_BRANCH == "master" ]]; then travis_wait 60 gulp wallet --platform $GULP_PLATFORM; fi # also build wallet if on master branch after_success: - gulp mist-checksums --platform $GULP_PLATFORM + - if [[ $TRAVIS_BRANCH == "master" ]]; then gulp wallet-checksums --platform $GULP_PLATFORM; fi notifications: webhooks: diff --git a/gulpfile.js b/gulpfile.js index ef95fe682..fcdf538b6 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -457,11 +457,6 @@ gulp.task('wallet', (cb) => { runSeq('set-variables-wallet', 'taskQueue', cb); }); -// CI task -gulp.task('ci', (cb) => { - runSeq('set-variables-mist', 'taskQueue', 'set-variables-wallet', 'taskQueue', cb); -}); - // WALLET task gulp.task('mist-checksums', (cb) => { runSeq('set-variables-mist', 'get-release-checksums', cb); diff --git a/package.json b/package.json index 78ac6d5e5..2e79e4353 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,7 @@ "url": "https://github.com/ethereum/mist.git" }, "scripts": { - "postinstall": "cd interface && yarn", - "ci": "gulp --platform=linux" + "postinstall": "cd interface && yarn" }, "main": "main.js", "dependencies": {