Skip to content

Commit 0504af7

Browse files
committed
change in flutter
1 parent ea9fd69 commit 0504af7

File tree

2 files changed

+69
-21
lines changed

2 files changed

+69
-21
lines changed

.flutter-version-tracked

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.32.3

.github/workflows/flutter-upgrade.yml

Lines changed: 68 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,45 @@ jobs:
2727
- name: Get current Flutter version
2828
id: current-version
2929
run: |
30-
CURRENT_VERSION=$(flutter --version | head -n 1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
31-
echo "current=$CURRENT_VERSION" >> $GITHUB_OUTPUT
32-
echo "Current Flutter version: $CURRENT_VERSION"
30+
# Check if we have a tracked version file
31+
if [ -f ".flutter-version-tracked" ]; then
32+
TRACKED_VERSION=$(cat .flutter-version-tracked)
33+
echo "tracked=$TRACKED_VERSION" >> $GITHUB_OUTPUT
34+
echo "Previously tracked Flutter version: $TRACKED_VERSION"
35+
else
36+
# Get current installed version as fallback
37+
CURRENT_VERSION=$(flutter --version | head -n 1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
38+
echo "tracked=$CURRENT_VERSION" >> $GITHUB_OUTPUT
39+
echo "No tracked version found, using current Flutter version: $CURRENT_VERSION"
40+
fi
41+
42+
# Also get the actual installed version for reference
43+
INSTALLED_VERSION=$(flutter --version | head -n 1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
44+
echo "installed=$INSTALLED_VERSION" >> $GITHUB_OUTPUT
45+
echo "Currently installed Flutter version: $INSTALLED_VERSION"
3346
3447
- name: Check for Flutter upgrades
3548
id: check-upgrade
3649
run: |
37-
# Get the latest stable Flutter version
38-
LATEST_VERSION=$(curl -s https://api.github.com/repos/flutter/flutter/releases/latest | grep -oP '"tag_name": "\K[^"]*')
50+
# Get the latest stable Flutter version (filter out pre-releases)
51+
LATEST_VERSION=$(curl -s https://api.github.com/repos/flutter/flutter/releases | grep '"tag_name"' | grep -v 'pre' | head -1 | cut -d '"' -f 4)
52+
53+
# Fallback to current installed version if API call fails
54+
if [ -z "$LATEST_VERSION" ]; then
55+
LATEST_VERSION=${{ steps.current-version.outputs.installed }}
56+
echo "Warning: Could not fetch latest version from GitHub, using installed version"
57+
fi
3958
echo "latest=$LATEST_VERSION" >> $GITHUB_OUTPUT
4059
echo "Latest Flutter version: $LATEST_VERSION"
4160
42-
# Compare versions
43-
if [ "${{ steps.current-version.outputs.current }}" != "$LATEST_VERSION" ]; then
61+
# Compare with tracked version (not current installed version)
62+
TRACKED_VERSION="${{ steps.current-version.outputs.tracked }}"
63+
if [ "$TRACKED_VERSION" != "$LATEST_VERSION" ]; then
4464
echo "upgrade_available=true" >> $GITHUB_OUTPUT
45-
echo "Upgrade available: ${{ steps.current-version.outputs.current }} -> $LATEST_VERSION"
65+
echo "Upgrade available: $TRACKED_VERSION -> $LATEST_VERSION"
4666
else
4767
echo "upgrade_available=false" >> $GITHUB_OUTPUT
48-
echo "Flutter is already up to date"
68+
echo "Flutter is already up to date (tracked: $TRACKED_VERSION)"
4969
fi
5070
5171
- name: Check for dependency updates
@@ -155,6 +175,13 @@ jobs:
155175
echo "Applying fixes:"
156176
dart fix --apply || echo "No fixes applied or apply failed"
157177
178+
- name: Update tracked Flutter version
179+
if: steps.check-upgrade.outputs.upgrade_available == 'true'
180+
run: |
181+
echo "Updating tracked Flutter version to ${{ steps.check-upgrade.outputs.latest }}"
182+
echo "${{ steps.check-upgrade.outputs.latest }}" > .flutter-version-tracked
183+
echo "Tracked version file updated"
184+
158185
- name: Install dependencies and test
159186
if: steps.check-upgrade.outputs.upgrade_available == 'true' || steps.check-deps.outputs.deps_available == 'true'
160187
run: |
@@ -184,33 +211,53 @@ jobs:
184211
fi
185212
186213
- name: Commit changes
187-
if: steps.check-upgrade.outputs.upgrade_available == 'true' && steps.check-changes.outputs.has_changes == 'true' || steps.check-deps.outputs.deps_available == 'true' && steps.check-changes.outputs.has_changes == 'true'
214+
if: steps.check-changes.outputs.has_changes == 'true'
188215
run: |
189-
git commit -m "chore: upgrade Flutter to ${{ steps.check-upgrade.outputs.latest }} and dependencies"
190-
191-
- Automated Flutter upgrade from ${{ steps.current-version.outputs.current }} to ${{ steps.check-upgrade.outputs.latest }}
192-
- Updated dependencies with flutter pub get
216+
# Create appropriate commit message based on what was updated
217+
if [ "${{ steps.check-upgrade.outputs.upgrade_available }}" == "true" ] && [ "${{ steps.check-deps.outputs.deps_available }}" == "true" ]; then
218+
COMMIT_MSG="chore: upgrade Flutter to ${{ steps.check-upgrade.outputs.latest }} and update dependencies
219+
220+
- Automated Flutter upgrade from ${{ steps.current-version.outputs.tracked }} to ${{ steps.check-upgrade.outputs.latest }}
221+
- Updated dependencies (dio, http)
222+
- Applied automatic fixes with dart fix
223+
- Updated tracked Flutter version
224+
- Verified with flutter analyze and flutter test"
225+
elif [ "${{ steps.check-upgrade.outputs.upgrade_available }}" == "true" ]; then
226+
COMMIT_MSG="chore: upgrade Flutter to ${{ steps.check-upgrade.outputs.latest }}
227+
228+
- Automated Flutter upgrade from ${{ steps.current-version.outputs.tracked }} to ${{ steps.check-upgrade.outputs.latest }}
229+
- Applied automatic fixes with dart fix
230+
- Updated tracked Flutter version
231+
- Verified with flutter analyze and flutter test"
232+
else
233+
COMMIT_MSG="chore: update dependencies
234+
235+
- Updated dependencies (dio: ${{ steps.check-deps.outputs.dio_latest }}, http: ${{ steps.check-deps.outputs.http_latest }})
236+
- Applied automatic fixes with dart fix
193237
- Verified with flutter analyze and flutter test"
238+
fi
239+
240+
git commit -m "$COMMIT_MSG"
194241
195242
- name: Push changes
196-
if: steps.check-upgrade.outputs.upgrade_available == 'true' && steps.check-changes.outputs.has_changes == 'true' || steps.check-deps.outputs.deps_available == 'true' && steps.check-changes.outputs.has_changes == 'true'
243+
if: steps.check-changes.outputs.has_changes == 'true'
197244
run: |
198245
git push origin "$BRANCH_NAME"
199246
200247
- name: Create Pull Request
201-
if: steps.check-upgrade.outputs.upgrade_available == 'true' && steps.check-changes.outputs.has_changes == 'true' || steps.check-deps.outputs.deps_available == 'true' && steps.check-changes.outputs.has_changes == 'true'
248+
if: steps.check-changes.outputs.has_changes == 'true'
202249
uses: actions/github-script@v7
203250
with:
204251
script: |
205252
const { data: pullRequest } = await github.rest.pulls.create({
206253
owner: context.repo.owner,
207254
repo: context.repo.repo,
208-
title: 'chore: upgrade Flutter to ' + ${{ steps.check-upgrade.outputs.latest }} + ' and dependencies',
255+
title: 'chore: upgrade Flutter to ' + '${{ steps.check-upgrade.outputs.latest }}' + ' and dependencies',
209256
head: process.env.BRANCH_NAME,
210257
base: 'master', // Change to 'main' if that's your default branch
211258
body: '## Flutter Auto Upgrade
212259
213-
This PR was automatically created to upgrade Flutter from **' + ${{ steps.current-version.outputs.current }} + '** to **' + ${{ steps.check-upgrade.outputs.latest }} + '** and update dependencies.
260+
This PR was automatically created to upgrade Flutter from **' + '${{ steps.current-version.outputs.tracked }}' + '** to **' + '${{ steps.check-upgrade.outputs.latest }}' + '** and update dependencies.
214261
215262
### Changes Made:
216263
- Upgraded Flutter to the latest stable version
@@ -236,7 +283,7 @@ jobs:
236283
console.log('Created PR #' + pullRequest.number);
237284
238285
- name: Add labels to PR
239-
if: steps.check-upgrade.outputs.upgrade_available == 'true' && steps.check-changes.outputs.has_changes == 'true' || steps.check-deps.outputs.deps_available == 'true' && steps.check-changes.outputs.has_changes == 'true'
286+
if: steps.check-changes.outputs.has_changes == 'true'
240287
uses: actions/github-script@v7
241288
with:
242289
script: |
@@ -263,7 +310,7 @@ jobs:
263310
if [ "${{ steps.check-upgrade.outputs.upgrade_available }}" == "true" ]; then
264311
if [ "${{ steps.check-changes.outputs.has_changes }}" == "true" ]; then
265312
echo "Flutter upgrade available, changes detected, and PR created!"
266-
echo "Upgraded from ${{ steps.current-version.outputs.current }} to ${{ steps.check-upgrade.outputs.latest }}"
313+
echo "Upgraded from ${{ steps.current-version.outputs.tracked }} to ${{ steps.check-upgrade.outputs.latest }}"
267314
else
268315
echo "Flutter upgrade available, but no changes detected"
269316
fi
@@ -274,5 +321,5 @@ jobs:
274321
echo "Dependency updates available, but no changes detected"
275322
fi
276323
else
277-
echo "Flutter is already up to date (${{ steps.current-version.outputs.current }})"
324+
echo "Flutter is already up to date (tracked: ${{ steps.current-version.outputs.tracked }})"
278325
fi

0 commit comments

Comments
 (0)