Skip to content

Commit

Permalink
Add separate setup action
Browse files Browse the repository at this point in the history
  • Loading branch information
kuhnroyal committed Aug 26, 2024
1 parent 4155f8c commit 3f51cd2
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 30 deletions.
67 changes: 40 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,67 +1,80 @@
# flutter-fvm-config-action
An action that parses an [FVM](https://github.com/leoafarias/fvm) config file (.fvmrc) into environment variables which
can then be used to configure the [flutter-action](https://github.com/subosito/flutter-action).

## Usage
An action that parses an [FVM](https://github.com/leoafarias/fvm) config file `.fvmrc` and configures the [subosito/flutter-action](https://github.com/subosito/flutter-action)
to install the Flutter SDK.

All the sample options below can be combined with each other.
An additional action is provided that just parses the FVM config into outputs & environment variables which
can then be used to manually configure the [subosito/flutter-action](https://github.com/subosito/flutter-action).

## Usage

### Basic usage
### Basic setup `kuhnroyal/flutter-fvm-config-action/setup`

The configuration will parse the FVM configuration and use subosito/flutter-action to install & cache the configured Flutter version.
The configuration will parse the FVM configuration and use subosito/flutter-action to install the configured Flutter version.

```yaml
steps:
- uses: actions/checkout@v4
- uses: kuhnroyal/flutter-fvm-config-action@v2
with:
# The setup flag enables installation of the Flutter SDK, will default to true in the next major version (v3)
setup: true
# The cache flag enables caching of the Flutter SDK, default is true - if setup is true
cache: true
- uses: kuhnroyal/flutter-fvm-config-action/setup@develop
```
### Basic usage with manual configuration
### Manual configuration & setup `kuhnroyal/flutter-fvm-config-action/config`

```yaml
steps:
- uses: actions/checkout@v4
- uses: kuhnroyal/flutter-fvm-config-action@v2
- uses: kuhnroyal/flutter-fvm-config-action/config@develop
id: fvm-config-action
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ steps.fvm-config-action.outputs.FLUTTER_VERSION }}
channel: ${{ steps.fvm-config-action.outputs.FLUTTER_CHANNEL }}
```

> [!IMPORTANT]
> The main action `kuhnroyal/flutter-fvm-config-action` will continue to work and can be configured either way.

## Configuration inputs

All the sample options below can be combined with each other.

### Custom config path

If you have a custom path for your `.fvmrc` file, you can set it with the `path` input.

```yaml
steps:
- uses: actions/checkout@v4
- uses: kuhnroyal/flutter-fvm-config-action@v2
id: fvm-config-action
- uses: kuhnroyal/flutter-fvm-config-action/setup@develop
with:
path: 'some-path/.fvmrc'
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ steps.fvm-config-action.outputs.FLUTTER_VERSION }}
channel: ${{ steps.fvm-config-action.outputs.FLUTTER_CHANNEL }}
```

### Reading specific flavor
### FVM flavor

If you require a specific flavor, you can set it with the `flavor` input.

```yaml
steps:
- uses: actions/checkout@v4
- uses: kuhnroyal/flutter-fvm-config-action@v2
id: fvm-config-action
- uses: kuhnroyal/flutter-fvm-config-action/setup@develop
with:
flavor: 'staging'
- uses: subosito/flutter-action@v2
```

### Enable Dart/Flutter analytics

Analytics are disabled by default. To enable them, set `disable-analytics` to `false`.

```yaml
steps:
- uses: actions/checkout@v4
- uses: kuhnroyal/flutter-fvm-config-action/setup@develop
with:
flutter-version: ${{ steps.fvm-config-action.outputs.FLUTTER_VERSION }}
channel: ${{ steps.fvm-config-action.outputs.FLUTTER_CHANNEL }}
disable-analytics: false
```

### Caching

This action supports all cache inputs from the [subosito/flutter-action](https://github.com/subosito/flutter-action):
See https://github.com/subosito/flutter-action#caching for more information.
See https://github.com/subosito/flutter-action#caching for more information.
13 changes: 11 additions & 2 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ inputs:
description: 'Setup Flutter via "subosito/flutter-action"? (default: false)'
required: false
default: 'false'
disable-analytics:
description: 'Disable analytics for Flutter and Dart'
required: false
default: 'true'
cache:
description: 'Cache Flutter via "subosito/flutter-action"? (default: true - if setup is true)'
required: false
default: 'true'
default: 'false'
cache-key:
description: 'Identifier for the Flutter SDK cache'
required: false
Expand Down Expand Up @@ -44,7 +48,7 @@ runs:
using: 'composite'
steps:
- name: Parse configuration
uses: kuhnroyal/flutter-fvm-config-action/config@v2
uses: kuhnroyal/flutter-fvm-config-action/config@develop
id: config
with:
path: ${{ inputs.path }}
Expand All @@ -60,6 +64,11 @@ runs:
cache-path: ${{ inputs.cache-path }}
pub-cache-key: ${{ inputs.pub-cache-key }}
pub-cache-path: ${{ inputs.pub-cache-path }}
- shell: sh
if: inputs.setup == 'true' && inputs.disable-analytics == 'true'
run: |
flutter config --no-analytics
dart --disable-analytics
branding:
icon: 'maximize'
color: 'blue'
2 changes: 1 addition & 1 deletion config/action.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'Flutter FVM config action'
description: 'Action that parses an FVM config file in order to configure the subosito/flutter-action.'
description: 'Action that parses an FVM config file and provides the version/channel as output/env variables.'
author: 'Peter Leibiger'
inputs:
path:
Expand Down
62 changes: 62 additions & 0 deletions setup/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: 'Flutter FVM setup action'
description: 'Action that parses an FVM config file and sets up the subosito/flutter-action.'
author: 'Peter Leibiger'
inputs:
path:
description: 'Path to the FVM config file'
required: false
flavor:
description: 'Flavor to use'
required: false
default: ''
disable-analytics:
description: 'Disable analytics for Flutter and Dart'
required: false
default: 'true'
cache:
description: 'Cache Flutter via "subosito/flutter-action"? (default: true - if setup is true)'
required: false
default: 'true'
cache-key:
description: 'Identifier for the Flutter SDK cache'
required: false
default: ''
cache-path:
description: 'Flutter SDK cache path'
required: false
default: ''
pub-cache-key:
description: 'Identifier for the Dart .pub-cache cache'
required: false
default: ''
pub-cache-path:
description: 'Flutter pub cache path'
required: false
default: default
runs:
using: 'composite'
steps:
- name: Parse configuration
uses: kuhnroyal/flutter-fvm-config-action/config@develop
id: config
with:
path: ${{ inputs.path }}
flavor: ${{ inputs.flavor }}
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ steps.config.outputs.FLUTTER_VERSION }}
channel: ${{ steps.config.outputs.FLUTTER_CHANNEL }}
cache: ${{ inputs.cache }}
cache-key: ${{ inputs.cache-key }}
cache-path: ${{ inputs.cache-path }}
pub-cache-key: ${{ inputs.pub-cache-key }}
pub-cache-path: ${{ inputs.pub-cache-path }}
- shell: sh
if: inputs.disable-analytics == 'true'
run: |
flutter config --no-analytics
dart --disable-analytics
branding:
icon: 'maximize'
color: 'blue'

0 comments on commit 3f51cd2

Please sign in to comment.