Check Flutter Version #389
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Check Flutter Version | |
on: | |
schedule: | |
- cron: "0 0 * * *" | |
jobs: | |
check-flutter-version: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-tags: "true" | |
fetch-depth: 0 | |
ref: main | |
- name: Get latest stable Flutter version | |
id: flutter-action | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: "stable" | |
- name: Get versions | |
id: get-versions | |
run: | | |
echo CURRENT_TAG=$(git describe --tags $(git rev-list --tags --max-count=1)) >> $GITHUB_OUTPUT | |
echo LATEST_TAG=${{ steps.flutter-action.outputs.VERSION }} >> $GITHUB_OUTPUT | |
- name: Compare versions | |
id: compare-versions | |
uses: madhead/semver-utils@latest | |
with: | |
version: ${{ steps.get-versions.outputs.LATEST_TAG }} | |
compare-to: ${{ steps.get-versions.outputs.CURRENT_TAG }} | |
- name: Update Dockerfile | |
if: ${{ steps.compare-versions.outputs.comparison-result == '>' }} | |
run: | | |
echo Newer stable flutter version found | |
echo "The version in this project is ${{ steps.get-versions.outputs.CURRENT_TAG }}" | |
echo "Latest version is ${{ steps.get-versions.outputs.LATEST_TAG }} | Revision: $revision | Date: $date" | |
sed -i "s/ENV FLUTTER_VERSION=.*/ENV FLUTTER_VERSION=\"${{ steps.get-versions.outputs.LATEST_TAG }}\"/" Dockerfile | |
- name: Update README | |
if: ${{ steps.compare-versions.outputs.comparison-result == '>' }} | |
run: | | |
framework_line=$(echo "$(flutter --version)" | grep "Framework") | |
revision=$(echo "$framework_line" | sed -E 's/.*revision ([^ ]+).*/\1/') | |
date=$(echo "$framework_line" | sed -E 's/.*([0-9]{4})-([0-9]{2})-([0-9]{2}).*/\1-\2-\3/') | |
sed -i "s@<a href=\"https://github.com/slashwhy/flutter-sdk-image/releases/tag/${{ steps.get-versions.outputs.CURRENT_TAG }}\"><img src=\"https://img.shields.io/badge/Current%20version-${{ steps.get-versions.outputs.CURRENT_TAG }}-blue.svg\"/></a>@<a href=\"https://github.com/slashwhy/flutter-sdk-image/releases/tag/${{ steps.get-versions.outputs.LATEST_TAG }}\"><img src=\"https://img.shields.io/badge/Current%20version-${{ steps.get-versions.outputs.LATEST_TAG }}-blue.svg\"/></a>@g" README.md | |
sed -i "s/slashwhyorganization\/flutter-sdk-image:${{ steps.get-versions.outputs.CURRENT_TAG }}/slashwhyorganization\/flutter-sdk-image:${{ steps.get-versions.outputs.LATEST_TAG }}/g" README.md | |
- name: Create Pull Request | |
if: ${{ steps.compare-versions.outputs.comparison-result == '>' }} | |
uses: peter-evans/create-pull-request@v7 | |
with: | |
commit-message: Update to ${{ steps.get-versions.outputs.LATEST_TAG }} | |
title: Update to ${{ steps.get-versions.outputs.LATEST_TAG }} | |
body: | | |
This PR was auto generated because a new Flutter version has been found | |
- [ ] make sure to run the PR pipeline, you can do this by closing and opening this pull request again | |
branch: feature/${{ steps.get-versions.outputs.LATEST_TAG }} |