Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ Omit `flutter-version` to track a channel instead (default `stable`):
Run it after checkout and before any `flutter` command. It replaces roughly
20 lines per job; we were carrying nine copies before extracting this.

## Caching

The pub cache step snapshots the directory `flutter pub get` writes to on
the current runner, resolved from the `PUB_CACHE` env var that
[subosito/flutter-action](https://github.com/subosito/flutter-action)
exports for the job. That path is `~/.pub-cache` on Linux and macOS and the
`LOCALAPPDATA` Pub Cache on Windows, so the same workflow caches the right
directory on every runner OS. Leave the key (`${{ runner.os }}-pub-...`) as
is for cross-OS safety: a cache built on Windows is not reused on Ubuntu,
and vice versa.

## License

AGPL-3.0
9 changes: 8 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ runs:
- name: Cache pub
uses: actions/cache@v6
with:
path: ~/.pub-cache
# subosito/flutter-action@v2 exports PUB_CACHE to the job environment,
# pointing at the directory `flutter pub get` actually populates
# (~/.pub-cache on Linux and macOS, the LOCALAPPDATA Pub Cache on
# Windows). Cache that path directly so this step stays in sync with
# the SDK install step on every runner OS. Hardcoding ~/.pub-cache
# instead misses the real cache directory on Windows runners, where
# Flutter writes pub packages to %LOCALAPPDATA%\Pub\Cache by default.
path: ${{ env.PUB_CACHE }}
key: ${{ runner.os }}-pub-${{ hashFiles('pubspec.lock') }}
restore-keys: |
${{ runner.os }}-pub-
Expand Down