Skip to content

Commit 5a8f592

Browse files
Updates plrust/build to programmatically get pgrx version (#381)
Addresses: #377 When plrust goes through a release cycle, occasionally (read: pretty much "almost" every time) we forget to update the hard-coded pgrx version in the `plrust/build` script due to the fact that our automated release tooling does not consider nor modify the script file. With the changes in this PR, we programmatically get the pgrx version using `cargo tree` and some unix utils magic so that nobody has to think about updating that value ever again upon release.
1 parent 3725747 commit 5a8f592

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

plrust/build

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,18 @@ fi
5252
cargo update -p pgrx
5353
cargo fetch
5454
if [ "$CI" != true ]; then
55-
cargo install cargo-pgrx \
56-
--version "0.10.0" \
57-
--locked # use the Cargo.lock in the pgrx repo
55+
# Attempt to get pgrx version from cargo tree. Looking for a pattern such as "pgrx v0.10.0"
56+
PGRX_VERSION=$(cargo tree --depth 1 --package plrust | grep -E "\s*pgrx\s+v[0-9]+\.[0-9]+\.[0-9]+" | head -n 1 | cut -f2- -dv)
57+
58+
if [ -z "$PGRX_VERSION" ]; then
59+
echo "Could not determine pgrx version from 'cargo tree'!"
60+
exit 1
61+
else
62+
echo "Installing cargo-pgrx version $PGRX_VERSION"
63+
cargo install cargo-pgrx \
64+
--version "$PGRX_VERSION" \
65+
--locked # use the Cargo.lock in the pgrx repo
66+
fi
5867
fi
5968

6069
# Don't need to run cargo pgrx init: user might already have set it up,

0 commit comments

Comments
 (0)