forked from anyproto/anytype-ts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·81 lines (65 loc) · 1.76 KB
/
update.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
#!/usr/bin/env bash
REPO="anyproto/anytype-heart"
FILE="addon.tar.gz"
GITHUB="api.github.com"
platform=${1:-ubuntu-latest};
arch=$2;
folder="build";
if [ "$platform" = "ubuntu-latest" ]; then
arch="linux-$arch";
folder="$arch";
elif [ "$platform" = "macos-latest" ]; then
arch="darwin-$arch";
folder="$arch";
elif [ "$platform" = "windows-latest" ]; then
arch="windows";
folder="dist";
FILE="addon.zip"
fi;
echo "Arch: $arch"
echo "Folder: $folder"
echo ""
if [ "$arch" = "" ]; then
echo "ERROR: arch not found"
exit 1
fi;
mwv=`cat middleware.version`
version=`curl -H "Accept: application/vnd.github.v3+json" -sL https://$GITHUB/repos/$REPO/releases/tags/v$mwv | jq .`
tag=`echo $version | jq ".tag_name"`
asset_id=`echo $version | jq ".assets | map(select(.name | match(\"js_v[0-9]+.[0-9]+.[0-9]+(-rc[0-9]+)?_$arch\";\"i\")))[0].id"`
if [ "$asset_id" = "" ]; then
echo "ERROR: version not found"
exit 1
fi;
printf "Version: $tag\n"
printf "Found asset: $asset_id\n"
echo -n "Downloading file..."
curl -sL -H 'Accept: application/octet-stream' "https://$GITHUB/repos/$REPO/releases/assets/$asset_id" > $FILE
printf "Done\n"
if [ "$platform" = "windows-latest" ]; then
echo -n "Uncompressing... "
unzip $FILE
printf "Done\n"
echo "Moving... "
mv -fv grpc-server.exe "$folder/anytypeHelper.exe"
else
echo -n "Uncompressing... "
tar -zxf $FILE
printf "Done\n"
echo "Moving... "
rm -rf "$folder"
mkdir -p "$folder"
mv -fv grpc-server "$folder/anytypeHelper"
fi;
rm -rf dist/lib/pb
rm -rf dist/lib/pkg
rm -rf dist/lib/protos
rm -rf dist/lib/json/generated/*.json
mv -fv protobuf/* "dist/lib/"
mkdir -p dist/lib/json/generated
mv -fv json/* "dist/lib/json/generated"
rm -rf protobuf
rm -rf relations
rm -rf json
rm -rf $FILE
printf "Done\n\n"