Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update update-version.sh to match package names less greedily #6174

Merged
merged 4 commits into from
Jun 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions scripts/update-version.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
#!/usr/bin/env bash

usage () {
echo "$(basename $0) PACKAGE VERSION
echo "usage: $(basename $0) PACKAGE VERSION
Updates the version for PACKAGE to VERSION, and updates bounds
on that package in other cabal files."
}

if [ "$#" == "0" ]; then
if [[ $# != 2 ]]; then
echo "Wrong number of arguments"
usage
exit 1
fi
Expand All @@ -24,7 +25,7 @@ echo "Updating version of $PACKAGE to $VERSION"
# update package version in cabal file for package
sed -i "s/\(^version:\s*\).*/\1$VERSION/" "./$PACKAGE/$PACKAGE.cabal"

# update version bounds in all cabal files
# Update version bounds in all cabal files
# It looks for patterns like the following:
#
# - ", plutus-core"
Expand All @@ -33,6 +34,18 @@ sed -i "s/\(^version:\s*\).*/\1$VERSION/" "./$PACKAGE/$PACKAGE.cabal"
# - ", plutus-core:{plutus-core, plutus-core-testlib} ^>=1.0"
#
# and updates the version bounds to "^>={major version}"
#
# The ?* pattern prevents 'find' from attempting to modify ".cabal" (no basename).
#
# The pattern $PACKAGE[^-A-Za-z0-1][^^] matches exactly the package name followed by anything
# up to ^. We need [^-A-Za-z0-1] to prevent eg `plutus-tx` from matching `plutus-tx-plugin`.
#
# The second sed command is to match the case where the package name is at the end of the line:
# we need this because the first case requires at least one character after the package name.
#
# Note that this all requires a comma (maybe preceded by whitespace) at the start of the line:
# it won't work with commas at the end.

echo "Updating version bounds on $PACKAGE to '^>=$major_version'"
find . -name "?*.cabal" -exec sed -i "s/\(, $PACKAGE[^^]*\).*/\1 ^>=$major_version/" {} \;
find . -name "?*.cabal" -exec sed -i "s/\(^[ \t]*, $PACKAGE[^-A-Za-z0-1][^^]*\).*/\1^>=$major_version/" {} \; \
-exec sed -i "s/\(^[ \t]*, $PACKAGE$\)/\1 ^>=$major_version/" {} \;
Loading