From 3f51cd280eb3fbc36717032db886f79d193f116e Mon Sep 17 00:00:00 2001 From: Peter Leibiger Date: Mon, 26 Aug 2024 17:06:09 +0200 Subject: [PATCH] Add separate setup action --- README.md | 67 +++++++++++++++++++++++++++------------------- action.yaml | 13 +++++++-- config/action.yaml | 2 +- setup/action.yaml | 62 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 114 insertions(+), 30 deletions(-) create mode 100644 setup/action.yaml diff --git a/README.md b/README.md index 530480c..990d090 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,29 @@ # 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: @@ -33,35 +31,50 @@ The configuration will parse the FVM configuration and use subosito/flutter-acti 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. \ No newline at end of file +See https://github.com/subosito/flutter-action#caching for more information. diff --git a/action.yaml b/action.yaml index ad84fc2..101d9f8 100644 --- a/action.yaml +++ b/action.yaml @@ -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 @@ -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 }} @@ -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' diff --git a/config/action.yaml b/config/action.yaml index 77f381e..7b2ec03 100644 --- a/config/action.yaml +++ b/config/action.yaml @@ -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: diff --git a/setup/action.yaml b/setup/action.yaml new file mode 100644 index 0000000..8078b54 --- /dev/null +++ b/setup/action.yaml @@ -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'