Skip to content

Commit 24ee42c

Browse files
committed
scripts/make_release.sh: Make it shorter
Also: - add bash "exception handling". - fix a {{CHANGELOG}} tag that was left behind after applying the template. - allow running the script from the master branch after the version bump is already merged.
1 parent 7186913 commit 24ee42c

File tree

1 file changed

+25
-33
lines changed

1 file changed

+25
-33
lines changed

scripts/make_release.sh

Lines changed: 25 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
#! /usr/bin/env nix-shell
2-
#! nix-shell -i bash -p nix coreutils gnugrep
2+
#! nix-shell -i bash -p nix coreutils gnugrep gnused
3+
4+
set -euo pipefail
35

46
# A handy utility for filling in the github RELEASE_TEMPLATE.
57
# Since we are using nix, this script shoud work whether on linux or mac.
68
#
7-
# NOTE: This script will target the LATEST wiki version. Make sure the wiki hasn't changed undesirably since
8-
# the release tag.
9+
# NOTE: This script will target the LATEST wiki version. Make sure the
10+
# wiki hasn't changed undesirably since the release tag.
911
#
1012
# Usage:
1113
# cd cardano-wallet # (only works from here!)
1214
# export GITHUB_API_TOKEN="..."
1315
# ./scripts/make_release.sh
1416
#
1517

16-
###############################################################
18+
################################################################################
1719
# Release-specific parameters (Change when you bump the version)
1820
GIT_TAG="v2020-04-28"
1921
CABAL_VERSION="2020.4.28"
@@ -23,51 +25,41 @@ OLD_CABAL_VERSION="2020.4.7"
2325

2426
JORM_TAG="v0.8.15"
2527
CARDANO_NODE_TAG="1.9.3"
26-
###############################################################
27-
TMP_CWD=$(pwd)
28+
################################################################################
2829
OLD_DATE="${OLD_GIT_TAG//v}"
2930
CHANGELOG=GENERATED_CHANGELOG.md
3031
OUT=GENERATED_RELEASE_NOTES-$GIT_TAG.md
3132
REPO="input-output-hk/cardano-wallet"
32-
TMP_WIKI_DIR=/tmp/cardano-wallet-script
33-
rm -rf $TMP_WIKI_DIR
34-
mkdir $TMP_WIKI_DIR
35-
echo $TMP_WIKI_DIR
36-
cd $TMP_WIKI_DIR
37-
git clone https://github.com/$REPO.wiki.git
38-
cd cardano-wallet.wiki
39-
40-
WIKI_COMMIT=$(git log -n 1 --pretty=format:%H)
41-
42-
cd $TMP_CWD
43-
echo "cd $TMP_CWD"
33+
WIKI_COMMIT=$(git ls-remote https://github.com/$REPO.wiki.git HEAD | cut -f1)
4434

4535
echo ""
4636
echo "Replacing $OLD_CABAL_VERSION with $CABAL_VERSION"
47-
find nix -name "*.nix" -type f | xargs sed -i "s/$OLD_CABAL_VERSION/$CABAL_VERSION/"
48-
find lib -name "*.cabal" -type f | xargs sed -i "s/$OLD_CABAL_VERSION/$CABAL_VERSION/"
37+
sed -i "s/$OLD_CABAL_VERSION/$CABAL_VERSION/" \
38+
$(git ls-files '*.nix'; git ls-files '*.cabal')
4939
echo "Looking for remaining references to old version:"
50-
echo "$(git grep $OLD_CABAL_VERSION)"
40+
git grep $OLD_CABAL_VERSION
5141
echo ""
5242

5343
echo "Generating changelog..."
5444
./scripts/make_changelog $OLD_DATE > $CHANGELOG
5545
echo ""
5646
echo "Filling in template..."
57-
sed -e "
58-
s/{{GIT_TAG}}/$GIT_TAG/g
59-
s/{{JORM_TAG}}/$JORM_TAG/g
60-
s/{{CARDANO_NODE_TAG}}/$CARDANO_NODE_TAG/g
61-
s/{{CABAL_VERSION}}/$CABAL_VERSION/g
62-
s/{{DOCKER_WIKI_COMMIT}}/$WIKI_COMMIT/g
63-
s/{{JORM_CLI_WIKI_COMMIT}}/$WIKI_COMMIT/g
64-
s/{{BYRON_CLI_WIKI_COMMIT}}/$WIKI_COMMIT/g
65-
" .github/RELEASE_TEMPLATE.md | sed -e "/{{CHANGELOG}}/r $CHANGELOG" > $OUT
47+
sed -e "s/{{GIT_TAG}}/$GIT_TAG/g" \
48+
-e "s/{{JORM_TAG}}/$JORM_TAG/g" \
49+
-e "s/{{CARDANO_NODE_TAG}}/$CARDANO_NODE_TAG/g" \
50+
-e "s/{{CABAL_VERSION}}/$CABAL_VERSION/g" \
51+
-e "s/{{DOCKER_WIKI_COMMIT}}/$WIKI_COMMIT/g" \
52+
-e "s/{{JORM_CLI_WIKI_COMMIT}}/$WIKI_COMMIT/g" \
53+
-e "s/{{BYRON_CLI_WIKI_COMMIT}}/$WIKI_COMMIT/g" \
54+
-e "/{{CHANGELOG}}/r $CHANGELOG" \
55+
-e "/{{CHANGELOG}}/d" \
56+
.github/RELEASE_TEMPLATE.md > $OUT
6657

67-
read -p "Do you want to create a commit and release-tag? (y/n)" -n 1 -r
68-
echo # (optional) move to a new line
58+
read -p "Do you want to create a commit and release-tag? (y/n) " -n 1 -r
59+
echo
6960
if [[ $REPLY =~ ^[Yy]$ ]]
7061
then
71-
git commit -am "Bump version from $OLD_CABAL_VERSION to $CABAL_VERSION"
62+
msg="Bump version from $OLD_CABAL_VERSION to $CABAL_VERSION"
63+
git diff --quiet || git commit -am "$msg"
7264
git tag -s -m $GIT_TAG $GIT_TAG
7365
fi

0 commit comments

Comments
 (0)