added publish-to-pubdev pipeline #7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Pre-merge checks | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| - master | |
| push: | |
| branches: | |
| - main | |
| - master | |
| jobs: | |
| test-publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Checkout repository | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| # Set up Flutter | |
| - name: Set up Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| flutter-version: '3.29.0' # Specify exact version instead of just 'stable' | |
| channel: 'stable' | |
| # Cache Flutter dependencies to speed up workflow | |
| - name: Cache Flutter dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.pub-cache | |
| key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pub- | |
| # Install dependencies | |
| - name: Install dependencies | |
| run: flutter pub get | |
| # Run tests | |
| - name: Run tests | |
| run: flutter test | |
| # Static code analysis | |
| - name: Analyze code | |
| run: flutter analyze --no-fatal-warnings | |
| # Verify package format is correct | |
| - name: Format check | |
| run: dart format --set-exit-if-changed . | |
| # Verify package | |
| - name: Verify package | |
| run: flutter pub publish --dry-run | |
| # Check if package can be published | |
| - name: Check publication readiness | |
| run: | | |
| ISSUES=$(flutter pub publish --dry-run 2>&1 | grep -i "error\|warning" || true) | |
| if [ ! -z "$ISSUES" ]; then | |
| echo "Publication issues found:" | |
| echo "$ISSUES" | |
| echo "Please fix these issues before merging." | |
| exit 1 | |
| else | |
| echo "Package is ready for publication! ✅" | |
| fi |