-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script to bump packages versions and dependencies [skip ci]
- Loading branch information
Showing
1 changed file
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/bin/bash | ||
|
||
shopt -s globstar | ||
|
||
############################################################################### | ||
# Functions | ||
############################################################################### | ||
|
||
# Find package version | ||
find_package_version() { | ||
grep -Po '^version:\s+\K\d+(?:\.\d+)+' < "$1" | ||
} | ||
|
||
VERSION_PATTERN="[0-9]+(\\.[0-9]+)+" | ||
|
||
# Bump package version from U.B.M to U.(B+1).0 | ||
bump_package_version() { | ||
# Find version | ||
version="$(find_package_version "$1")" | ||
unicode="$(echo "$version" | cut -f1 -d'.')" | ||
major="$(echo "$version" | cut -f2 -d'.')" | ||
# Bump version | ||
major=$((major + 1)) | ||
new_version="$unicode.$major.0" | ||
echo "Found: $(basename -s .cabal "$1")-$version; bump to: $new_version." | ||
sed -ri "s/^(version:\s+)$VERSION_PATTERN/\1$new_version/" "$1" | ||
} | ||
|
||
############################################################################### | ||
# Bump packages versions | ||
############################################################################### | ||
|
||
for cabal in **/*.cabal | ||
do | ||
bump_package_version "$cabal" | ||
done | ||
|
||
############################################################################### | ||
# Bump dependencies | ||
############################################################################### | ||
|
||
UNICODE_DATA="$(grep -Po '^version:\s+\K\d+(?:\.\d+)+' \ | ||
< unicode-data/unicode-data.cabal)" | ||
|
||
UNICODE="$(echo "$UNICODE_DATA" | cut -f1 -d'.')" | ||
UNICODE_DATA_MAJOR="$(echo "$UNICODE_DATA" | cut -f2 -d'.')" | ||
# UNICODE_DATA_MINOR="$(echo "$UNICODE_DATA" | cut -f3 -d'.')" | ||
|
||
UNICODE_DATA_MIN_BOUND="$UNICODE.$UNICODE_DATA_MAJOR" | ||
UNICODE_DATA_MAX_BOUND="$UNICODE.$((UNICODE_DATA_MAJOR+1))" | ||
|
||
REGEX="s/\ | ||
(unicode-data\\s+>= )$VERSION_PATTERN(\\s+&&\\s+< )$VERSION_PATTERN/\ | ||
\\1$UNICODE_DATA_MIN_BOUND\\3$UNICODE_DATA_MAX_BOUND/" | ||
|
||
for cabal in **/*.cabal | ||
do | ||
sed -ri "$REGEX" "$cabal" | ||
done |