From b57c41b9e7b7b16693e963ec791f0baa8e72768f Mon Sep 17 00:00:00 2001 From: Sri Date: Wed, 25 Jun 2025 12:29:55 -0700 Subject: [PATCH 1/4] added new publishing steps --- .github/workflows/ci.yml | 99 ++++++++++++++++++++++++++++------- .github/workflows/publish.yml | 56 +++----------------- README.md | 3 ++ RELEASE.md | 49 ++++++++++------- test/vapi_test.dart | 19 +++++++ 5 files changed, 138 insertions(+), 88 deletions(-) create mode 100644 test/vapi_test.dart diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0ecd8f6..9c3ed3e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,35 +2,98 @@ name: CI on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] jobs: test: - runs-on: ubuntu-latest - + name: Test on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + include: + - os: ubuntu-latest + flutter_path: /opt/hostedtoolcache/flutter + - os: macos-latest + flutter_path: /Users/runner/hostedtoolcache/flutter + - os: windows-latest + flutter_path: C:\hostedtoolcache\windows\flutter + steps: - - name: Checkout code - uses: actions/checkout@v4 - + - uses: actions/checkout@v4 + - name: Setup Flutter uses: subosito/flutter-action@v2 with: flutter-version: '3.27.0' channel: 'stable' - + - name: Install dependencies run: flutter pub get - - - name: Analyze code + + - name: Verify formatting + run: dart format --output=none --set-exit-if-changed . + + - name: Analyze project source run: flutter analyze - - # - name: Run tests - # run: flutter test - - - name: Check formatting - run: dart format --set-exit-if-changed . - - - name: Check publish readiness + + - name: Run tests + run: flutter test + + - name: Check pub score + run: | + dart pub global activate pana + dart pub global run pana --no-warning --exit-code-threshold 0 + + example: + name: Build example app + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: '3.27.0' + channel: 'stable' + + - name: Install dependencies (root) + run: flutter pub get + + - name: Install dependencies (example) + run: | + cd example + flutter pub get + + - name: Build Android APK + run: | + cd example + flutter build apk --debug + + - name: Build iOS (simulator only) + if: matrix.os == 'macos-latest' + run: | + cd example + flutter build ios --debug --simulator + + publish-dry-run: + name: Publish dry run + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: '3.27.0' + channel: 'stable' + + - name: Install dependencies + run: flutter pub get + + - name: Publish dry run run: flutter pub publish --dry-run diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index a445b75..a62a26c 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,56 +1,12 @@ name: Publish to pub.dev on: - release: - types: [published] + push: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+*' jobs: publish: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup Flutter - uses: subosito/flutter-action@v2 - with: - flutter-version: '3.27.0' - channel: 'stable' - - - name: Verify version consistency - run: | - # Extract version from pubspec.yaml - PUBSPEC_VERSION=$(grep '^version: ' pubspec.yaml | sed 's/version: //') - # Remove 'v' prefix from tag if present - TAG_VERSION=${GITHUB_REF_NAME#v} - - echo "Tag version: $TAG_VERSION" - echo "Pubspec version: $PUBSPEC_VERSION" - - if [ "$TAG_VERSION" != "$PUBSPEC_VERSION" ]; then - echo "Error: Tag version ($TAG_VERSION) does not match pubspec.yaml version ($PUBSPEC_VERSION)" - echo "Please ensure your tag matches the version in pubspec.yaml" - exit 1 - fi - - echo "✓ Version check passed!" - - - name: Install dependencies - run: flutter pub get - - - name: Setup Dart credentials - run: | - mkdir -p ~/.pub-cache - echo '${{ secrets.PUB_CREDENTIALS }}' > ~/.pub-cache/credentials.json - - - name: Verify package scores - run: | - echo "Running package verification..." - flutter pub publish --dry-run - - - name: Publish to pub.dev - run: | - # Using --force because this runs in CI without user interaction - # The dry-run above ensures the package is valid before publishing - flutter pub publish --force + permissions: + id-token: write # Required for authentication using OIDC + uses: dart-lang/setup-dart/.github/workflows/publish.yml@v1 diff --git a/README.md b/README.md index 3637e22..094cf3a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # Vapi Flutter SDK +[![CI](https://github.com/VapiAI/vapi-client-sdk-flutter/actions/workflows/ci.yml/badge.svg)](https://github.com/VapiAI/vapi-client-sdk-flutter/actions/workflows/ci.yml) +[![pub package](https://img.shields.io/pub/v/vapi.svg)](https://pub.dev/packages/vapi) + ## Minimum requirements ### Mobile diff --git a/RELEASE.md b/RELEASE.md index 7660f24..aa8a3e4 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -4,19 +4,16 @@ This guide explains how to release new versions of the Vapi Flutter SDK to pub.d ## Initial Setup (One-time) -### 1. Get pub.dev credentials +### Enable Automated Publishing on pub.dev -```bash -./scripts/get_pub_credentials.sh -``` - -If not logged in yet: `flutter pub login` +1. Go to [pub.dev](https://pub.dev) and sign in +2. Navigate to your package page +3. Go to the **Admin** tab +4. Under **Automated Publishing**, click **Enable publishing from GitHub Actions** +5. Enter your repository: `/` +6. Set tag pattern: `v{{version}}` -### 2. Add to GitHub Secrets - -1. Go to Settings → Secrets and variables → Actions -2. Add new secret: `PUB_CREDENTIALS` -3. Paste the JSON content from step 1 +**Note:** You must be a verified publisher or have uploader permissions on the package. ## Release Process @@ -58,24 +55,36 @@ git commit -m "chore: bump version to 0.2.0" git push origin main ``` -### 4. Create GitHub Release +### 4. Create and push tag -1. Go to Releases → Create a new release -2. Create tag: `v0.2.0` (with 'v' prefix) -3. Title: `v0.2.0` -4. Copy notes from CHANGELOG.md -5. Publish release +```bash +# Create tag matching the version +git tag v0.2.0 -The GitHub Action will automatically publish to pub.dev. +# Push the tag to trigger publishing +git push origin v0.2.0 +``` + +The GitHub Action will automatically publish to pub.dev using OIDC authentication. ### 5. Monitor Check the Actions tab for the "Publish to pub.dev" workflow status. +### 6. Create GitHub Release (Optional) + +After successful publishing, you can create a GitHub release: + +1. Go to Releases → Create a new release +2. Choose existing tag: `v0.2.0` +3. Title: `v0.2.0` +4. Copy notes from CHANGELOG.md +5. Publish release + ## Troubleshooting -- **Tests failing**: Fix and create new release -- **Credentials issue**: Verify `PUB_CREDENTIALS` secret +- **Workflow not triggering**: Ensure tag matches pattern `v{{version}}` +- **Authentication failed**: Verify automated publishing is enabled on pub.dev - **Version conflict**: Ensure version bump in pubspec.yaml - **Manual fallback**: `flutter pub publish` diff --git a/test/vapi_test.dart b/test/vapi_test.dart new file mode 100644 index 0000000..53bcaac --- /dev/null +++ b/test/vapi_test.dart @@ -0,0 +1,19 @@ +import 'package:flutter_test/flutter_test.dart'; +import 'package:vapi/vapi.dart'; + +void main() { + group('VapiClient', () { + test('can be instantiated with public key', () { + expect(() => VapiClient('test-public-key'), returnsNormally); + }); + + test('platformInitialized completes', () async { + // This should complete immediately on mobile platforms + // and after SDK loads on web + await expectLater( + VapiClient.platformInitialized.future, + completes, + ); + }); + }); +} From 603dab35b4ea3bee5ee79bf1e98d4560c6932793 Mon Sep 17 00:00:00 2001 From: Sri Date: Wed, 25 Jun 2025 12:37:29 -0700 Subject: [PATCH 2/4] updated score threshold --- .github/workflows/ci.yml | 9 ++++++++- pubspec.yaml | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9c3ed3e..e04d269 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,7 +45,14 @@ jobs: - name: Check pub score run: | dart pub global activate pana - dart pub global run pana --no-warning --exit-code-threshold 0 + export PATH="$PATH:$HOME/.pub-cache/bin" + # Allow for 10 point deduction due to dependency constraints + # (permission_handler is constrained by daily_flutter) + echo "Running pana analysis..." + pana --no-warning --exit-code-threshold 10 | tee pana-output.txt + echo "" + echo "Note: permission_handler is constrained to ^11.3.1 by daily_flutter 0.31.0" + echo "This causes a 10-point deduction in the pub score." example: name: Build example app diff --git a/pubspec.yaml b/pubspec.yaml index 868144c..7569962 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -19,6 +19,8 @@ dependencies: # Mobile-specific dependencies daily_flutter: ^0.31.0 + # Note: permission_handler is constrained by daily_flutter 0.31.0 + # which requires ^11.3.1. Update when daily_flutter supports ^12.0.0 permission_handler: ^11.3.1 # Web-specific dependencies From 21c44b313bfb94c97b6748502f5a60d480751240 Mon Sep 17 00:00:00 2001 From: Sri Date: Wed, 25 Jun 2025 12:42:20 -0700 Subject: [PATCH 3/4] added local script to test ci --- RELEASE.md | 24 ++++++-- scripts/run_checks.sh | 132 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 152 insertions(+), 4 deletions(-) create mode 100755 scripts/run_checks.sh diff --git a/RELEASE.md b/RELEASE.md index aa8a3e4..97d9ef5 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -47,7 +47,23 @@ version: 0.2.0 # Update accordingly - Renamed method `oldName()` to `newName()` ``` -### 3. Commit and push +### 3. Run validation checks + +Before committing, ensure all checks pass locally: + +```bash +./scripts/run_checks.sh +``` + +This script runs the same checks as CI: + +- Code formatting +- Static analysis +- Unit tests +- pub.dev score check +- Package validation + +### 4. Commit and push ```bash git add pubspec.yaml CHANGELOG.md @@ -55,7 +71,7 @@ git commit -m "chore: bump version to 0.2.0" git push origin main ``` -### 4. Create and push tag +### 5. Create and push tag ```bash # Create tag matching the version @@ -67,11 +83,11 @@ git push origin v0.2.0 The GitHub Action will automatically publish to pub.dev using OIDC authentication. -### 5. Monitor +### 6. Monitor Check the Actions tab for the "Publish to pub.dev" workflow status. -### 6. Create GitHub Release (Optional) +### 7. Create GitHub Release (Optional) After successful publishing, you can create a GitHub release: diff --git a/scripts/run_checks.sh b/scripts/run_checks.sh new file mode 100755 index 0000000..b475889 --- /dev/null +++ b/scripts/run_checks.sh @@ -0,0 +1,132 @@ +#!/bin/bash + +# run_checks.sh - Validate package before release +# +# This script runs all the same checks as the GitHub Actions CI workflow. +# Run this before committing changes or creating a release to ensure +# your code will pass CI. +# +# Usage: ./scripts/run_checks.sh + +set -e # Exit on error + +echo "🔍 Running CI checks locally..." +echo "" + +# 1. Install dependencies +echo "📦 Installing dependencies..." +flutter pub get +cd example && flutter pub get && cd .. +echo "✅ Dependencies installed" +echo "" + +# 2. Format check +echo "🎨 Checking code formatting..." +if dart format --output=none --set-exit-if-changed .; then + echo "✅ Code formatting is correct" +else + echo "❌ Code formatting issues found. Run 'dart format .' to fix" + exit 1 +fi +echo "" + +# 3. Analyze +echo "🔎 Running static analysis..." +if flutter analyze; then + echo "✅ Static analysis passed" +else + echo "❌ Static analysis failed" + exit 1 +fi +echo "" + +# 4. Run tests +echo "🧪 Running tests..." +if flutter test; then + echo "✅ All tests passed" +else + echo "❌ Tests failed" + exit 1 +fi +echo "" + +# 5. Check pub score +echo "📊 Checking pub.dev score with pana..." +if ! command -v pana &> /dev/null; then + echo "Installing pana..." + dart pub global activate pana +fi + +# Add pub-cache to PATH +export PATH="$PATH:$HOME/.pub-cache/bin" + +echo "Running pana analysis..." +pana --no-warning | tee pana-output.txt + +# Check the score +SCORE=$(grep "Points:" pana-output.txt | awk '{print $2}' | cut -d'/' -f1) +MAX_SCORE=$(grep "Points:" pana-output.txt | awk '{print $2}' | cut -d'/' -f2 | cut -d'.' -f1) + +if [ -z "$SCORE" ]; then + echo "❌ Could not determine pub score" + exit 1 +fi + +EXPECTED_DEDUCTION=10 +EXPECTED_MIN_SCORE=$((MAX_SCORE - EXPECTED_DEDUCTION)) + +echo "" +echo "Score: $SCORE/$MAX_SCORE" +echo "Expected minimum: $EXPECTED_MIN_SCORE (allowing $EXPECTED_DEDUCTION points for dependency constraints)" + +if [ "$SCORE" -ge "$EXPECTED_MIN_SCORE" ]; then + echo "✅ Pub score check passed" + echo "" + echo "Note: permission_handler is constrained to ^11.3.1 by daily_flutter 0.31.0" + echo "This causes a 10-point deduction in the pub score." +else + echo "❌ Pub score is too low: $SCORE/$MAX_SCORE (minimum: $EXPECTED_MIN_SCORE)" + exit 1 +fi +echo "" + +# 6. Dry run publish +echo "📤 Running publish dry run..." +if flutter pub publish --dry-run; then + echo "✅ Package is ready to publish" +else + echo "❌ Package validation failed" + exit 1 +fi +echo "" + +# 7. Build example (optional) +read -p "Do you want to build the example app? (y/N) " -n 1 -r +echo "" +if [[ $REPLY =~ ^[Yy]$ ]]; then + echo "🏗️ Building example app..." + cd example + + # Detect platform + if [[ "$OSTYPE" == "darwin"* ]]; then + echo "Building for iOS simulator..." + flutter build ios --debug --simulator + else + echo "Building for Android..." + flutter build apk --debug + fi + + cd .. + echo "✅ Example app built successfully" +fi + +echo "" +echo "🎉 All CI checks passed locally!" +echo "" +echo "Next steps:" +echo "1. Commit your changes: git add . && git commit -m 'your message'" +echo "2. Push to GitHub: git push origin your-branch" +echo "3. Create a PR to trigger the full CI pipeline" + +# Clean up +rm -f pana-output.txt \ No newline at end of file From cc345d594612a77235cf1a1e3429adc9ce7a0c67 Mon Sep 17 00:00:00 2001 From: Sri Date: Wed, 25 Jun 2025 12:45:07 -0700 Subject: [PATCH 4/4] fix windows --- .github/workflows/ci.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e04d269..f72bf52 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,11 +45,8 @@ jobs: - name: Check pub score run: | dart pub global activate pana - export PATH="$PATH:$HOME/.pub-cache/bin" - # Allow for 10 point deduction due to dependency constraints - # (permission_handler is constrained by daily_flutter) echo "Running pana analysis..." - pana --no-warning --exit-code-threshold 10 | tee pana-output.txt + dart pub global run pana --no-warning --exit-code-threshold 10 echo "" echo "Note: permission_handler is constrained to ^11.3.1 by daily_flutter 0.31.0" echo "This causes a 10-point deduction in the pub score."