Skip to content

Commit 3e45e26

Browse files
authored
Check in CI if changelogs need a bump
1 parent df1ca30 commit 3e45e26

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

.github/workflows/haskell.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,3 +665,6 @@ jobs:
665665
666666
- name: Run linter
667667
run: scripts/format-changelogs.sh || git diff --exit-code
668+
669+
- name: Check if changelogs need a bump
670+
run: scripts/bump-changelogs.sh || (git diff; false)

scripts/bump-changelogs.sh

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
11
#!/usr/bin/env bash
22

3-
CHAP=./cardano-haskell-packages
4-
# Download a shallow copy of CHaP
5-
git clone --depth 1 git@github.com:IntersectMBO/cardano-haskell-packages.git $CHAP
6-
7-
cd $CHAP || exit
83
# Save all the available packages from CHaP
9-
CHAP_PACKAGES=$(./scripts/list-packages.sh)
10-
cd - || exit
11-
echo "The following packages are available in CHaP:"
4+
CHAP_PACKAGES=$(mktemp)
5+
trap 'rm -f "$CHAP_PACKAGES"' EXIT
6+
7+
if tar --version | grep -q 'GNU tar'
8+
then
9+
tar () { command tar --wildcards "$@"; }
10+
fi
11+
12+
curl -sSL https://chap.intersectmbo.org/01-index.tar.gz |
13+
tar -tz \*.cabal |
14+
cut -d/ -f1-2 |
15+
LANG=C sort -t/ -k1,1 -k2,2Vr |
16+
LANG=C sort -t/ -k1,1 -u -o "$CHAP_PACKAGES"
17+
echo "The complete CHaP package index is here:"
1218
echo "$CHAP_PACKAGES"
1319

1420
# Save the paths to every `cardano-ledger` cabal file
15-
CABAL_FILES=$(find . -wholename '*/eras/*.cabal' -o -wholename '*/libs/*.cabal')
21+
CABAL_FILES=$(git ls-files '*.cabal')
1622

1723
for i in $CABAL_FILES;
1824
do
@@ -29,7 +35,7 @@ do
2935
# Check if the package had a release with
3036
# the most recent `CHANGELOG` version number
3137
printf "Looking for %s with version %s in CHaP\n" "$PACKAGE" "$VERSION"
32-
RESULT=$(echo "$CHAP_PACKAGES" | grep -o "$PACKAGE $VERSION")
38+
RESULT=$(grep -o "$PACKAGE/$VERSION" "$CHAP_PACKAGES")
3339
if [[ -n "$RESULT" ]]; then
3440
# A release was found and thus the `CHANGELOG` has to be bumped
3541
# with the incremented patch version
@@ -40,7 +46,9 @@ do
4046
fi
4147
done
4248

43-
rm -rf $CHAP
44-
printf "\n!!!!!!\n%s %s\n!!!!!!\n" \
45-
"WARNING! DO NOT BUMP THE VERSION NUMBER IN THE CABAL FILES" \
46-
"(unless its dependencies were bumped)!"
49+
if ! git diff -s --exit-code; then
50+
printf "\n!!!!!!\n%s %s\n!!!!!!\n" \
51+
"WARNING! DO NOT BUMP THE VERSION NUMBER IN THE CABAL FILES" \
52+
"(unless their dependencies were bumped)!"
53+
exit 1
54+
fi

0 commit comments

Comments
 (0)