Browse Source

Switch to Node.js uploadcdn script

Renée Kooi 6 years ago
parent
commit
722c31262d
4 changed files with 21 additions and 3 deletions
  1. 7 1
      .travis.yml
  2. 12 0
      bin/upload-to-cdn.js
  3. 1 1
      bin/upload-to-cdn.sh
  4. 1 1
      package.json

+ 7 - 1
.travis.yml

@@ -10,7 +10,13 @@ script:
 - npm run build
 - npm run test
 - if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then npm run test:endtoend; fi
-#- npm run uploadcdn
+- |
+  if [ "${TRAVIS_PULL_REQUEST}" = "false" ] &&\
+     [[ "${TRAVIS_COMMIT_MESSAGE}" =~ ^Release* ]]; then
+    npm run uploadcdn uppy
+    npm run uploadcdn @uppy/robodog
+    npm run uploadcdn @uppy/locales
+  fi
 cache:
   apt: true
   directories:

+ 12 - 0
bin/upload-to-cdn.js

@@ -32,6 +32,10 @@ const { promisify } = require('util')
 const readFile = promisify(require('fs').readFile)
 const finished = promisify(require('stream').finished)
 
+function delay (ms) {
+  return new Promise(resolve => setTimeout(resolve, ms))
+}
+
 const AWS_REGION = 'us-east-1'
 const AWS_BUCKET = 'crates.edgly.net'
 const AWS_DIRECTORY = '756b8efaed084669b02cb99d4540d81f/default'
@@ -99,6 +103,14 @@ async function main (packageName, version) {
     version = require(`../packages/${packageName}/package.json`).version
   }
 
+  // Warn if uploading a local build not from CI:
+  // - If we're on CI, this should be a release commit.
+  // - If we're local, normally we should upload a released version, not a local build.
+  if (!remote && !process.env.CI) {
+    console.log('Warning, writing a local build to the CDN, this is usually not what you want. Sleeping 3s. Press CTRL+C!')
+    await delay(3000)
+  }
+
   const packagePath = remote
     ? `${packageName}@${version}`
     : path.join(__dirname, '..', 'packages', packageName)

+ 1 - 1
bin/upload-to-cdn.sh

@@ -169,7 +169,7 @@ pushd "${__root}" > /dev/null 2>&1
 
   if [ "${versionSuffix}" != "" ]; then
     echo "Not setting latest version because versionSuffix was set, which is used for testing only"
-  else 
+  else
     echo "${version}" | env \
       AWS_ACCESS_KEY_ID="${EDGLY_KEY}" \
       AWS_SECRET_ACCESS_KEY="${EDGLY_SECRET}" \

+ 1 - 1
package.json

@@ -120,7 +120,7 @@
     "test:unit": "npm run build:lib && jest",
     "test:watch": "jest --watch",
     "test": "npm-run-all lint test:locale-packs test:unit test:type test:companion",
-    "uploadcdn": "bin/upload-to-cdn.sh",
+    "uploadcdn": "node ./bin/upload-to-cdn",
     "version": "./bin/sync-version-numbers",
     "watch:css": "onchange 'packages/**/*.scss' --initial --verbose -- npm run build:css",
     "watch:js:bundle": "onchange 'packages/{@uppy/,}*/src/**/*.js' --initial --verbose -- npm run build:bundle",