Skip to content

Commit 20502c0

Browse files
committed
Fix create release script
1 parent 7f0eb9c commit 20502c0

File tree

1 file changed

+27
-17
lines changed

1 file changed

+27
-17
lines changed

create_release.sh

+27-17
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,29 @@
88
# 3. The CHANGELOG.md file
99
# 4. The tag
1010

11+
function get_changes() {
12+
local currentTag previousTag
13+
previousTag=$(git describe --abbrev=0 --tags "$(git describe --abbrev=0)"^)
14+
currentTag=$(git describe --abbrev=0)
15+
changes=$(git log --pretty=oneline --pretty=format:'[`%h`](https://github.com/cbrnrd/maliketh/commit/%h) - %s' --abbrev-commit "$previousTag...$currentTag" | grep -v "Upgrade")
16+
cat << EOF
17+
## $currentTag
18+
19+
$changes
20+
21+
View diff [\`$previousTag...$currentTag\`](https://github.com/cbrnrd/maliketh/compare/$previousTag...$currentTag)
22+
23+
EOF
24+
}
25+
1126
function get_changelog() {
12-
local currentTag previousTag prevChangelogContents
13-
currentTag=$(git describe --abbrev=0 --tags "$(git describe --abbrev=0)"^)
14-
previousTag=$(git describe --abbrev=0)
27+
local prevChangelogContents
1528
prevChangelogContents=$(cat ./CHANGELOG.md)
1629

17-
{
18-
echo "## $currentTag";
19-
echo "";
20-
git log --pretty=oneline --pretty=format:'`%h` - %s' --abbrev-commit "$currentTag...$previousTag" | grep -v "Upgrade";
21-
echo "";
22-
} > CHANGELOG.md
30+
get_changes > CHANGELOG.md
2331
echo "$prevChangelogContents" >> CHANGELOG.md
2432
}
2533

26-
2734
# Print usage if -h or no args
2835
if [[ $1 == "-h" || $# -eq 0 ]]; then
2936
echo "Usage: ./create_release.sh <new_version>"
@@ -51,17 +58,12 @@ cd server && poetry version $NEW_VERSION && cd ..
5158
# Update the version number in client/pyproject.toml
5259
cd client && poetry version $NEW_VERSION && cd ..
5360

54-
# Commit the changes
5561
git add server/pyproject.toml client/pyproject.toml
5662
git commit -m "Bump version to v$NEW_VERSION"
5763

5864
# Create a new tag
5965
git tag -a v$NEW_VERSION
6066

61-
# Push the changes
62-
git push
63-
git push origin v$NEW_VERSION
64-
6567
# Prompt for changelog autogeneration
6668
read -p "Would you like to autogenerate the changelog? (y/n) " AUTOGEN
6769

@@ -75,13 +77,21 @@ else
7577
echo "$prevChangelogContents" >> CHANGELOG.md
7678
fi
7779

80+
# Commit the changes
81+
git add CHANGELOG.md
82+
git commit -m "Update changelog for v$NEW_VERSION"
83+
84+
# Push the changes
85+
git push
86+
git push origin v$NEW_VERSION
87+
7888
read -p "Would you like to add a custom release title? (y/n) " CUSTOM_TITLE
7989

8090
if [[ $CUSTOM_TITLE == "y" ]]; then
8191
read -p "Enter the release title: " TITLE
82-
gh release create v$NEW_VERSION --notes-from-tag --title "$TITLE"
92+
get_changes | gh release create v$NEW_VERSION -F - --title "$TITLE"
8393
else
84-
gh release create v$NEW_VERSION --notes-from-tag
94+
get_changes | gh release create v$NEW_VERSION -F -
8595
fi
8696

8797
echo "Done!"

0 commit comments

Comments
 (0)