-
Notifications
You must be signed in to change notification settings - Fork 36
/
release.sh
executable file
·65 lines (54 loc) · 2 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
#!/bin/bash
echo "Creating a new release"
npm ci
migration_version=$(cat package.json | jq -r '.devDependencies."@daostack/migration"')
docker_compose_migration_version=$(cat docker-compose.yml | grep daostack/migration | cut -d ":" -f 3 | sed "s/'//")
package_version=$(cat package.json | jq -r '.version')
image_version=ganache-$migration_version-$package_version
if [[ $docker_compose_migration_version != $migration_version ]]; then
echo "The migration version in the docker-compose file is not the same as the one in package.json ($docker_compose_migration_version != $migration_version)"
exit
fi
echo "(Re)bulding docker containers..."
docker-compose down -v
docker-compose build
docker-compose up -d
# wait a bit for graph-node to come (it will redirect with a 302)
echo "waiting for subgraph to start"
while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' 127.0.0.1:8000)" != "200" ]]; do sleep 5; done
if [ -f .env ]; then
echo "moving .env to make sure we have default settings"
mv .env .env_backup
fi
echo "deploying subgraph"
npm run deploy
if [ -f .env_backup ]; then
echo "restoring .env file"
mv .env_backup .env
fi
# commit the postgres image
container_id=$(docker ps -f "name=postgres" -l -q)
image_name=daostack/subgraph-postgres
echo "docker commit $container_id $image_name:$image_version"
docker commit $container_id $image_name:$image_version
echo "docker push $image_name:$image_version"
docker push $image_name:$image_version
# commit the ipfs image
container_id=$(docker ps -f "name=ipfs" -l -q)
image_name=daostack/subgraph-ipfs
echo "docker commit $container_id $image_name:$image_version"
docker commit $container_id $image_name:$image_version
echo "docker push $image_name:$image_version"
docker push $image_name:$image_version
docker-compose down -v
# publish npm
echo "Publishing to npm..."
npm install
npm login
npm publish
# tag on github
echo "create tag ${image_version}"
git tag -a $image_version -m "Release of version $image_name:$image_version"
git push --tags
# done
echo "Done!"