From 7ff07e9ecd05af9a026fc24436c812d388c5b311 Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Wed, 18 Mar 2026 15:31:10 +0100 Subject: [PATCH] Add separate pub-cache boolean flag (#377) This allows to selectively enabled pub dependency caching. Uses backwards compatible default if only `cache: true` is set. Also update README --- README.md | 18 ++++++++++++++++++ action.yaml | 6 +++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6bd41f6..9f891e0 100644 --- a/README.md +++ b/README.md @@ -323,6 +323,7 @@ steps: channel: stable cache: true # optional parameters follow + pub-cache: true # optional, defaults to empty (falls back to cache value for backward compatibility) cache-key: "flutter-:os:-:channel:-:version:-:arch:-:hash:" # optional, change this to force refresh cache cache-path: "${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:" # optional, change this to specify the cache path pub-cache-key: "flutter-pub-:os:-:channel:-:version:-:arch:-:hash:" # optional, change this to force refresh cache of dart pub get dependencies @@ -330,6 +331,23 @@ steps: - run: flutter --version ``` +> [!NOTE] +> +> The `cache` and `pub-cache` inputs are independent and control different caches: +> - `cache: true` - Caches the Flutter SDK installation +> - `pub-cache: true` - Caches Dart pub dependencies +> - `pub-cache: false` - Disables pub dependency caching +> +> **Backward Compatibility:** When `pub-cache` is not specified (empty), it falls back to the `cache` value. +> This means existing workflows with `cache: true` will automatically cache both Flutter SDK and pub dependencies. +> +> You can use them in any combination: +> - Both enabled: `cache: true` (pub-cache will default to true for backward compatibility) +> - Both enabled explicitly: `cache: true` and `pub-cache: true` +> - Only Flutter SDK: `cache: true` and `pub-cache: false` +> - Only pub dependencies: `cache: false` and `pub-cache: true` for self-hosted runners +> - Neither: `cache: false` and `pub-cache: false` (or omit both) + Note: `cache-key`, `pub-cache-key`, and `cache-path` have support for several dynamic values: diff --git a/action.yaml b/action.yaml index 2bc1ec8..644170e 100644 --- a/action.yaml +++ b/action.yaml @@ -34,6 +34,10 @@ inputs: description: Flutter SDK cache path required: false default: "" + pub-cache: + description: Cache the Dart pub dependencies + required: false + default: "" pub-cache-key: description: Identifier for the Dart .pub-cache cache required: false @@ -125,7 +129,7 @@ runs: - name: Cache pub dependencies uses: actions/cache@v5 id: cache-pub - if: ${{ inputs.cache == 'true' }} + if: ${{ (inputs.pub-cache == '' && inputs.cache == 'true') || inputs.pub-cache == 'true' }} with: path: ${{ steps.flutter-action.outputs.PUB-CACHE-PATH }} key: ${{ steps.flutter-action.outputs.PUB-CACHE-KEY }}-${{ hashFiles('**/pubspec.lock') }}