-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add inputs setFlutterRootPath, setPubCachePath and addPubCacheBinToPath.
- Loading branch information
1 parent
11f96cd
commit 0290f5e
Showing
6 changed files
with
250 additions
and
6 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [Unreleased] | ||
|
||
## [1.1.0] - 2021-12-22 | ||
### Added | ||
- Inputs setFlutterRootPath, setPubCachePath and addPubCacheBinToPath. | ||
|
||
## [1.0.0] - 2021-12-10 | ||
Initial release |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,23 @@ author: 'Hrishikesh Kadam <[email protected]>' | |
description: 'Composite GitHub Action to setup and cache the Flutter SDK.' | ||
inputs: | ||
ref: | ||
description: 'channel (stable, beta or master), version(2.8) or any git reference(2.8.0-3.3.pre)' | ||
description: 'channel (stable, beta or master), version(2.8.0) or any git reference(2.8.0-3.3.pre).' | ||
required: false | ||
default: 'stable' | ||
setFlutterRootPath: | ||
description: 'Set FLUTTER_ROOT to path where Flutter is installed.' | ||
required: false | ||
default: 'false' | ||
setPubCachePath: | ||
description: 'Set PUB_CACHE to desired path, where pub saves dependencies.' | ||
required: false | ||
default: '' | ||
addPubCacheBinToPath: | ||
description: 'Add PUB_CACHE bin to PATH.\n | ||
Note: On Windows, activated global packages can be run by without specifying | ||
`dart pub global run` only on pwsh, cmd and powershell.' | ||
required: false | ||
default: 'false' | ||
|
||
runs: | ||
using: 'composite' | ||
|
@@ -14,24 +28,57 @@ runs: | |
run: | | ||
echo "FLUTTER_REF_HEAD=$(git ls-remote https://github.com/flutter/flutter ${{ inputs.ref }} | cut -f 1)" >> $GITHUB_ENV | ||
shell: bash | ||
|
||
- name: Check if Flutter is cached | ||
id: cache-flutter | ||
uses: actions/cache@v2 | ||
with: | ||
path: ${{ runner.tool_cache }}/flutter | ||
key: flutter-${{ runner.os }}-${{ inputs.ref }}-${{ env.FLUTTER_REF_HEAD }} | ||
|
||
- name: Clone Flutter repository if not cached | ||
if: steps.cache-flutter.outputs.cache-hit != 'true' | ||
run: | | ||
git clone --branch ${{ inputs.ref }} --depth 1 \ | ||
https://github.com/flutter/flutter $RUNNER_TOOL_CACHE/flutter | ||
shell: bash | ||
|
||
- name: Set FLUTTER_ROOT on Linux or macOS | ||
if: inputs.setFlutterRootPath == 'true' && runner.os != 'Windows' | ||
run: echo "FLUTTER_ROOT=$RUNNER_TOOL_CACHE/flutter" >> $GITHUB_ENV | ||
shell: bash | ||
|
||
- name: Set FLUTTER_ROOT on Windows | ||
if: inputs.setFlutterRootPath == 'true' && runner.os == 'Windows' | ||
run: echo "FLUTTER_ROOT=$env:RUNNER_TOOL_CACHE\flutter" | Out-File -FilePath $env:GITHUB_ENV -Append | ||
shell: pwsh | ||
|
||
- name: Add Flutter to PATH | ||
run: echo "$RUNNER_TOOL_CACHE/flutter/bin" >> $GITHUB_PATH | ||
shell: bash | ||
|
||
- name: Set PUB_CACHE on Linux or macOS | ||
if: inputs.setPubCachePath != '' && runner.os != 'Windows' | ||
run: | | ||
PUB_CACHE=${{ inputs.setPubCachePath }} | ||
echo "PUB_CACHE=$PUB_CACHE" >> $GITHUB_ENV | ||
shell: bash | ||
|
||
- name: Set PUB_CACHE on Windows | ||
if: inputs.setPubCachePath != '' && runner.os == 'Windows' | ||
run: | | ||
$env:PUB_CACHE="${{ inputs.setPubCachePath }}" | ||
echo "PUB_CACHE=$env:PUB_CACHE" | Out-File -FilePath $env:GITHUB_ENV -Append | ||
shell: pwsh | ||
|
||
- name: Add PUB_CACHE bin to PATH | ||
if: inputs.addPubCacheBinToPath == 'true' | ||
run: ./src/add-pub-cache-bin-to-path.sh | ||
shell: bash | ||
|
||
- run: flutter --version | ||
shell: bash | ||
|
||
branding: | ||
icon: 'heart' | ||
color: 'purple' | ||
color: 'blue' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [[ -n $PUB_CACHE ]]; then | ||
if [[ $RUNNER_OS == 'Windows' ]]; then | ||
PUB_CACHE_BIN="$PUB_CACHE\bin" | ||
else | ||
PUB_CACHE_BIN=$PUB_CACHE/bin | ||
fi | ||
else | ||
if [[ $RUNNER_OS == 'Windows' ]]; then | ||
PUB_CACHE_BIN="$LOCALAPPDATA\Pub\Cache\bin" | ||
else | ||
PUB_CACHE_BIN=$HOME/.pub-cache/bin | ||
fi | ||
fi | ||
|
||
echo "::debug::Adding $PUB_CACHE_BIN to \$GITHUB_PATH" | ||
echo "$PUB_CACHE_BIN" >> $GITHUB_PATH |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [[ -n $PUB_CACHE ]]; then | ||
echo "$PUB_CACHE" | ||
else | ||
if [[ $RUNNER_OS == 'Windows' ]]; then | ||
echo "$LOCALAPPDATA\Pub\Cache" | ||
else | ||
echo "$HOME/.pub-cache" | ||
fi | ||
fi |