-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathuploadsourcemaps.sh
executable file
·67 lines (58 loc) · 1.9 KB
/
uploadsourcemaps.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
#!/bin/bash
ENDPOINT="https://api.rollbar.com/api/1/sourcemap"
VERSION=$(git rev-parse HEAD)
URL_PREFIX="//www.liftosaur.com"
DIST_DIR="./dist"
MAX_CONCURRENT_UPLOADS=3
MAX_RETRIES=3
CURL_TIMEOUT=20
function limit_jobs() {
while [ "$(jobs -r | wc -l)" -ge "$MAX_CONCURRENT_UPLOADS" ]; do
sleep 1
done
}
if [ -z "$VERSION" ]; then
echo "Error: Git commit hash not found. Are you in a Git repository?"
exit 1
fi
if [ -z "$ROLLBAR_POST_SERVER_ITEM" ]; then
echo "Error: Rollbar Post Server Item token is not found."
exit 1
fi
for jsfile in $DIST_DIR/*.js; do
mapfile="${jsfile}.map"
if [[ -f "$mapfile" ]]; then
jsfilename=$(basename $jsfile)
echo ""
echo "Uploading $jsfilename source map, version $VERSION"
(
for ((i=1; i<=MAX_RETRIES; i++)); do
echo "Uploading for https://"
curl -m $CURL_TIMEOUT $ENDPOINT \
-F access_token=$ROLLBAR_POST_SERVER_ITEM \
-F version=$VERSION \
-F minified_url="$URL_PREFIX/$jsfilename" \
-F source_map=@$mapfile
if [ $? -eq 0 ]; then
echo "\\nUploading for liftosaur://"
curl -m $CURL_TIMEOUT $ENDPOINT \
-F access_token=$ROLLBAR_POST_SERVER_ITEM \
-F version=$VERSION \
-F minified_url="liftosaur:$URL_PREFIX/$jsfilename" \
-F source_map=@$mapfile
if [ $? -eq 0 ]; then
break
else
echo "Retry $i for $jsfilename..."
sleep 2
fi
else
echo "Retry $i for $jsfilename..."
sleep 2
fi
done
) &
limit_jobs
fi
done
wait