Skip to content

Commit d2ee8cd

Browse files
authored
feat: fix flutter version (#2895)
1 parent 4dae625 commit d2ee8cd

File tree

8 files changed

+67
-0
lines changed

8 files changed

+67
-0
lines changed

.github/actions/android/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ runs:
3636
uses: subosito/flutter-action@v2
3737
with:
3838
cache: true
39+
flutter-version-file: pubspec.yaml
3940

4041
- name: Build Android APK/AAB
4142
shell: bash

.github/actions/common/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ runs:
77
uses: subosito/flutter-action@v2
88
with:
99
cache: true
10+
flutter-version-file: pubspec.yaml
1011

1112
- name: Fetch Flutter Dependencies
1213
shell: bash

.github/actions/ios/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ runs:
1717
uses: subosito/flutter-action@v2
1818
with:
1919
cache: true
20+
flutter-version-file: pubspec.yaml
2021

2122
- name: Update Podfile
2223
shell: bash

.github/actions/screenshot-android/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ runs:
5353
uses: subosito/flutter-action@v2
5454
with:
5555
cache: true
56+
flutter-version-file: pubspec.yaml
5657

5758
- name: Create Android Screenshots
5859
uses: reactivecircus/android-emulator-runner@v2

.github/actions/screenshot-ipad/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ runs:
1313
uses: subosito/flutter-action@v2
1414
with:
1515
cache: true
16+
flutter-version-file: pubspec.yaml
1617

1718
- name: Update Podfile
1819
shell: bash

.github/actions/screenshot-iphone/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ runs:
1313
uses: subosito/flutter-action@v2
1414
with:
1515
cache: true
16+
flutter-version-file: pubspec.yaml
1617

1718
- name: Update Podfile
1819
shell: bash
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Flutter Upgrade Check
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 * * 1"
6+
workflow_dispatch:
7+
8+
jobs:
9+
check-flutter-upgrade:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v5
15+
16+
- name: Read Flutter version from pubspec.yaml
17+
id: read-version
18+
run: |
19+
FLUTTER_VERSION=$(yq '.environment.flutter' pubspec.yaml)
20+
echo "Current Flutter version: $FLUTTER_VERSION"
21+
echo "flutter_version=$FLUTTER_VERSION" >> $GITHUB_ENV
22+
23+
- name: Get latest stable Flutter version
24+
id: check-latest
25+
run: |
26+
LATEST_VERSION=$(curl -s https://storage.googleapis.com/flutter_infra_release/releases/releases_linux.json | jq -r '.releases[] | select(.channel == "stable") | .version' | head -n 1)
27+
echo "Latest stable Flutter version: $LATEST_VERSION"
28+
echo "latest_flutter_version=$LATEST_VERSION" >> $GITHUB_ENV
29+
30+
- name: Compare versions and update pubspec.yaml if needed
31+
id: update-version
32+
run: |
33+
if [ "$flutter_version" != "$latest_flutter_version" ]; then
34+
echo "Updating Flutter version in pubspec.yaml..."
35+
sed -i "s/flutter:\s*'${flutter_version}'/flutter: '${latest_flutter_version}'/" pubspec.yaml
36+
git --no-pager diff
37+
echo "update_needed=true" >> $GITHUB_ENV
38+
else
39+
echo "Flutter is up to date."
40+
echo "update_needed=false" >> $GITHUB_ENV
41+
fi
42+
43+
- name: Commit and create PR if update is needed
44+
if: env.update_needed == 'true'
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
run: |
48+
git config --global user.name "dependabot[bot]"
49+
git config --global user.email "49699333+dependabot[bot]@users.noreply.github.com"
50+
51+
BRANCH_NAME="flutter-upgrade-${{ env.latest_flutter_version }}"
52+
git checkout -b $BRANCH_NAME
53+
git add pubspec.yaml
54+
git commit -m "chore: Upgrade Flutter to ${{ env.latest_flutter_version }}"
55+
git push origin -f $BRANCH_NAME
56+
57+
PR_URL=$(gh pr create --title "chore(deps): upgrade Flutter to ${{ env.latest_flutter_version }}" \
58+
--body "This PR updates Flutter version in pubspec.yaml to the latest stable release." \
59+
--base development \
60+
--head $BRANCH_NAME)

pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ version: 1.0.0+1
2020

2121
environment:
2222
sdk: ^3.5.4
23+
flutter: '3.35.3'
2324

2425
# Dependencies specify other packages that your package needs in order to work.
2526
# To automatically upgrade your package dependencies to the latest versions

0 commit comments

Comments
 (0)