diff --git a/.fvmrc b/.fvmrc new file mode 100644 index 0000000..e848c2e --- /dev/null +++ b/.fvmrc @@ -0,0 +1,4 @@ +{ + "flutter": "3.3.2", + "flavors": {} +} \ No newline at end of file diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml new file mode 100644 index 0000000..5868cb7 --- /dev/null +++ b/.github/actions/setup/action.yml @@ -0,0 +1,13 @@ +name: Setup Flutter environment and get dependencies + +runs: + using: "composite" + steps: + - name: Install Flutter + uses: kuhnroyal/flutter-fvm-config-action/setup@v3 + - name: Get dependencies + shell: bash + run: flutter pub get + - name: Generate intermediates + shell: bash + run: flutter pub run build_runner build --delete-conflicting-outputs \ No newline at end of file diff --git a/.github/workflows/analyze.yml b/.github/workflows/analyze.yml new file mode 100644 index 0000000..9066b16 --- /dev/null +++ b/.github/workflows/analyze.yml @@ -0,0 +1,15 @@ +name: Run Flutter Analyze + +on: + workflow_call: + +jobs: + analyze: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v5 + - name: Setup Flutter + uses: ./.github/actions/setup + - name: Analyze + run: flutter analyze \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..c73da9c --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,29 @@ +name: Build Artifacts + +on: + workflow_call: + inputs: + platform: + required: true + type: string + +jobs: + build: + runs-on: ${{ inputs.platform == 'linux' && 'ubuntu-latest' || inputs.platform == 'windows' && 'windows-latest' || inputs.platform == 'macos' && 'macos-latest' }} + steps: + - name: Checkout code + uses: actions/checkout@v5 + - name: Install dependencies + if: ${{ inputs.platform == 'linux' }} + run: | + sudo apt-get update -y + sudo apt-get install \ + clang cmake git \ + ninja-build pkg-config \ + libgtk-3-dev liblzma-dev \ + libstdc++-12-dev + - name: Setup Flutter + uses: ./.github/actions/setup + - name: Build Artifacts + working-directory: example/${{ inputs.platform }} + run: flutter build ${{ inputs.platform }} --release \ No newline at end of file diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml new file mode 100644 index 0000000..21f9c6a --- /dev/null +++ b/.github/workflows/default.yml @@ -0,0 +1,41 @@ +name: Pipeline + +on: + pull_request: + push: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + analyze: + name: Analyze + uses: ./.github/workflows/analyze.yml + + test: + name: Testing + uses: ./.github/workflows/test.yml + strategy: + matrix: + platform: [ linux, windows, macos ] + with: + platform: ${{ matrix.platform }} + + build: + name: Build ${{ matrix.platform }} + needs: + - analyze + - test + uses: ./.github/workflows/build.yml + strategy: + matrix: + platform: [ linux, windows, macos ] + with: + platform: ${{ matrix.platform }} + + publish: + name: Publish + needs: + - build + uses: ./.github/workflows/publish.yml \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 2f1144d..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: Flutter CI - -on: push - -jobs: - tests-linux: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v5 - - uses: subosito/flutter-action@v2 - with: - channel: 'stable' - flutter-version: '3.3.2' - - name: Install dependencies - run: flutter pub get - - name: Generate support files - run: flutter pub run build_runner build --delete-conflicting-outputs - - name: Run Linux Tests - run: flutter test test/linux/disks_test.dart - - tests-windows: - runs-on: windows-latest - - steps: - - uses: actions/checkout@v5 - - uses: subosito/flutter-action@v2 - with: - channel: 'stable' - flutter-version: '3.3.2' - - name: Install dependencies - run: flutter pub get - - name: Run Windows Tests - run: flutter test test/windows/disks_test.dart - - tests-macos: - runs-on: macos-latest - - steps: - - uses: actions/checkout@v5 - - uses: subosito/flutter-action@v2 - with: - channel: 'stable' - flutter-version: '3.3.2' - architecture: x64 - - name: Install dependencies - run: flutter pub get - - name: Generate support files - run: flutter pub run build_runner build --delete-conflicting-outputs - - name: Run macOS Tests - run: flutter test test/macos/disks_test.dart \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..d4405de --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,11 @@ +name: Publish Artifacts + +on: + workflow_call: + +jobs: + publish: + if: startsWith(github.ref, 'refs/tags/') + permissions: + id-token: write + uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1 \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..bc0c594 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,19 @@ +name: Run Flutter Tests + +on: + workflow_call: + inputs: + platform: + required: true + type: string + +jobs: + test: + runs-on: ${{ inputs.platform == 'linux' && 'ubuntu-latest' || inputs.platform == 'windows' && 'windows-latest' || inputs.platform == 'macos' && 'macos-latest' }} + steps: + - name: Checkout code + uses: actions/checkout@v5 + - name: Setup Flutter + uses: ./.github/actions/setup + - name: Run Tests + run: flutter test test/${{ inputs.platform }}/disks_test.dart \ No newline at end of file diff --git a/README.md b/README.md index 73f3f44..d37d9ac 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Disks Desktop is Flutter desktop library able to retrieve the installed devices information [![Pub](https://img.shields.io/pub/v/disks_desktop.svg)](https://pub.dev/packages/disks_desktop) -![Flutter CI](https://github.com/AngeloAvv/disks/workflows/Flutter%20CI/badge.svg) +![Flutter CI](https://github.com/AngeloAvv/disks/workflows/Pipeline/badge.svg) [![Star on GitHub](https://img.shields.io/github/stars/AngeloAvv/disks.svg?style=flat&logo=github&colorB=deeppink&label=stars)](https://github.com/AngeloAvv/disks) [![License: MIT](https://img.shields.io/badge/license-MIT-purple.svg)](https://opensource.org/licenses/MIT)