Skip to content

Commit

Permalink
Add a prepare_release.sh script that automates some manual steps. (#524)
Browse files Browse the repository at this point in the history
  • Loading branch information
pradh authored May 13, 2021
1 parent 6aba884 commit 2ff216c
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 2 deletions.
10 changes: 8 additions & 2 deletions docs/developer_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ found [here](../deploy/README.md).
Local development uses [Skaffold](https://skaffold.dev) to manage the build, deploy and
port forwarding.

## Prerequisit
## Prerequisite

- Contact DataCommons team to get data access to Cloud Bigtable and BigQuery.

Expand Down Expand Up @@ -79,11 +79,17 @@ brought up here, can not test the REST API.

### Generate Go proto files

Run the following code to generate Go proto files.
Install the following packages as a one-time action.

```bash
cd ~/ # Be sure there is no go.mod in the local directory
go get google.golang.org/protobuf/cmd/protoc-gen-go@v1.23.0
go get google.golang.org/grpc/cmd/protoc-gen-go-grpc@v0.0.0-20200824180931-410880dd7d91
```

Run the following command to generate Go proto files.

```bash
protoc \
--proto_path=proto \
--go_out=internal \
Expand Down
59 changes: 59 additions & 0 deletions scripts/prepare_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash
#
# A helper script to update the storage versions and prepare a commit for
# release.
#

DIR=$(dirname "$0")

cd "$DIR"/..
VERSION=

function update_version() {
echo ""
echo "==== Updating BT and BQ versions ===="

BT=$(curl https://autopush.datacommons.org/version 2>/dev/null | awk '{ if ($1~/^borgcron_/) print $1; }')
printf "$BT" > deploy/storage/bigtable.version

BQ=$(curl https://autopush.datacommons.org/version 2>/dev/null | awk '{ if ($1~/^datcom-store/) print $1; }')
printf "$BQ" > deploy/storage/bigquery.version

VERSION="${BT//borgcron_/}"
}

function update_proto() {
echo ""
echo "==== Updating go proto files ===="
protoc --proto_path=proto --go_out=internal --go-grpc_out=internal \
--go-grpc_opt=requireUnimplementedServers=false proto/*.proto
if [ $? -ne 0 ]; then
echo "ERROR: Failed to update proto"
exit 1
fi
}

function update_golden() {
echo ""
echo "==== Updating staging golden files ===="
./scripts/update_golden_staging.sh
if [ $? -ne 0 ]; then
echo "ERROR: Failed to update proto"
exit 1
fi
}

function commit() {
echo ""
echo "==== Committing the change ===="
git commit -a -m "Data Release: $VERSION"
}

update_version
update_proto
update_golden
commit

echo ""
echo "NOTE: Please review the commit, push to your remote repo and create a PR."
echo ""

0 comments on commit 2ff216c

Please sign in to comment.