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)
1820GIT_TAG=" v2020-04-28"
1921CABAL_VERSION=" 2020.4.28"
@@ -23,51 +25,41 @@ OLD_CABAL_VERSION="2020.4.7"
2325
2426JORM_TAG=" v0.8.15"
2527CARDANO_NODE_TAG=" 1.9.3"
26- # ##############################################################
27- TMP_CWD=$( pwd)
28+ # ###############################################################################
2829OLD_DATE=" ${OLD_GIT_TAG// v} "
2930CHANGELOG=GENERATED_CHANGELOG.md
3031OUT=GENERATED_RELEASE_NOTES-$GIT_TAG .md
3132REPO=" 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
4535echo " "
4636echo " 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 ' )
4939echo " Looking for remaining references to old version:"
50- echo " $( git grep $OLD_CABAL_VERSION ) "
40+ git grep $OLD_CABAL_VERSION
5141echo " "
5242
5343echo " Generating changelog..."
5444./scripts/make_changelog $OLD_DATE > $CHANGELOG
5545echo " "
5646echo " 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
6960if [[ $REPLY =~ ^[Yy]$ ]]
7061then
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
7365fi
0 commit comments