Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving and improving CDN publish script #5468

Merged
merged 1 commit into from
Feb 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions tasks/cdn_publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash -e

# check if aws is installed
if [[ ! -n `which aws` ]]; then
echo "Error: Please install and configure 'aws'."
exit 1
fi

# get plotly.js version from its package json
version=$(node -e "console.log(require('./package.json').version);")
major=$(node -e "console.log(require('./package.json').version.split('.')[0]);")

# read tag either latest or rc
tag=$(node -e "var rc = require('./package.json').version.split('-')[1]; console.log(rc ? rc.split('.')[0] : 'latest');")
# if not v1 add major version to the tag e.g. latest-v2
if [ $major -ne 1 ]; then tag=$tag-v$major; fi
echo $tag

dist=dist
sync=build/sync

# clear and make a sync folder
if [ -d "$sync" ]; then rm -rf $sync; fi
mkdir -p $sync

# copy dist bundles over to the sync folder and rename them
for path in `ls $dist/plotly*`; do
basename=${path##*/}
name=${basename%%.*}
ext="${basename#*.}"

if [ $name == 'plotly-geo-assets' ] || [ $name == 'plotly-with-meta' ]; then
continue
fi

cp $path "$sync/${name}-${version}.$ext"
cp $path "$sync/${name}-${tag}.$ext"
done

# copy topojson files over to the sync folder
cp $dist/topojson/* $sync

# list folder and files
echo $sync
ls $sync

# sync to s3
aws s3 sync $sync/ s3://plotly-cdn/ --acl public-read