-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublish.sh
More file actions
executable file
·55 lines (40 loc) · 1.19 KB
/
publish.sh
File metadata and controls
executable file
·55 lines (40 loc) · 1.19 KB
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
#! /bin/bash
set -e
if [ "$#" -lt 2 ]; then
echo "Please specify TARGET and VERSION"
exit 1
fi
TARGET="$1"
VERSION="$2"
[ "$TARGET" == "stage" ] || [ "$TARGET" == "production" ] || {
echo "TARGET must be stage or production, got $TARGET"
exit 1
}
[[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]] || {
echo "VERSION must be a semantic version number x.y.z, got $VERSION"
exit 1
}
PUBLISH_DIR=publish/$TARGET/$VERSION
ARTIFACT_FILE_NAME="artifacts/$TARGET v$VERSION.zip"
# Abort if the zip file already exists
if [ -f "$ARTIFACT_FILE_NAME" ]; then
echo "$ARTIFACT_FILE_NAME already exists, aborting"
exit 1
fi
# Build the project pointing to https://roar.morehumaninternet.org
ENV=$TARGET npm run build
# Clear and remake the publish directory
rm -rf $PUBLISH_DIR && mkdir -p $PUBLISH_DIR
# Copy over the following resources
for resource in bundled html img; do
cp -R $resource ./$PUBLISH_DIR
done
if [[ $TARGET == "production" ]]; then
NAME="Roar"
else
NAME="Roar Stage"
fi
cat manifest.json | sed "s/1.0.0/$VERSION/" | sed "s/Roar Local/$NAME/" > ./$PUBLISH_DIR/manifest.json
ROOT=$(pwd)
mkdir -p artifacts
cd $PUBLISH_DIR && zip -r -FS "$ROOT/$ARTIFACT_FILE_NAME" * && cd $ROOT