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

Commit

Permalink
improvements and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Luca Zeug committed Jan 12, 2017
1 parent a7f0e57 commit 29b3220
Showing 1 changed file with 17 additions and 28 deletions.
45 changes: 17 additions & 28 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

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

Expand Down Expand Up @@ -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);
}
});

Expand All @@ -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
Expand Down

0 comments on commit 29b3220

Please sign in to comment.