|
| 1 | +name: Update Flutter stable version |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: "23 6 * * *" |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + pull-requests: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + update: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v6 |
| 17 | + |
| 18 | + - name: Find latest stable Flutter version |
| 19 | + id: latest |
| 20 | + shell: bash |
| 21 | + run: | |
| 22 | + set -euo pipefail |
| 23 | + latest=$( |
| 24 | + curl --fail --silent https://api.github.com/repos/flutter/flutter/releases/latest \ |
| 25 | + | jq -r '.tag_name | sub("^v"; "")' |
| 26 | + ) |
| 27 | + if [ -z "$latest" ] || [ "$latest" = "null" ]; then |
| 28 | + echo "Could not resolve latest Flutter release" >&2 |
| 29 | + exit 1 |
| 30 | + fi |
| 31 | + echo "version=$latest" >> "$GITHUB_OUTPUT" |
| 32 | +
|
| 33 | + - name: Update versions.env |
| 34 | + id: update |
| 35 | + shell: bash |
| 36 | + run: | |
| 37 | + set -euo pipefail |
| 38 | + current=$(grep '^FLUTTER_STABLE_VERSION=' versions.env | cut -d= -f2- || true) |
| 39 | + if [ "$current" = "${{ steps.latest.outputs.version }}" ]; then |
| 40 | + echo "changed=false" >> "$GITHUB_OUTPUT" |
| 41 | + exit 0 |
| 42 | + fi |
| 43 | + tmp=$(mktemp) |
| 44 | + awk -F= -v latest="${{ steps.latest.outputs.version }}" \ |
| 45 | + 'BEGIN { updated=0 } /^FLUTTER_STABLE_VERSION=/ { print "FLUTTER_STABLE_VERSION=" latest; updated=1; next } { print } END { if (!updated) print "FLUTTER_STABLE_VERSION=" latest }' \ |
| 46 | + versions.env > "$tmp" |
| 47 | + mv "$tmp" versions.env |
| 48 | + echo "changed=true" >> "$GITHUB_OUTPUT" |
| 49 | +
|
| 50 | + - name: Create pull request |
| 51 | + if: steps.update.outputs.changed == 'true' |
| 52 | + uses: peter-evans/create-pull-request@v8 |
| 53 | + with: |
| 54 | + branch: bot/update-flutter-${{ steps.latest.outputs.version }} |
| 55 | + commit-message: Update Flutter to ${{ steps.latest.outputs.version }} |
| 56 | + title: Update Flutter to ${{ steps.latest.outputs.version }} |
| 57 | + body: | |
| 58 | + Updates the base image Flutter SDK version to `${{ steps.latest.outputs.version }}`. |
| 59 | +
|
| 60 | + The publish workflow will build and push: |
| 61 | + - `ghcr.io/${{ github.repository }}-web-only:${{ steps.latest.outputs.version }}` |
| 62 | + labels: dependencies, flutter |
0 commit comments