Skip to content

Commit

Permalink
chore(flame_behaviors): 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
alestiago committed Aug 27, 2024
1 parent 7f0c1b9 commit 2648c50
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 4 deletions.
5 changes: 1 addition & 4 deletions packages/flame_behaviors/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# 1.2.0
# [1.2.0](https://github.com/VeryGoodOpenSource/flame_behaviors/compare/flame_behaviors-v1.1.0...flame_behaviors-v1.2.0) (2024-08-27)

- chore(deps): bump very_good_analysis from 4.0.0+1 to 5.1.0 in /packages/flame_behaviors/example ([#54](https://github.com/VeryGoodOpenSource/flame_behaviors/pull/54))
- chore(deps): bump very_good_analysis from 5.1.0 to 6.0.0 in /packages/flame_behaviors/example ([#61](https://github.com/VeryGoodOpenSource/flame_behaviors/pull/61))
- chore(deps): bump very_good_analysis from 5.1.0 to 6.0.0 in /packages/flame_behaviors ([#62](https://github.com/VeryGoodOpenSource/flame_behaviors/pull/62))
- chore: tighten dependencies ([#64](https://github.com/VeryGoodOpenSource/flame_behaviors/pull/64))

# [1.1.0](https://github.com/VeryGoodOpenSource/flame_behaviors/compare/flame_behaviors-v1.0.0...flame_behaviors-v1.1.0) (2024-01-11)
Expand Down
84 changes: 84 additions & 0 deletions packages/flame_behaviors/tool/release_ready.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Ensures that the package or brick is ready for a release.
#
# Will update the version.dart file and update the CHANGELOG.md.
#
# Set it up for a new version:
# `./release_ready.sh <version>

# Check if current directory is usable for this script, if so we assume it is correctly set up.
if [ ! -f "pubspec.yaml" ]; then
echo "$(pwd) is not a valid Dart package."
exit 1
fi

currentBranch=$(git symbolic-ref --short -q HEAD)
if [[ ! $currentBranch == "main" ]]; then
echo "Releasing is only supported on the main branch."
exit 1
fi

# Get information
old_version=""
current_name=""
if [ -f "pubspec.yaml" ]; then
old_version=$(dart pub deps --json | pcregrep -o1 -i '"version": "(.*?)"' | head -1)
current_name=$(dart pub deps --json | pcregrep -o1 -i '"name": "(.*?)"' | head -1)
fi

if [ -z "$old_version" ] || [ -z "$current_name" ]; then
echo "Current version or name was not resolved."
exit 1
fi

# Get new version
new_version="$1";

if [[ "$new_version" == "" ]]; then
echo "No new version supplied, please provide one"
exit 1
fi

if [[ "$new_version" == "$old_version" ]]; then
echo "Current version is $old_version, can't update."
exit 1
fi

# Retrieving all the commits in the current directory since the last tag.
previousTag="${current_name}-v${old_version}"
raw_commits="$(git log --pretty=format:"%s" --no-merges --reverse $previousTag..HEAD -- .)"
markdown_commits=$(echo "$raw_commits" | sed -En "s/\(#([0-9]+)\)/([#\1](https:\/\/github.com\/VeryGoodOpenSource\/flame_behaviors\/pull\/\1))/p")

if [[ "$markdown_commits" == "" ]]; then
echo "No commits since last tag, can't update."
exit 0
fi
commits=$(echo "$markdown_commits" | sed -En "s/^/- /p")

echo "Updating version to $new_version"
if [ -f "pubspec.yaml" ]; then
sed -i '' "s/version: $old_version/version: $new_version/g" pubspec.yaml
fi

# Update dart file with new version.
dart run build_runner build --delete-conflicting-outputs > /dev/null

if grep -q $new_version "CHANGELOG.md"; then
echo "CHANGELOG already contains version $new_version."
exit 1
fi

# Add a new version entry with the found commits to the CHANGELOG.md.
echo "# ${new_version}\n\n${commits}\n\n$(cat CHANGELOG.md)" > CHANGELOG.md
echo "CHANGELOG for $current_name generated, validate entries here: $(pwd)/CHANGELOG.md"

echo "Creating git branch for $current_name@$new_version"
git checkout -b "chore($current_name)/$new_version" > /dev/null

git add pubspec.yaml CHANGELOG.md
if [ -f lib/version.dart ]; then
git add lib/version.dart
fi

echo ""
echo "Run the following command if you wish to commit the changes:"
echo "git commit -m \"chore($current_name): $new_version\""

0 comments on commit 2648c50

Please sign in to comment.