Skip to content

Commit 3ab53d9

Browse files
authored
chore: add release script to generate changelogs (#145)
* chore: add release script * must be main * spell
1 parent b7d3a7d commit 3ab53d9

File tree

2 files changed

+85
-2
lines changed

2 files changed

+85
-2
lines changed

.github/cspell.json

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"version": "0.2",
33
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
4-
"dictionaries": ["vgv_allowed", "vgv_forbidden"],
4+
"dictionaries": ["vgv_allowed",
5+
"vgv_forbidden"],
56
"dictionaryDefinitions": [
67
{
78
"name": "vgv_allowed",
@@ -15,5 +16,23 @@
1516
}
1617
],
1718
"useGitignore": true,
18-
"words": ["endtemplate", "APPDATA", "brickhub", "noopener", "typecheck", "clsx", "Infima", "Csvg", "clsx", "xlink", "linecap", "Contador", "localizable", "mostrado", "página", "Texto"]
19+
"words": [
20+
"endtemplate",
21+
"APPDATA",
22+
"brickhub",
23+
"noopener",
24+
"typecheck",
25+
"clsx",
26+
"Infima",
27+
"Csvg",
28+
"clsx",
29+
"xlink",
30+
"linecap",
31+
"Contador",
32+
"localizable",
33+
"mostrado",
34+
"página",
35+
"Texto",
36+
"creatordate"
37+
]
1938
}

tool/release_ready.sh

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/bash
2+
3+
# Ensures that the package is ready for a release.
4+
#
5+
# Will update the version.dart file and update the CHANGELOG.md.
6+
#
7+
# Set it up for a new version:
8+
# `./release_ready.sh <version>
9+
10+
currentBranch=$(git symbolic-ref --short -q HEAD)
11+
if [[ ! $currentBranch == "main" ]]; then
12+
echo "Releasing is only supported on the main branch."
13+
exit 1
14+
fi
15+
16+
# Get information
17+
old_version=$(git for-each-ref --count=2 --format "%(refname:short)" --sort=-creatordate refs/tags | tail -n +2 | cut -c 2-)
18+
19+
if [ -z "$old_version" ]; then
20+
echo "Current version was not resolved."
21+
exit 1
22+
fi
23+
24+
# Get new version
25+
new_version="$1";
26+
27+
if [[ "$new_version" == "" ]]; then
28+
echo "No new version supplied, please provide one"
29+
exit 1
30+
fi
31+
32+
if [[ "$new_version" == "$old_version" ]]; then
33+
echo "Current version is $old_version, can't update."
34+
exit 1
35+
fi
36+
37+
# Retrieving all the commits in the current directory since the last tag.
38+
previousTag="v${old_version}"
39+
raw_commits="$(git log --pretty=format:"%s" --no-merges --reverse $previousTag..HEAD -- .)"
40+
markdown_commits=$(echo "$raw_commits" | sed -En "s/\(#([0-9]+)\)/([#\1](https:\/\/github.com\/VeryGoodOpenSource\/very_good_workflows\/pull\/\1))/p")
41+
42+
if [[ "$markdown_commits" == "" ]]; then
43+
echo "No commits since last tag, can't update."
44+
exit 0
45+
fi
46+
commits=$(echo "$markdown_commits" | sed -En "s/^/- /p")
47+
48+
if grep -q v$new_version "CHANGELOG.md"; then
49+
echo "CHANGELOG already contains version $new_version."
50+
exit 1
51+
fi
52+
53+
# Add a new version entry with the found commits to the CHANGELOG.md.
54+
echo "# ${new_version} \n\n ${commits}\n\n$(cat CHANGELOG.md)" > CHANGELOG.md
55+
echo "CHANGELOG generated, validate entries here: $(pwd)/CHANGELOG.md"
56+
57+
echo "Creating git branch for ver_good_cli@$new_version"
58+
git checkout -b "chore/$new_version" > /dev/null
59+
60+
git add pubspec.yaml CHANGELOG.md
61+
62+
echo ""
63+
echo "Run the following command if you wish to commit the changes:"
64+
echo "git commit -m \"chore: v$new_version\""

0 commit comments

Comments
 (0)