-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathpublish-dev.sh
executable file
·99 lines (87 loc) · 3.74 KB
/
publish-dev.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env bash
set -e
bucketname=dev-sdk-build-artifacts
rootDir=`pwd`
filename=$1-$(date +%Y%m%d-%H%M%S).tar.gz
packageDir=packages/$1
# REQUIREMENTS:
# - `brew install jq`
# - Setup your aws veritone profile. Add the file `USER/.aws/config` with the following contents:
# [profile veritone]
# region=us-east-1
# output=text
# veritone-widgets is a special case
# veritone-react/redux-common packages need to be built, uploaded, and
# linked into veritone-widgets, which will then be built itself and uploaded.
if [ "$1" = "all" ]; then
vReduxDir=packages/veritone-redux-common
vReactDir=packages/veritone-react-common
vWidgetsDir=packages/veritone-widgets
vReduxName=veritone-redux-common-$(date +%Y%m%d-%H%M%S).tar.gz
vReactName=veritone-react-common-$(date +%Y%m%d-%H%M%S).tar.gz
vWidgetsName=veritone-widgets-$(date +%Y%m%d-%H%M%S).tar.gz
# Redux
yarn workspace veritone-redux-common run build
mkdir -p $vReduxDir/publish-dev-dist/dist
cp -r $vReduxDir/dist/* $vReduxDir/publish-dev-dist/dist
cp $vReduxDir/package.json $vReduxDir/publish-dev-dist/package.json
cd $vReduxDir/publish-dev-dist
tar czf $rootDir/$vReduxName ./*
cd ..
rm -rf ./publish-dev-dist
cd $rootDir
aws s3api put-object --bucket $bucketname --key $vReduxName --body $vReduxName --profile veritone
rm $vReduxName
vReduxS3=https://${bucketname}.s3.amazonaws.com/${vReduxName}
echo "Created veritone-redux-common package at ${vReduxS3}"
# React
yarn workspace veritone-react-common run build
mkdir -p $vReactDir/publish-dev-dist/dist
cp -r $vReactDir/dist/* $vReactDir/publish-dev-dist/dist
cp $vReactDir/package.json $vReactDir/publish-dev-dist/package.json
cd $vReactDir/publish-dev-dist
tar czf $rootDir/$vReactName ./*
cd ..
rm -rf ./publish-dev-dist
cd $rootDir
aws s3api put-object --bucket $bucketname --key $vReactName --body $vReactName --profile veritone
rm $vReactName
vReactS3=https://${bucketname}.s3.amazonaws.com/${vReactName}
echo "Created veritone-react-common package at ${vReactS3}"
# Widgets
yarn workspace veritone-widgets run build
mkdir -p $vWidgetsDir/publish-dev-dist/dist
cp -r $vWidgetsDir/dist/* $vWidgetsDir/publish-dev-dist/dist
cp $vWidgetsDir/package.json $vWidgetsDir/publish-dev-dist/package.json
cd $vWidgetsDir/publish-dev-dist
# Link React/Redux to the current build of Widgets
jq '.dependencies["veritone-react-common"] = "'$vReactS3'"' package.json > tmp.$$.json && mv tmp.$$.json test.json
jq '.dependencies["veritone-redux-common"] = "'$vReduxS3'"' test.json > tmp.$$.json && mv tmp.$$.json package.json
tar czf $rootDir/$vWidgetsName ./*
cd ..
rm -rf ./publish-dev-dist
cd $rootDir
aws s3api put-object --bucket $bucketname --key $vWidgetsName --body $vWidgetsName --profile veritone
rm $vWidgetsName
vWidgetsS3=https://${bucketname}.s3.amazonaws.com/${vWidgetsName}
# Re-echo subpackages since we may need to reference them in some cases
echo "Created veritone-redux-common package at ${vReduxS3}"
echo "Created veritone-react-common package at ${vReactS3}"
echo "Created veritone-widgets package at ${vWidgetsS3}"
echo "Finished - This build of veritone-widgets contains all changes in veritone-react/redux-common"
# Bail out since we're done!
exit 1
fi
# All other cases
yarn workspace $1 run build
mkdir -p $packageDir/publish-dev-dist/dist
cp -r $packageDir/dist/* $packageDir/publish-dev-dist/dist
cp $packageDir/package.json $packageDir/publish-dev-dist/package.json
cd $packageDir/publish-dev-dist
tar czf $rootDir/$filename ./*
cd ..
rm -rf ./publish-dev-dist
cd $rootDir
aws s3api put-object --bucket $bucketname --key $filename --body $filename --profile veritone
rm $filename
echo "Artifact stored at https://${bucketname}.s3.amazonaws.com/${filename}"