-
Notifications
You must be signed in to change notification settings - Fork 463
/
Copy pathupload_bundle.sh
executable file
·51 lines (35 loc) · 1.69 KB
/
upload_bundle.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
#/usr/bin/sh
# This script will publish the compiler.js bundle / packages cmij.js files to our KeyCDN server.
# The target folder on KeyCDN will be the compiler.js' version number.
# This script requires `curl` / `openssl` to be installed.
SCRIPT_DIR=$(cd "$(dirname "$0")"; pwd -P)
# Get the actual version from the compiled playground bundle
VERSION=$(cd $SCRIPT_DIR; node -e 'require("./compiler.js"); console.log(rescript_compiler.make().rescript.version)')
if [ -z "${KEYCDN_USER}" ]; then
echo "KEYCDN_USER environment variable not set. Make sure to set the environment accordingly."
exit 1
fi
if [ -z "${KEYCDN_PASSWORD}" ]; then
echo "KEYCDN_PASSWORD environment variable not set. Make sure to set the environment accordingly."
exit 1
fi
KEYCDN_SRV="ftp.keycdn.com"
NETRC_FILE="${SCRIPT_DIR}/.netrc"
# To make sure to not leak any secrets in the bash history, we create a NETRC_FILE
# with the credentials provided via ENV variables.
if [ ! -f "${NETRC_FILE}" ]; then
echo "No .netrc file found. Creating file '${NETRC_FILE}'"
echo "machine ${KEYCDN_SRV} login $KEYCDN_USER password $KEYCDN_PASSWORD" > "${NETRC_FILE}"
fi
PACKAGES=( "compiler-builtins" "@rescript/react" "@rescript/core")
echo "Uploading compiler.js file..."
curl --ftp-create-dirs -T "${SCRIPT_DIR}/compiler.js" --ssl --netrc-file $NETRC_FILE ftp://${KEYCDN_SRV}/v${VERSION}/compiler.js
echo "---"
echo "Uploading packages cmij files..."
for dir in ${PACKAGES[@]};
do
SOURCE="${SCRIPT_DIR}/packages/${dir}"
TARGET="ftp://${KEYCDN_SRV}/v${VERSION}/${dir}"
echo "Uploading '$SOURCE/cmij.js' to '$TARGET/cmij.js'..."
curl --ftp-create-dirs -T "${SOURCE}/cmij.js" --ssl --netrc-file $NETRC_FILE "${TARGET}/cmij.js"
done