-
Notifications
You must be signed in to change notification settings - Fork 4
/
release.sh
executable file
·104 lines (87 loc) · 2.26 KB
/
release.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
100
101
102
103
104
#!/usr/bin/env bash
set -e
# config
valid_chains=($(ls config | sed 's/\.json//g'))
valid_providers=("goldsky" "0xgraph")
function exit_help {
echo "Usage: $0 <version> <chain> <provider> <deploy_key>"
echo " Example: $0 0.1.4 polygon goldsky ABCDEA123"
echo " chains: " ${valid_chains[@]}
echo " providers: " ${valid_providers[@]}
exit 1
}
function publish_0xgraph {
CHAIN=$1
SUBGRAPH=$2
VERSION=$3
DEPLOY_KEY=$4
echo "preparing $CHAIN"
yarn configure $CHAIN
yarn codegen
yarn build
echo "publishing $SUBGRAPH to 0xgraph"
yarn run graph deploy $SUBGRAPH --node https://api.0xgraph.xyz/deploy --ipfs https://api.0xgraph.xyz/ipfs --version-label="v$VERSION" --deploy-key=$DEPLOY_KEY
}
function publish_goldsky {
CHAIN=$1
SUBGRAPH=$2
VERSION=$3
DEPLOY_KEY=$4
echo "preparing $CHAIN"
yarn configure $CHAIN
yarn codegen
yarn build
echo "publishing $SUBGRAPH to goldsky"
goldsky subgraph deploy $SUBGRAPH/$VERSION --path . --token $DEPLOY_KEY
sleep 5 # wait for the subgraph to propagate
goldsky subgraph tag create $SUBGRAPH/$VERSION --token $DEPLOY_KEY --tag next
}
function publish {
VERSION=$1
CHAIN=$2
PROVIDER=$3
DEPLOY_KEY=$4
SUBGRAPH=
case $PROVIDER in
"0xgraph")
publish_0xgraph $CHAIN beefyfinance/clm-$CHAIN $VERSION $DEPLOY_KEY
;;
"goldsky")
publish_goldsky $CHAIN beefy-clm-$CHAIN $VERSION $DEPLOY_KEY
;;
esac
}
version=$1
if [ -z "$version" ]; then
echo "version is required"
exit_help
fi
# allow only x.y.z and x.y.z-n versions
if [[ ! $version =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9]+)?$ ]]; then
echo "invalid version ""$version"""
exit_help
fi
chain=$2
if [ -z "$chain" ]; then
echo "chain is required"
exit_help
fi
if [[ ! " ${valid_chains[@]} " =~ " ${chain} " ]]; then
echo "invalid chain"
exit_help
fi
provider=$3
if [ -z "$provider" ]; then
echo "provider is required"
exit_help
fi
if [[ ! " ${valid_providers[@]} " =~ " ${provider} " ]]; then
echo "invalid provider $provider"
exit_help
fi
deploy_key=$4
if [ -z "$deploy_key" ]; then
echo "deploy key is required"
exit_help
fi
publish $version $chain $provider $deploy_key