5月27日 14:25
What is the deployment and release process for Expo apps? How to use EAS Build?
The deployment and release process of Expo apps is the final step in the development cycle and a key link to ensure successful app launch. Expo provides multiple deployment options, with comprehensive tool support from development testing to production release.
Deployment Process Overview:
- Development Phase: Use Expo Go for rapid iteration
- Testing Phase: Use Development Build for real device testing
- Pre-release Phase: Use EAS Build to generate test versions
- Production Phase: Use EAS Build and Submit to publish to app stores
EAS Build Deployment:
- Configure EAS
bash# Install EAS CLI npm install -g eas-cli # Login to Expo account eas login # Configure project eas build:configure
- Configure eas.json
json{ "cli": { "version": ">= 5.2.0" }, "build": { "development": { "developmentClient": true, "distribution": "internal", "android": { "buildType": "apk" }, "ios": { "simulator": false } }, "preview": { "distribution": "internal", "android": { "buildType": "apk" }, "ios": { "simulator": true } }, "production": { "android": { "buildType": "app-bundle" }, "ios": { "autoIncrement": true } } }, "submit": { "production": { "android": { "serviceAccountKeyPath": "./google-service-account.json", "track": "internal" }, "ios": { "appleId": "your-apple-id@email.com", "ascAppId": "YOUR_APP_STORE_CONNECT_APP_ID", "appleTeamId": "YOUR_TEAM_ID", "skipWorkflow": false } } } }
- Build App
bash# Build development version eas build --profile development --platform android # Build preview version eas build --profile preview --platform ios # Build production version eas build --profile production --platform android # Local build eas build --local --platform android
Android Deployment:
- Prepare Google Play Account
bash# Create Google Play Developer account # Visit https://play.google.com/console
- Configure Google Play Service Account
bash# Create service account # 1. Visit Google Play Console # 2. Go to Settings > API access # 3. Create service account # 4. Download JSON key file # 5. Grant service account permissions
- Submit to Google Play
bash# Submit app eas submit --platform android --latest # Submit specific build eas submit --platform android --build-id BUILD_ID # Specify release track eas submit --platform android --track internal
- Google Play Release Tracks
- Internal: Internal testing (up to 100 testers)
- Alpha: Closed testing (unlimited)
- Beta: Open testing
- Production: Official release
iOS Deployment:
- Prepare Apple Developer Account
bash# Register for Apple Developer Program # Visit https://developer.apple.com/programs/
- Configure Certificates and Provisioning Profiles
bash# Use EAS to automatically manage certificates # Or manually configure: # 1. Create App ID # 2. Create development certificate # 3. Create distribution certificate # 4. Create provisioning profile
- Configure app.json
json{ "expo": { "ios": { "bundleIdentifier": "com.yourcompany.yourapp", "buildNumber": "1", "supportsTablet": true, "infoPlist": { "NSCameraUsageDescription": "Need camera permission", "NSLocationWhenInUseUsageDescription": "Need location permission" } } } }
- Submit to App Store
bash# Submit app eas submit --platform ios --latest # Use TestFlight for testing # 1. Upload to App Store Connect # 2. Add testers # 3. Distribute TestFlight version
OTA Update Deployment:
- Configure Updates
json{ "expo": { "updates": { "url": "https://u.expo.dev/your-project-id" }, "runtimeVersion": { "policy": "appVersion" } } }
- Publish Updates
bash# Create update eas update --branch production --message "Fix bug" # View update history eas update:list # Rollback update eas update:rollback --branch production
Web Deployment:
- Build Web Version
bash# Build production version npx expo export:web # Local preview npx expo start --web
- Deploy to Vercel
bash# Install Vercel CLI npm i -g vercel # Deploy vercel # Production deployment vercel --prod
- Deploy to Netlify
bash# Install Netlify CLI npm i -g netlify-cli # Deploy netlify deploy --prod
Environment Variable Management:
- Configure Environment Variables
bash# Set EAS environment variables eas secret:create --name API_KEY --value "your-api-key" # View environment variables eas secret:list # Delete environment variable eas secret:delete --name API_KEY
- Use in Code
typescript// Access environment variables const API_KEY = process.env.EXPO_PUBLIC_API_KEY; const API_URL = process.env.EXPO_PUBLIC_API_URL;
Version Management:
- Version Number Convention
json{ "expo": { "version": "1.0.0", "ios": { "buildNumber": "1" }, "android": { "versionCode": 1 } } }
- Automated Version Management
bash# Use semantic-release npm install --save-dev semantic-release # Configure .releaserc.json { "branches": ["main"], "plugins": [ "@semantic-release/commit-analyzer", "@semantic-release/release-notes-generator", "@semantic-release/npm", "@semantic-release/github" ] }
CI/CD Integration:
- GitHub Actions Configuration
yamlname: Build and Deploy on: push: branches: [main] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 with: node-version: '18' - run: npm ci - run: npm test - run: eas build --platform android --non-interactive env: EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
- Automated Testing and Deployment
yamlname: CI/CD Pipeline on: push: branches: [main, develop] pull_request: branches: [main] jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - run: npm ci - run: npm test build-android: needs: test runs-on: ubuntu-latest if: github.ref == 'refs/heads/main' steps: - uses: actions/checkout@v2 - run: eas build --platform android --non-interactive env: EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }} build-ios: needs: test runs-on: ubuntu-latest if: github.ref == 'refs/heads/main' steps: - uses: actions/checkout@v2 - run: eas build --platform ios --non-interactive env: EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
Best Practices:
- Version Control: Use semantic versioning
- Automated Testing: Run all tests before deployment
- Gradual Release: Release to test tracks first, then production
- Monitoring and Logging: Monitor app performance and errors after deployment
- Rollback Plan: Prepare quick rollback plan
- Documentation: Record content and changes of each release
Common Issues:
- Build Failures: Check configuration files and dependency versions
- Submission Rejections: Ensure compliance with app store review guidelines
- Updates Not Taking Effect: Check runtime version and update configuration
- Signing Issues: Ensure certificates and provisioning profiles are correctly configured
Through a comprehensive deployment process, you can ensure Expo apps launch successfully and run stably.