Skip to content
This repository has been archived by the owner on Sep 5, 2020. It is now read-only.

Commit

Permalink
[gulp] new task 'upload-binaries' (to github) (#1578)
Browse files Browse the repository at this point in the history
* add gulp-task 'upload-binaries'

* fix ESLint errors

* improvements and fixes

* switch URLs to ethereum/mist repo

* also build wallet if on master branch
  • Loading branch information
luclu authored Jan 23, 2017
1 parent 7e102af commit cc27bc3
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 23 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
85 changes: 68 additions & 17 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down Expand Up @@ -110,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`));
});


Expand All @@ -134,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`));
});


Expand All @@ -149,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}`)));
}
});

Expand Down Expand Up @@ -188,15 +194,15 @@ 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);
});
} 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);
Expand All @@ -211,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`));
});


Expand All @@ -234,7 +242,7 @@ gulp.task('build-dist', ['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: [
Expand All @@ -261,7 +269,8 @@ gulp.task('build-dist', ['copy-i18n'], (cb) => {
x: 441,
y: 142,
type: 'file',
}],
}
],
},
},
directories: {
Expand Down Expand Up @@ -320,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`);
Expand Down Expand Up @@ -351,14 +360,54 @@ gulp.task('release-dist', ['build-dist'], (done) => {
done();
});

gulp.task('upload-binaries', () => {
// token must be set using travis' ENVs
const GITHUB_TOKEN = process.env.GITHUB_TOKEN;

// query github releases
return got(`https://api.github.com/repos/ethereum/mist/releases?access_token=${GITHUB_TOKEN}`, {
json: true,
})
// filter draft with current version's tag
.then((res) => {
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) => {
const dir = `dist_${type}/release`;
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/ethereum/mist/releases/${draft.id}/assets{?name}`,
token: [GITHUB_TOKEN],
assets: filePaths,
}).then((res) => {
console.log(`Successfully uploaded ${res} to v${version} release draft.`);
});
})
.catch((err) => {
console.log(err);
});
});

gulp.task('get-release-checksums', (done) => {
const releasePath = `./dist_${type}/release`;

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}`));
Expand Down Expand Up @@ -392,9 +441,11 @@ gulp.task('download-signatures', (cb) => {
.catch(cb);
});

gulp.task('taskQueue', [
'release-dist',
]);
gulp.task('taskQueue', ['release-dist'], (cb) => {
if (process.env.TRAVIS_BRANCH === 'master') {
runSeq('upload-binaries', cb);
}
});

// MIST task
gulp.task('mist', (cb) => {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -47,6 +46,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",
Expand Down
22 changes: 18 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -3660,7 +3674,7 @@ [email protected]:
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:
Expand Down

0 comments on commit cc27bc3

Please sign in to comment.