|
| 1 | +--- |
| 2 | +name: Flutter CI |
| 3 | +on: push |
| 4 | + |
| 5 | +jobs: |
| 6 | + build: |
| 7 | + runs-on: ${{ matrix.os }} |
| 8 | + strategy: |
| 9 | + fail-fast: false |
| 10 | + matrix: |
| 11 | + include: |
| 12 | + - os: macos-12 |
| 13 | + - os: ubuntu-20.04 |
| 14 | + |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v3 |
| 17 | + |
| 18 | + - name: Cache Flutter dependencies |
| 19 | + uses: actions/cache@v3 |
| 20 | + with: |
| 21 | + path: /opt/hostedtoolcache/flutter |
| 22 | + key: ${{ runner.os }}-flutter |
| 23 | + restore-keys: ${{ runner.os }}-flutter |
| 24 | + |
| 25 | + - name: Install llvm |
| 26 | + if: contains(runner.os, 'Linux') |
| 27 | + run: sudo apt install libclang-dev llvm |
| 28 | + |
| 29 | + - uses: subosito/flutter-action@v2 |
| 30 | + with: |
| 31 | + flutter-version: 3.3.4 |
| 32 | + channel: stable |
| 33 | + |
| 34 | + - uses: actions/setup-python@v3 |
| 35 | + with: |
| 36 | + python-version: 3.7 |
| 37 | + |
| 38 | + - run: flutter pub get |
| 39 | + - run: python scripts/get_native_libraries.py |
| 40 | + |
| 41 | + - name: Check build Android |
| 42 | + if: contains(runner.os, 'Linux') |
| 43 | + run: | |
| 44 | + cd example |
| 45 | + flutter build apk |
| 46 | + cd .. |
| 47 | +
|
| 48 | + - name: Check build iOS |
| 49 | + if: contains(runner.os, 'macOS') |
| 50 | + run: | |
| 51 | + cd example |
| 52 | + flutter build ios --release --no-codesign |
| 53 | + cd .. |
| 54 | +
|
| 55 | + - run: flutter analyze . |
| 56 | + - run: flutter test --concurrency 1 -x redis # exclude redis tests (no docker for macos) |
| 57 | + env: |
| 58 | + REDIS_HOST: redis |
| 59 | + REDIS_PORT: 6379 |
| 60 | + |
| 61 | + - run: dart benchmark/cloudproof_benchmark.dart |
| 62 | + |
| 63 | + - name: Dart publish dry run |
| 64 | + if: contains(runner.os, 'Linux') |
| 65 | + run: | |
| 66 | + mkdir -p ~/.config/dart |
| 67 | + echo "$DART_CREDENTIALS" > ~/.config/dart/pub-credentials.json |
| 68 | + rm -f android/src/main/jniLibs/*/.git* |
| 69 | + rm -f ios/.gitignore |
| 70 | + rm -f resources/.gitignore |
| 71 | + rm -f lib/src/.gitignore |
| 72 | + git add * || true |
| 73 | + dart pub publish --dry-run |
| 74 | + env: |
| 75 | + DART_CREDENTIALS: ${{ secrets.DART_CREDENTIALS }} |
| 76 | + |
| 77 | + - name: Dart publish |
| 78 | + if: contains(runner.os, 'Linux') && startsWith(github.ref, 'refs/tags/') |
| 79 | + run: | |
| 80 | + mkdir -p ~/.config/dart |
| 81 | + echo "$DART_CREDENTIALS" > ~/.config/dart/pub-credentials.json |
| 82 | + rm -f android/src/main/jniLibs/*/.git* |
| 83 | + rm -f ios/.gitignore |
| 84 | + rm -f resources/.gitignore |
| 85 | + rm -f lib/src/.gitignore |
| 86 | + git add * || true |
| 87 | + dart pub publish -f |
| 88 | + env: |
| 89 | + DART_CREDENTIALS: ${{ secrets.DART_CREDENTIALS }} |
| 90 | + |
| 91 | + - name: Verify package import from internet |
| 92 | + continue-on-error: true |
| 93 | + if: contains(runner.os, 'Linux') && startsWith(github.ref, 'refs/tags/') |
| 94 | + run: | |
| 95 | + cp -r example /tmp/flutter_example |
| 96 | + cd /tmp/flutter_example |
| 97 | + sed -i "s/cloudproof:/cloudproof: ${REF_NAME:1}/" pubspec.yaml |
| 98 | + sed -i "s/path: ..//" pubspec.yaml |
| 99 | + flutter pub get |
| 100 | + flutter build apk |
| 101 | + env: |
| 102 | + REF_NAME: ${{ github.ref_name }} |
| 103 | + |
| 104 | + release: |
| 105 | + needs: |
| 106 | + - build |
| 107 | + name: release |
| 108 | + runs-on: ubuntu-latest |
| 109 | + steps: |
| 110 | + - uses: actions/checkout@v1 |
| 111 | + - name: Release |
| 112 | + if: startsWith(github.ref, 'refs/tags/') |
| 113 | + uses: softprops/action-gh-release@v1 |
| 114 | + |
| 115 | + cleanup: |
| 116 | + needs: |
| 117 | + - release |
| 118 | + uses: Cosmian/reusable_workflows/.github/workflows/cleanup_cache.yml@main |
| 119 | + secrets: inherit |
0 commit comments