Skip to content

Commit

Permalink
Publish metadata file to S3.
Browse files Browse the repository at this point in the history
Remove publishing tarball to `/${channel}.tgz` due to npm and yarn
caching issues.

Publishes a new `/${channel}.json` file (in a stable location) that can
be used by tooling to determine the correct asset path for the current
channel build SHA.

(cherry picked from commit 41985bd)
  • Loading branch information
rwjblue committed Jan 12, 2018
1 parent 2dc45b2 commit c2b7d49
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
12 changes: 10 additions & 2 deletions bin/build-for-publishing.js
Expand Up @@ -4,14 +4,14 @@
const fs = require('fs');
const path = require('path');
const execSync = require('child_process').execSync;
const VERSION = require('../broccoli/version').VERSION;

/*
Updates the `package.json`'s `version` string to be the same value that
the built assets will have as `Ember.VERSION`.
*/
function updatePackageJSONVersion() {
let packageJSONPath = path.join(__dirname, '..', 'package.json');
let VERSION = require('../broccoli/version').VERSION;

let pkgContents = fs.readFileSync(packageJSONPath, { encoding: 'utf-8' });
let pkg = JSON.parse(pkgContents);
Expand All @@ -31,7 +31,6 @@ function updatePackageJSONVersion() {
*/
function updateDocumentationVersion() {
let docsPath = path.join(__dirname, '..', 'docs', 'data.json');
let VERSION = require('../broccoli/version').VERSION;

let contents = fs.readFileSync(docsPath, { encoding: 'utf-8' });
let docs = JSON.parse(contents);
Expand All @@ -51,3 +50,12 @@ updateDocumentationVersion();
// using npm pack here because `yarn pack` does not honor the `package.json`'s `files`
// property properly, and therefore the tarball generated is quite large (~7MB).
execSync('npm pack');

// generate build-metadata.json
const metadata = {
version: VERSION,
buildType: process.env.BUILD_TYPE,
SHA: process.env.TRAVIS_COMMIT,
assetPath: `/${process.env.BUILD_TYPE}/shas/${process.env.TRAVIS_COMMIT}.tgz`,
};
fs.writeFileSync('build-metadata.json', JSON.stringify(metadata, null, 2), { encoding: 'utf-8' });
21 changes: 17 additions & 4 deletions config/s3ProjectConfig.js
Expand Up @@ -26,27 +26,40 @@ function fileMap(revision, tag, date) {
contentType: 'application/x-gzip',
destinations: {
'alpha': [
`alpha.tgz`,
`alpha/daily/${date}.tgz`,
`alpha/shas/${revision}.tgz`,
],
'canary': [
`canary.tgz`,
`canary/daily/${date}.tgz`,
`canary/shas/${revision}.tgz`,
],
'beta': [
`beta.tgz`,
`beta/daily/${date}.tgz`,
`beta/shas/${revision}.tgz`,
],
'release': [
`release.tgz`,
`release/daily/${date}.tgz`,
`release/shas/${revision}.tgz`,
],
}
};
filesToPublish['../build-metadata.json'] = {
contentType: 'application/json',
destinations: {
'alpha': [
'alpha.json',
],
'canary': [
'canary.json',
],
'beta': [
'beta.json',
],
'release': [
'release.json',
],
}
};

return filesToPublish;
}
Expand Down

0 comments on commit c2b7d49

Please sign in to comment.