diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 06f0927..912301f 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -1,46 +1,38 @@ -name: Dart +name: Dart Package on: push: - branches: [ "main" ] + branches: + - main pull_request: - branches: [ "main" ] + branches: + - main jobs: - build: + publish: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - # Setting up the Flutter SDK - - uses: subosito/flutter-action@v2 - with: - flutter-version: '3.22.2' - - - name: Install dependencies - run: flutter pub get - - # Uncomment this step to verify the use of 'dart format' on each commit. - # - name: Verify formatting - # run: flutter format --output=none --set-exit-if-changed . - - # Conditional step for analyzing the project source - #- name: Analyze project source - # if: ${{ secrets.SKIP_ANALYZE != 'true' }} - # run: flutter analyze - - # Run tests - # - name: Run tests - # run: flutter test - - - name: dart-package - uses: nikosportolos/dart_package@v0.2.1 - with: - coverage: false - codecov: false - codecov_token: ${{ secrets.CODECOV_TOKEN }} - publish: true - pubdev_token: ${{ secrets.PUBDEV_TOKEN }} - sdk: flutter - flutter-sdk: '3.22.2' + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Dart + uses: nikosportolos/dart_package@v0.2.1 + with: + sdk: 'stable' + + - name: Install dependencies + run: dart pub get + + - name: Run tests + run: dart test + + - name: Publish to pub.dev (dry run) + env: + PUB_DEV_TOKEN: ${{ secrets.PUB_DEV_TOKEN }} + run: dart pub publish --dry-run + + - name: Publish to pub.dev + if: github.ref == 'refs/heads/main' && github.event_name == 'push' + env: + PUB_DEV_TOKEN: ${{ secrets.PUB_DEV_TOK