Skip to content
This repository has been archived by the owner on Feb 27, 2019. It is now read-only.

Commit

Permalink
first version of github upload script
Browse files Browse the repository at this point in the history
  • Loading branch information
Swiip committed Jul 19, 2016
1 parent c710685 commit b819716
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 8 deletions.
11 changes: 5 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ node_js:
- stable

env:
global:
- secure: lkTGpgQdeg5mBji8hg1ZpKO3eO4P0KNgy/VUY3o9WK9poKp+x8Hg72lwRsk2UYxeIUBzxJvSk0FFleeyKnEfH2o6nzvFqseUl+6WlOfFW2lVrDQD7gpT8uk73j6UNVT/oqh3mPO+Hw3c/AnFX7BtLaJJqjn684Twu/uX3wlP2T5dQVIdkHYWW4uxK1qvrGDHux3xDUrDMg+mO4GQKMqiPFlWUGcZHrZNwzMgkbFfhnPbV7W1BPtzPXWfOgVf++hy2wSEWJ3yxcGGC859VioBIgpxXZ6yYIzMto6HmgqL3OaH0jth5Ub5G3GOK1w5y0KmFT4p6wbFDhqm59hCXBxZ8cdD+YH6eEInvhwFbqaI2R1TFtJQCH6eAz3biGvq+vmkRSgwqmOI90F4gUha16xYvGIhDq27j1mVc/BrMtFAAOaa3R74HRHd0Y81FqcCPG2Og6qessns5nPJtSen6vvd9ZJVftRsMUhnOO8AovOZIodm0uP9iDNe3gwpWyXn0YUyXloXeZooXp+Fr6QhvzPcE70K2iwLkzudYhnC1e+s1eOVmPf40zB/vpCUAcuzf9CMxfq7fx1ALcAE8D+Fk2kW/kBZycBlT2KwK5VzpfeplbnuOASRjtlER/u/tDDzJoF/qgbSgQtO+kHWCZ1rImoYI9I4r2dOA8pk8CmUZW65BE8=
- GIT_NAME: Travis CI
- GIT_EMAIL: [email protected]
- GITHUB_REPO: FountainJS/fountain
global:
- secure: lkTGpgQdeg5mBji8hg1ZpKO3eO4P0KNgy/VUY3o9WK9poKp+x8Hg72lwRsk2UYxeIUBzxJvSk0FFleeyKnEfH2o6nzvFqseUl+6WlOfFW2lVrDQD7gpT8uk73j6UNVT/oqh3mPO+Hw3c/AnFX7BtLaJJqjn684Twu/uX3wlP2T5dQVIdkHYWW4uxK1qvrGDHux3xDUrDMg+mO4GQKMqiPFlWUGcZHrZNwzMgkbFfhnPbV7W1BPtzPXWfOgVf++hy2wSEWJ3yxcGGC859VioBIgpxXZ6yYIzMto6HmgqL3OaH0jth5Ub5G3GOK1w5y0KmFT4p6wbFDhqm59hCXBxZ8cdD+YH6eEInvhwFbqaI2R1TFtJQCH6eAz3biGvq+vmkRSgwqmOI90F4gUha16xYvGIhDq27j1mVc/BrMtFAAOaa3R74HRHd0Y81FqcCPG2Og6qessns5nPJtSen6vvd9ZJVftRsMUhnOO8AovOZIodm0uP9iDNe3gwpWyXn0YUyXloXeZooXp+Fr6QhvzPcE70K2iwLkzudYhnC1e+s1eOVmPf40zB/vpCUAcuzf9CMxfq7fx1ALcAE8D+Fk2kW/kBZycBlT2KwK5VzpfeplbnuOASRjtlER/u/tDDzJoF/qgbSgQtO+kHWCZ1rImoYI9I4r2dOA8pk8CmUZW65BE8=
- GIT_NAME: Travis CI
- GIT_EMAIL: [email protected]
- GITHUB_REPO: FountainJS/fountain

# Deactive fetch submodules by Travis. (e.g. before_script)
git:
Expand Down Expand Up @@ -75,5 +75,4 @@ before_cache:

after_success:
- echo $TRAVIS_TAG
- if [ ! -z "$TRAVIS_TAG" ]; then echo $TRAVIS_TAG; fi
- if [ ! -z "$TRAVIS_TAG" ] && [[ ${TRAVIS_JOB_NUMBER} == *".1" ]]; then node ./scripts/dist; node ./scripts/upload; fi
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"mkdirp-promise": "^2.0.0",
"mocha": "^2.4.5",
"mz": "^2.4.0",
"node-fetch": "^1.5.3",
"rimraf-promise": "^2.0.0",
"sauce-connect-launcher": "^0.14.0",
"semver": "^5.1.0",
Expand Down
38 changes: 36 additions & 2 deletions scripts/upload.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,37 @@
console.log('upload script');
const fs = require('fs');
const path = require('path');
const co = require('co');
const fetch = require('node-fetch');
const FormData = require('form-data');

console.log('env GIT_NAME', process.env.GIT_NAME);
const combinations = require('./helpers/combinations');

try {
co(function *() {
for (const options of combinations.full()) {
const fileName = `${options.framework}-${options.modules}-${options.js}-${options.css}-${options.router}-${options.sample}.zip`;
const combinationPath = path.join(__dirname, `../dist/${fileName}`);

const form = new FormData();
form.append('name', fileName);
form.append(fileName, fs.createReadStream(combinationPath), {
headers: {
'Authorization': process.env.GITHUB_TOKEN,
'Content-Type': 'application/zip'
}
});

const url = `https://github.com/repos/FountainJS/fountain/releases/${process.env.TRAVIS_TAG}/assets`;

console.log('Uploading', fileName, 'to', url);

yield fetch(url, {
method: 'POST',
body: form,
headers: form.getHeaders()
});
}
});
} catch (error) {
console.log('Something went wrong', error);
}

0 comments on commit b819716

Please sign in to comment.