diff --git a/.github/workflows/license_check.yml b/.github/workflows/license_check.yml index e21db54..d4d7d48 100644 --- a/.github/workflows/license_check.yml +++ b/.github/workflows/license_check.yml @@ -12,9 +12,13 @@ on: type: string default: "ubuntu-latest" dart_sdk: + description: 'Dart SDK to use when no flutter_version is specified' + required: false + type: string + flutter_version: + description: 'Flutter SDK version to use' required: false type: string - default: "stable" allowed: required: false type: string @@ -46,15 +50,39 @@ jobs: working-directory: ${{inputs.working_directory}} runs-on: ${{inputs.runs_on}} + env: + USE_FLUTTER: ${{ inputs.flutter_version != '' }} + USE_DART: ${{ inputs.flutter_version == '' }} + SHOW_DART_FLUTTER_WARNING: ${{ inputs.flutter_version != '' && inputs.dart_sdk != '' }} steps: - name: 📚 Git Checkout uses: actions/checkout@v5 - - name: 🎯 Setup Dart + - name: Show warning if conflicting SDK inputs + if: ${{ env.SHOW_DART_FLUTTER_WARNING == 'true' }} + run: echo "::warning::Both 'flutter_version' and 'dart_sdk' were specified. The workflow will proceed with the Flutter SDK setup." + + - name: Set Dart SDK Version + if: ${{ env.USE_DART == 'true' }} + id: set_dart_version + run: | + echo "dart_sdk_version=${{ inputs.dart_sdk || 'stable' }}" >> $GITHUB_OUTPUT + + - name: 🦋Set up Flutter + if: ${{ env.USE_FLUTTER == 'true' }} + uses: subosito/flutter-action@v2 + with: + flutter-version: ${{inputs.flutter_version}} + cache: true + cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }} + + - name: 🎯 Set up Dart + if: ${{ env.USE_DART == 'true' }} uses: dart-lang/setup-dart@v1 with: - sdk: ${{inputs.dart_sdk}} + sdk: ${{steps.set_dart_version.outputs.dart_sdk_version}} + - name: 🤫 Set SSH Key env: @@ -64,10 +92,15 @@ jobs: with: ssh-private-key: ${{secrets.ssh_key}} - - name: 📦 Install Dependencies + - name: 📦 Install Dependencies for Flutter + if: ${{ env.USE_FLUTTER == 'true' }} + run: flutter pub get --no-example + + - name: 📦 Install Dependencies for Dart + if: ${{ env.USE_DART == 'true' }} run: dart pub get --no-example - name: 👨‍⚖️ Check licenses run: | dart pub global activate very_good_cli - dart pub global run very_good_cli:very_good packages check licenses --skip-packages=${{inputs.skip_packages}} --dependency-type=${{inputs.dependency_type}} ${{(inputs.ignore_retrieval_failures && '--ignore-retrieval-failures') || ''}} --allowed=${{inputs.allowed}} --forbidden=${{inputs.forbidden}} + dart pub global run very_good_cli:very_good packages check licenses --skip-packages=${{inputs.skip_packages}} --dependency-type=${{inputs.dependency_type}} ${{(inputs.ignore_retrieval_failures && '--ignore-retrieval-failures') || ''}} --allowed=${{inputs.allowed}} --forbidden=${{inputs.forbidden}} \ No newline at end of file diff --git a/site/docs/workflows/license_check.md b/site/docs/workflows/license_check.md index 4dfc593..a0601b3 100644 --- a/site/docs/workflows/license_check.md +++ b/site/docs/workflows/license_check.md @@ -35,10 +35,16 @@ The License Check workflow consists of the following steps: ### `dart_sdk` -**Optional** Which Dart SDK version to use. It can be a version (e.g. `3.5.0`) or a channel (e.g. `stable`): +**Optional** Which Dart SDK version to use. It can be a version (e.g. `3.5.0`) or a channel (e.g. `stable`). This parameter is ignored if a flutter_version is specified. **Default** `"stable"` +### `flutter_version` + +**Optional** Which Flutter SDK version to use. + +**Default** `""` + ### `allowed` **Optional** Only allow the use of certain licenses. The expected format is a comma-separated list. @@ -104,7 +110,8 @@ jobs: license_check: uses: VeryGoodOpenSource/very_good_workflows/.github/workflows/license_check.yml@v1 with: - allowed: 'MIT,BSD-3-Clause,BSD-2-Clause,Apache-2.0' + flutter_version: '3.32.0' + allowed: 'MIT,BSD-3-Clause,BSD-2-Clause,Apache-2.0,Zlib' ``` The example [workflow file](https://docs.github.com/en/actions/quickstart#creating-your-first-workflow) will [trigger](https://docs.github.com/en/actions/using-workflows/triggering-a-workflow) the `license_check` job on every push to the `main` branch and on every pull request that modifies the `pubspec.yaml` or the `license_check.yaml` workflow file.