|
| 1 | +name: publish |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + |
| 8 | +jobs: |
| 9 | + |
| 10 | + flutter_test: |
| 11 | + name: ${{ matrix.package }} running analyze and tests |
| 12 | + runs-on: ubuntu-latest |
| 13 | + strategy: |
| 14 | + matrix: |
| 15 | + package: |
| 16 | + - 'mindbox' |
| 17 | + - 'mindbox_android' |
| 18 | + - 'mindbox_ios' |
| 19 | + - 'mindbox_platform_interface' |
| 20 | + fail-fast: false |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v2 |
| 23 | + - uses: actions/setup-java@v1 |
| 24 | + with: |
| 25 | + java-version: "12.x" |
| 26 | + - uses: subosito/flutter-action@v1 |
| 27 | + with: |
| 28 | + channel: "stable" |
| 29 | + - run: cd ${{ matrix.package }} && flutter pub get |
| 30 | + - run: cd ${{ matrix.package }} && flutter analyze |
| 31 | + - run: cd ${{ matrix.package }} && flutter test |
| 32 | + |
| 33 | + publish: |
| 34 | + needs: [flutter_test] |
| 35 | + timeout-minutes: 4 |
| 36 | + runs-on: ubuntu-latest |
| 37 | + name: ${{ matrix.package }} publishing |
| 38 | + strategy: |
| 39 | + matrix: |
| 40 | + package: |
| 41 | + - 'mindbox' |
| 42 | + - 'mindbox_android' |
| 43 | + - 'mindbox_ios' |
| 44 | + - 'mindbox_platform_interface' |
| 45 | + fail-fast: false |
| 46 | + |
| 47 | + steps: |
| 48 | + |
| 49 | + with: |
| 50 | + fetch-depth: 2 |
| 51 | + |
| 52 | + - name: Check package Pubspec |
| 53 | + id: pubspec |
| 54 | + run: | |
| 55 | + set +e |
| 56 | + git diff-tree --no-commit-id --name-only -r ${{ github.sha }} | grep '${{ matrix.package }}/pubspec.yaml' |
| 57 | + echo ::set-output name=changed::$? |
| 58 | + set -e |
| 59 | + - name: Extract package version |
| 60 | + if: steps.pubspec.outputs.changed == 0 |
| 61 | + run: | |
| 62 | + cd ${{ matrix.package }} |
| 63 | + echo "VERSION=$(awk '{if ($1 ~ /^version:/) print $2}' pubspec.yaml)" >> $GITHUB_ENV |
| 64 | + - uses: sakebook/[email protected] |
| 65 | + if: steps.pubspec.outputs.changed == 0 |
| 66 | + with: |
| 67 | + package_directory: ${{ matrix.package }} |
| 68 | + credential: ${{ secrets.PUB_CREDENTIALS }} |
| 69 | + flutter_package: true |
| 70 | + skip_test: true |
| 71 | + - name: Create Release |
| 72 | +# if: steps.pubspec.outputs.changed == 0 |
| 73 | + id: create_release |
| 74 | + |
| 75 | + env: |
| 76 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 77 | + with: |
| 78 | + tag_name: ${{ matrix.package }}-v${{ env.VERSION }} |
| 79 | + release_name: ${{ matrix.package }} v${{ env.VERSION }} |
| 80 | + draft: false |
| 81 | + prerelease: false |
0 commit comments