From c370264cce0aaf5130c3ea2563795220f6d4a9c7 Mon Sep 17 00:00:00 2001 From: Sebastian Messingfeld Date: Sat, 4 Jul 2026 06:21:21 +0200 Subject: [PATCH] feat: cache SDK, add flutter-version output, bump deps - action.yml: cache exact Flutter versions via actions/cache@v4 (moving channels stable/beta/master are excluded to avoid pinning a stale SDK), add flutter-version output, use --single-branch clone - ci: bump actions/checkout@v3 -> v7, example version 3.7.7 -> 3.44.4, assert the flutter-version output is populated - docs: fix "Versionen" typo, document inputs/outputs and caching, point usage example at @v1 and Flutter 3.44.4 Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_011UGuW2u1CSh2sZCd3RdYjj --- .github/workflows/main.yml | 10 ++++++++-- README.md | 26 ++++++++++++++++++++------ action.yml | 30 ++++++++++++++++++++++++++---- 3 files changed, 54 insertions(+), 12 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 07f184c..6ed477e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,12 +6,18 @@ jobs: strategy: matrix: os: [macos-latest, ubuntu-latest] - flutter-sdk-version: ["stable", "beta", "3.7.7"] + flutter-sdk-version: ["stable", "beta", "3.44.4"] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v7 - name: Install Flutter SDK + id: flutter uses: ./ with: flutter-sdk-version: ${{ matrix.flutter-sdk-version }} + - name: Assert flutter-version output + run: | + test -n "${{ steps.flutter.outputs.flutter-version }}" + echo "Installed: ${{ steps.flutter.outputs.flutter-version }}" + shell: bash - run: flutter --version - run: flutter doctor diff --git a/README.md b/README.md index 83bc464..e384d5b 100644 --- a/README.md +++ b/README.md @@ -3,20 +3,34 @@ The action installs the specified Flutter SDK version in the used runner. Both Linux and macOS runners are supported. By default, the latest stable release of the Flutter SDK is used. +The installed SDK is cached between runs, so subsequent runs of the same version skip the clone. -## Flutter SDK Versionen +## Flutter SDK Versions | Flutter SDK Version | Description | Default | Link | | --- | --- | --- | --- | | stable | Latest stable version of Flutter SDK | true | https://flutter.dev/docs/development/tools/sdk/releases | | beta | Latest beta version of Flutter SDK | false | https://flutter.dev/docs/development/tools/sdk/releases | -| x.y.z | Exact version of Flutter SDK, like 3.7.7 | false | https://flutter.dev/docs/development/tools/sdk/releases | +| x.y.z | Exact version of Flutter SDK, like 3.44.4 | false | https://flutter.dev/docs/development/tools/sdk/releases | + + +## Inputs + +| Name | Description | Default | +| --- | --- | --- | +| flutter-sdk-version | The Flutter SDK version to install (`stable`, `beta`, or an exact `x.y.z`) | `stable` | + +## Outputs + +| Name | Description | +| --- | --- | +| flutter-version | The resolved Flutter version reported by the installed SDK | ## Usage -Install Flutter SDK version 3.7.7 on macOS runner: +Install Flutter SDK version 3.44.4 on macOS runner: ```yaml on: [push] @@ -25,11 +39,11 @@ jobs: main: runs-on: macos-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v7 - name: Install Flutter SDK - uses: mobiledevops/flutter-sdk-action@v1.0.0 + uses: mobiledevops/flutter-sdk-action@v1 with: - flutter-sdk-version: 3.7.7 + flutter-sdk-version: 3.44.4 - run: flutter --version - run: flutter doctor - run: flutter pub get diff --git a/action.yml b/action.yml index f189cdd..a4c742c 100644 --- a/action.yml +++ b/action.yml @@ -9,14 +9,36 @@ inputs: description: "The Flutter SDK Version" required: false default: "stable" +outputs: + flutter-version: + description: "The resolved Flutter version reported by the installed SDK" + value: ${{ steps.install.outputs.flutter-version }} runs: using: "composite" steps: - - run: | + - name: Cache Flutter SDK + id: cache + # Only cache immutable exact versions. Moving channels (stable/beta/master) + # would otherwise be pinned to a stale SDK forever. + if: inputs.flutter-sdk-version != 'stable' && inputs.flutter-sdk-version != 'beta' && inputs.flutter-sdk-version != 'master' && inputs.flutter-sdk-version != 'main' + uses: actions/cache@v4 + with: + path: | + ~/.flutter + ~/.pub-cache + key: ${{ runner.os }}-flutter-${{ inputs.flutter-sdk-version }} + - name: Clone Flutter SDK + if: steps.cache.outputs.cache-hit != 'true' + run: | echo "Installing Flutter SDK ${{ inputs.flutter-sdk-version }}" - git clone https://github.com/flutter/flutter.git --depth 1 --branch ${{ inputs.flutter-sdk-version }} "$HOME/.flutter" + git clone https://github.com/flutter/flutter.git --depth 1 --single-branch --branch ${{ inputs.flutter-sdk-version }} "$HOME/.flutter" + shell: bash + - name: Configure and precache Flutter SDK + id: install + run: | echo "$HOME/.flutter/bin" >> $GITHUB_PATH echo "$HOME/.pub-cache/bin" >> $GITHUB_PATH - shell: bash - - run: flutter precache + "$HOME/.flutter/bin/flutter" precache + version="$("$HOME/.flutter/bin/flutter" --version | head -n 1)" + echo "flutter-version=$version" >> $GITHUB_OUTPUT shell: bash