Skip to content

Commit 5c38cd6

Browse files
committed
feat: improve substream release script
Improvements include: - exit the script if any non-recoverable step fails - fix bug where cargo version was hardcoded to be detected in balancer package - allow optional input of substream config file. This is necessary for protocols with forks as they will have multiple configs in one directory
1 parent 3c3b519 commit 5c38cd6

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

.github/workflows/substream.cd.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ on:
99
package:
1010
required: true
1111
description: "Package to build"
12+
config_file:
13+
required: false
14+
description: "Path to the substreams configuration file"
15+
default: "substreams.yaml"
1216

1317
jobs:
1418
Release:
@@ -42,4 +46,4 @@ jobs:
4246
- name: Run checks
4347
run: |
4448
cd substreams
45-
./release.sh ${{ inputs.package }}
49+
./release.sh ${{ inputs.package }} ${{ inputs.config_file }}

substreams/release.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ if [ -n "$current_tag" ]; then
1616
# Semantic version
1717
version="${BASH_REMATCH[2]}"
1818

19-
cargo_version=$(cargo pkgid -p ethereum-balancer | cut -d# -f2 | cut -d: -f2)
19+
cargo_version=$(cargo pkgid -p "$package" | cut -d# -f2 | cut -d: -f2)
2020
if [[ "$cargo_version" != "$version" ]]; then
2121
echo "Error: Cargo version: ${cargo_version} does not match tag version: ${version}!"
2222
exit 1
@@ -52,9 +52,18 @@ fi
5252
REPOSITORY=${REPOSITORY:-"s3://repo.propellerheads/substreams"}
5353
repository_path="$REPOSITORY/$package/$package-$version.spkg"
5454

55+
# Optional input for yaml file; defaults to substreams.yaml if not provided
56+
yaml_file=${2:-"substreams.yaml"}
57+
58+
if [[ ! -f "$package/$yaml_file" ]]; then
59+
echo "Error: manifest reader: unable to stat input file $yaml_file: file does not exist."
60+
exit 1
61+
fi
62+
63+
set -e # Exit the script if any command fails
5564
cargo build --target wasm32-unknown-unknown --release -p "$package"
5665
mkdir -p ./target/spkg/
57-
substreams pack $package/substreams.yaml -o ./target/spkg/$package-$version.spkg
66+
substreams pack "$package/$yaml_file" -o ./target/spkg/$package-$version.spkg
5867
aws s3 cp ./target/spkg/$package-$version.spkg $repository_path
5968

60-
echo "Released substreams package: '$repository_path'"
69+
echo "Released substreams package: '$repository_path'"

0 commit comments

Comments
 (0)