From 9dcdae602edc4078966fc26f88a9a50570c51060 Mon Sep 17 00:00:00 2001 From: Alejandro Santiago Date: Wed, 4 Sep 2024 08:37:15 +0100 Subject: [PATCH] chore(flame_steering_behaviors): v0.2.0 (#68) --- .../flame_steering_behaviors_pub_publish.yaml | 10 ++- .../flame_steering_behaviors/CHANGELOG.md | 4 + .../flame_steering_behaviors/pubspec.yaml | 2 +- .../tool/release_ready.sh | 79 +++++++++++++++++++ 4 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 packages/flame_steering_behaviors/tool/release_ready.sh diff --git a/.github/workflows/flame_steering_behaviors_pub_publish.yaml b/.github/workflows/flame_steering_behaviors_pub_publish.yaml index d80dc94..0d6a6bd 100644 --- a/.github/workflows/flame_steering_behaviors_pub_publish.yaml +++ b/.github/workflows/flame_steering_behaviors_pub_publish.yaml @@ -18,7 +18,15 @@ jobs: uses: actions/checkout@v4 - name: 🐦 Setup Flutter uses: subosito/flutter-action@v2 + - name: 🪪 Get Id Token + uses: actions/github-script@v6 + with: + script: | + let pub_token = await core.getIDToken('https://pub.dev') + core.exportVariable('PUB_TOKEN', pub_token) + - name: 📢 Authenticate + run: flutter pub pub token add https://pub.dev --env-var PUB_TOKEN - name: 📦 Install Dependencies run: flutter pub get - name: 📢 Publish - run: dart pub publish --force \ No newline at end of file + run: flutter pub publish -f \ No newline at end of file diff --git a/packages/flame_steering_behaviors/CHANGELOG.md b/packages/flame_steering_behaviors/CHANGELOG.md index a6816b9..e2a4913 100644 --- a/packages/flame_steering_behaviors/CHANGELOG.md +++ b/packages/flame_steering_behaviors/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.2.0 + +- chore: tighten dependencies ([#64](https://github.com/VeryGoodOpenSource/flame_behaviors/pull/64, [#67](https://github.com/VeryGoodOpenSource/flame_behaviors/pull/67, [#71](https://github.com/VeryGoodOpenSource/flame_behaviors/pull/71) + # 0.1.0 (2023-12-21) - initial release diff --git a/packages/flame_steering_behaviors/pubspec.yaml b/packages/flame_steering_behaviors/pubspec.yaml index 29be42d..7b04b16 100644 --- a/packages/flame_steering_behaviors/pubspec.yaml +++ b/packages/flame_steering_behaviors/pubspec.yaml @@ -1,6 +1,6 @@ name: flame_steering_behaviors description: Flame Steering Behaviors brings steering algorithms to the behavior pattern, built by Very Good Ventures. -version: 0.1.0 +version: 0.2.0 homepage: https://github.com/VeryGoodOpenSource/flame_behaviors repository: https://github.com/VeryGoodOpenSource/flame_behaviors issue_tracker: https://github.com/VeryGoodOpenSource/flame_behaviors/issues diff --git a/packages/flame_steering_behaviors/tool/release_ready.sh b/packages/flame_steering_behaviors/tool/release_ready.sh new file mode 100644 index 0000000..2654895 --- /dev/null +++ b/packages/flame_steering_behaviors/tool/release_ready.sh @@ -0,0 +1,79 @@ +# Ensures that the package is ready for release. +# +# Set it up for a new version: +# `./release_ready.sh + +# 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 + +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\"" \ No newline at end of file