From 33eb159a01b7418168190cfba75fe7a0add8a0b8 Mon Sep 17 00:00:00 2001 From: Kevin van Zonneveld Date: Mon, 29 Jan 2018 10:08:02 +0100 Subject: [PATCH] Upload Uppy releases to Edgly.net CDN (#558) * Upload Uppy releases to Edgly.net CDN * Install AWS CLI if needed * Remove unpkg from docs a) Good citizenship to pay for production bandwidth ourselves b) Nice to have a CDN that will exist exactly as long we will :) * Fix typos (thx @goto-bus-stop) --- .gitignore | 1 + .travis.yml | 3 + CHANGELOG.md | 4 +- README.md | 8 +-- bin/upload-to-cdn.sh | 100 +++++++++++++++++++++++++++ env.example.sh | 2 + examples/cdn-example/index.html | 4 +- package.json | 1 + website/src/docs/index.md | 6 +- website/src/examples/i18n/app.html | 6 +- website/themes/uppy/layout/index.ejs | 4 +- 11 files changed, 124 insertions(+), 15 deletions(-) create mode 100755 bin/upload-to-cdn.sh diff --git a/.gitignore b/.gitignore index 32cdbb419..366a950bd 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ config/ nohup.out examples/bundled-example/bundle.js +uppy-*.tgz diff --git a/.travis.yml b/.travis.yml index f54e82fc4..f39f223cd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,6 +22,7 @@ script: - npm run build - npm run test - if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then npm run test:acceptance; fi +- npm run uploadcdn env: global: - CXX=g++-4.8 @@ -33,6 +34,8 @@ env: - secure: YpVwjcpc6FomKgRb0tP8MpITEOfvMP2kTAnpSfG3USMW3mZ8Zkn8CLr471DjpmVE2jHklI6AfPTpGPFb1VOsrS7Ea4jxAJOdBwH6Ab7kL52GX0GYtPsSxeTVME5IMZXsU90UCbAXKOEkZbGq5sIaIHjAePmcNSv+OHb157fqcyX0oSJWDg1eVzBikgWhpKtlcbPFp7AdoIvhDr5bPLyV1c0HmOIEirc0VcoQg3fYsKB7mY5tP7KCqCIJtZtD0+FiSamp13WImD0/7wwX0hbTG2KH3zgjyiKOLxsbwXOIpXIJ0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ISxTJKSepEeqbBUIBQs48S8hr+FHk0VPtpP4HGxqaITRLm+mI1coPRvfISxzrB8d240oup6muhC9Ws4/LXi6v8miyIOs2zoYmGxd56TrUeON3UYlKt6dMava0V4bugARzrafN/tfyI9ccqbHzQLBspQvBI61DzZ5I2vnWpkjfWgIHz9Fl4VzXHqMXwjuTUEu8ibA12b3dHZiJEAoqeb9Oj9QcLPbstPLhlNTZZaOrfiFtwLctI2rFh37slDpAfk5idv3ycxcoG5rbCxgyg5i6dpQqrqHxnyglgHg2/nZ+YA5okeS7nJJNtU/4S6AFRWOUUWMVVY0VBEV+8w+uurl0PDy80RUY3uyK64qAgQ8U0M81/Ys1oyWyn78TqHcbby7V2Ws5I9Yakrq8D+mdfsWYCio8F6LXHSwJ0mt2FanJtdDvpPk9sAwsXZN0n8xhELt5TiRp3bzVIQ0IPUgF54dTG9/zWRvC1P4TFaFU/2fg73ZEUC5aWJoFMnLSZjbZvp5gwpCVd0MjSBk80nF9dHYcavIgJ0wMGI3BMb8Nn6+T11Gw/ycr7OGU4NMkj7i8vSFgKF74piWZyiNW8orkMN6XZgM+o= diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a7961af8..bd4c2577b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -62,7 +62,6 @@ What we need to do to release Uppy 1.0 - [ ] QA: test in multiple browsers and mobile devices - [ ] QA: test uppy server. benchmarks / stress test. multiple connections, different setups, large files (10 GB) - [ ] QA: tests for some plugins -- [ ] automatically host releases on edgly and use that as our main CDN - [ ] docs: on using plugins, all options, list of plugins, i18n - [ ] feature: preset for Transloadit that mimics jQuery SDK, check https://github.com/transloadit/jquery-sdk docs - [ ] refactoring: possibly add CSS-in-JS @@ -126,6 +125,7 @@ To be released: 2018-02-10. - [ ] uppy-server: benchmarks / stress test, large file, uppy-server / tus / S3 (10 GB) - [ ] meta: add https://twin.github.io/better-file-uploads-with-shrine-direct-uploads to the next blog post - [ ] uppy-server: document docker image setup for uppy-server (@ifedapoolarewaju) +- [x] meta: automatically host releases on edgly and use that as our main CDN (#558 / @kvz) - [ ] uppy-server: pass response from uppy-server upload’s endpoint (@ifedapoolarewaju) - [ ] uppy-server: support localhost urls as endpoints (@ifedapoolarewaju) @@ -554,7 +554,7 @@ Theme: Getting together. - [x] tus: add `resumable` capability flag (@arturi) - [x] tus: start fixing pause/resume issues and race conditions (@arturi) - [x] test: working Uppy example on Require Bin — latest version straight from NPM http://requirebin.com/?gist=54e076cccc929cc567cb0aba38815105 (@arturi @acconut) -- [x] meta: update readme docs, add unpkg CDN links (https://unpkg.com/uppy/dist/uppy.min.css) (@arturi) +- [x] meta: update readme docs, add unpkg CDN links (https://transloadit.edgly.net/releases/uppy/v0.22.0/dist/uppy.min.css) (@arturi) - [x] meta: write 0.10 release blog post (@arturi) ## 0.9.0 diff --git a/README.md b/README.md index 75412332f..28b05674d 100644 --- a/README.md +++ b/README.md @@ -64,21 +64,21 @@ $ npm install uppy --save We recommend installing from npm and then using a module bundler such as [Webpack](http://webpack.github.io/), [Browserify](http://browserify.org/) or [Rollup.js](http://rollupjs.org/). -Add CSS [uppy.min.css](https://unpkg.com/uppy/dist/uppy.min.css), either to `` of your HTML page or include in JS, if your bundler of choice supports it — transforms and plugins are available for Browserify and Webpack. +Add CSS [uppy.min.css](https://transloadit.edgly.net/releases/uppy/v0.22.0/dist/uppy.min.css), either to `` of your HTML page or include in JS, if your bundler of choice supports it — transforms and plugins are available for Browserify and Webpack. -Alternatively, you can also use a pre-built bundle, for example from [unpkg CDN](https://unpkg.com/uppy/). In that case, `Uppy` will attach itself to the global `window.Uppy` object. +Alternatively, you can also use a pre-built bundle from Transloadit's CDN: Edgly. In that case `Uppy` will attach itself to the global `window.Uppy` object. > ⚠️ The bundle currently consists of most Uppy plugins, so this method is not recommended for production, as your users will have to download all plugins when you are likely using just a few. 1\. Add a script to the bottom of ``: ``` html - + ``` 2\. Add CSS to ``: ``` html - + ``` 3\. Initialize: diff --git a/bin/upload-to-cdn.sh b/bin/upload-to-cdn.sh new file mode 100755 index 000000000..3e9ce8b40 --- /dev/null +++ b/bin/upload-to-cdn.sh @@ -0,0 +1,100 @@ +#!/usr/bin/env bash +# Upload Uppy releases to Edgly.net CDN. Copyright (c) 2018, Transloadit Ltd. +# +# This file: +# +# - Assumes EDGLY_KEY and EDGLY_SECRET are available (e.g. set via Travis secrets) +# - Tries to load env.sh instead, if not +# - Checks if a tag is being built (on Travis - otherwise opts to continue execution regardless) +# - Installs AWS CLI if needed +# - Assumed a fully built uppy is in root dir (unless a specific tag was specified, then it's fetched from npm) +# - Runs npm pack, and stores files to e.g. https://transloadit.edgly.net/releases/uppy/v0.22.0/dist/uppy.css +# - Uses local package by default, if [version] argument was specified, takes package from npm +# +# Run as: +# +# ./upload-to-cdn.sh [version] +# +# To upload all versions in one go (DANGER): +# +# git tag |awk -Fv '{print "./bin/upload-to-cdn.sh "$2}' |bash +# +# Authors: +# +# - Kevin van Zonneveld +set -o pipefail +set -o errexit +set -o nounset +# set -o xtrace + +# Set magic variables for current FILE & DIR +__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +__file="${__dir}/$(basename "${BASH_SOURCE[0]}")" +__base="$(basename ${__file} .sh)" +__root="$(cd "$(dirname "${__dir}")" && pwd)" + +function fatal () { + echo "❌ ${*}"; + exit 1 +} + +pushd "${__root}" > /dev/null 2>&1 + if [ -z "${EDGLY_KEY:-}" ] && [ -f ./env.sh ]; then + source ./env.sh + fi + + [ -z "${EDGLY_KEY:-}" ] && fatal "Unable to find or source EDGLY_KEY env var" + + if [ "${TRAVIS:-}" = "true" ]; then + if [ -z "${TRAVIS_TAG:-}" ]; then + echo "On Travis (TRAVIS is '${TRAVIS}'), I'm only pushing releases to the CDN when a tag is being built (TRAVIS_TAG is '${TRAVIS_TAG}')" + exit 0; + fi + fi + + type aws || pip install --user awscli + + remoteVersion="${1:-}" + version="${remoteVersion}" + if [ -z "${remoteVersion}" ]; then + localVersion=$(node -pe "require('./package.json').version") + echo "${localVersion}" + version="${localVersion}" + fi + + echo -n "--> Check if not overwriting an existing tag ... " + env \ + AWS_ACCESS_KEY_ID="${EDGLY_KEY}" \ + AWS_SECRET_ACCESS_KEY="${EDGLY_SECRET}" \ + aws s3 ls \ + --region="us-east-1" \ + "s3://crates.edgly.net/756b8efaed084669b02cb99d4540d81f/default/releases/uppy/v${version}/package.json" > /dev/null 2>&1 && fatal "Tag ${version} already exists" + echo "✅" + + echo "--> Obtain relevant npm files for uppy ${version} ... " + if [ -z "${remoteVersion}" ]; then + npm pack || fatal "Unable to fetch " + else + npm pack "uppy@${remoteVersion}" + fi + echo "✅" + rm -rf /tmp/uppy-to-edgly + mkdir -p /tmp/uppy-to-edgly + cp -af "uppy-${version}.tgz" /tmp/uppy-to-edgly/ + tar zxvf "uppy-${version}.tgz" -C /tmp/uppy-to-edgly/ + + echo "--> Upload to edgly.net CDN" + pushd /tmp/uppy-to-edgly/package + # --delete \ + env \ + AWS_ACCESS_KEY_ID="${EDGLY_KEY}" \ + AWS_SECRET_ACCESS_KEY="${EDGLY_SECRET}" \ + aws s3 sync \ + --region="us-east-1" \ + --exclude 'website/*' \ + --exclude 'node_modules/*' \ + --exclude 'examples/*/node_modules/*' \ + ./ "s3://crates.edgly.net/756b8efaed084669b02cb99d4540d81f/default/releases/uppy/v${version}" + popd > /dev/null 2>&1 + rm -rf /tmp/uppy-to-edgly +popd > /dev/null 2>&1 \ No newline at end of file diff --git a/env.example.sh b/env.example.sh index 69f35fc52..73f856c12 100644 --- a/env.example.sh +++ b/env.example.sh @@ -8,6 +8,8 @@ export UPPYSERVER_GOOGLE_KEY="***" export UPPYSERVER_GOOGLE_SECRET="***" export UPPYSERVER_INSTAGRAM_KEY="***" export UPPYSERVER_INSTAGRAM_SECRET="***" +export EDGLY_KEY="***" +export EDGLY_SECRET="***" # Let's not set this by default, because that will make acceptance tests Always run on Saucelabs ## export SAUCE_ACCESS_KEY="***" diff --git a/examples/cdn-example/index.html b/examples/cdn-example/index.html index 896d2abc6..9c78a3cf7 100644 --- a/examples/cdn-example/index.html +++ b/examples/cdn-example/index.html @@ -4,11 +4,11 @@ - + - + + ``` 2\. Add CSS to ``: ``` html - + ``` 3\. Initialize: diff --git a/website/src/examples/i18n/app.html b/website/src/examples/i18n/app.html index cd840e653..9d211bbb8 100644 --- a/website/src/examples/i18n/app.html +++ b/website/src/examples/i18n/app.html @@ -1,9 +1,11 @@ - +
- + + +