forked from fossasia/pslab-app
-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (58 loc) · 2.29 KB
/
Copy pathflutter_upgrade.yml
File metadata and controls
68 lines (58 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: Flutter Upgrade Check
on:
schedule:
- cron: "0 0 * * 1"
workflow_dispatch:
jobs:
check-flutter-upgrade:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v5
- name: Read current Flutter version
id: read-version
shell: bash
run: |
FLUTTER_VERSION=$(cat .flutter-version)
echo "Current Flutter version: $FLUTTER_VERSION"
echo "FLUTTER_VERSION=$FLUTTER_VERSION" >> $GITHUB_ENV
- name: Get latest stable Flutter version
id: check-latest
shell: bash
run: |
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)
echo "Latest stable Flutter version: $LATEST_VERSION"
echo "LATEST_VERSION=$LATEST_VERSION" >> $GITHUB_ENV
- name: Compare versions and update .flutter-version
id: update-version
shell: bash
run: |
if [ "$FLUTTER_VERSION" != "$LATEST_VERSION" ]; then
echo "Updating Flutter version..."
echo "$LATEST_VERSION" > .flutter-version
git --no-pager diff
echo "UPDATE_NEEDED=true" >> $GITHUB_ENV
else
echo "Flutter is already up to date."
echo "UPDATE_NEEDED=false" >> $GITHUB_ENV
fi
- name: Commit and create PR if update is needed
if: env.UPDATE_NEEDED == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
BRANCH_NAME="flutter-upgrade-${LATEST_VERSION}"
git checkout -b "$BRANCH_NAME"
git add .flutter-version
git commit -m "chore: upgrade Flutter to ${LATEST_VERSION}"
git push origin "$BRANCH_NAME"
gh pr create \
--title "chore(deps): upgrade Flutter to ${LATEST_VERSION}" \
--body "This PR updates the Flutter SDK version in .flutter-version to the latest stable release." \
--base flutter \
--head "$BRANCH_NAME"