|
| 1 | +# Deployment Guide |
| 2 | + |
| 3 | +This document outlines the process for building, testing, and deploying the CardSnap to various platforms. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The CardSnap uses GitHub Actions for continuous integration and deployment. This guide covers: |
| 8 | + |
| 9 | +- Local development setup |
| 10 | +- Building and testing locally |
| 11 | +- CI/CD pipeline details |
| 12 | +- Release processes |
| 13 | + |
| 14 | +## Local Development Setup |
| 15 | + |
| 16 | +### Prerequisites |
| 17 | + |
| 18 | +1. Node.js (v18 or later) |
| 19 | +2. JDK 17 (for Android builds) |
| 20 | +3. Xcode (for iOS builds - requires macOS) |
| 21 | +4. CocoaPods (for iOS dependencies) |
| 22 | +5. Android Studio & Android SDK (for Android builds) |
| 23 | + |
| 24 | +### Installation |
| 25 | + |
| 26 | +```bash |
| 27 | +# Install JavaScript dependencies |
| 28 | +npm install |
| 29 | + |
| 30 | +# Install iOS dependencies (macOS only) |
| 31 | +cd ios && pod install && cd .. |
| 32 | +``` |
| 33 | + |
| 34 | +## Local Building and Testing |
| 35 | + |
| 36 | +### Running Tests |
| 37 | + |
| 38 | +```bash |
| 39 | +# Run all tests |
| 40 | +npm test |
| 41 | + |
| 42 | +# Run tests in watch mode |
| 43 | +npm test -- --watch |
| 44 | + |
| 45 | +# Run specific test file |
| 46 | +npx jest src/screens/ScannerScreen.test.tsx |
| 47 | + |
| 48 | +# Run tests with coverage |
| 49 | +npm test -- --coverage |
| 50 | +``` |
| 51 | + |
| 52 | +### Linting |
| 53 | + |
| 54 | +```bash |
| 55 | +# Run ESLint on entire project |
| 56 | +npm run lint |
| 57 | + |
| 58 | +# Run ESLint on specific files/directories |
| 59 | +npx eslint src/screens/ScannerScreen.tsx |
| 60 | +npx eslint src/utils/ |
| 61 | +``` |
| 62 | + |
| 63 | +### Building Applications |
| 64 | + |
| 65 | +#### Android Debug Build |
| 66 | + |
| 67 | +```bash |
| 68 | +npm run build:android |
| 69 | +# Output: android/app/build/outputs/apk/debug/app-debug.apk |
| 70 | +``` |
| 71 | + |
| 72 | +#### iOS Debug Build (macOS only) |
| 73 | + |
| 74 | +```bash |
| 75 | +npm run build:ios |
| 76 | +# Output: ios/build/Debug-iphonesimulator/CardSnap.app |
| 77 | +``` |
| 78 | + |
| 79 | +#### Running on Devices/Emulators |
| 80 | + |
| 81 | +```bash |
| 82 | +# Run on Android emulator/device |
| 83 | +npm run android |
| 84 | + |
| 85 | +# Run on iOS simulator (macOS only) |
| 86 | +npm run ios |
| 87 | +``` |
| 88 | + |
| 89 | +## CI/CD Pipeline |
| 90 | + |
| 91 | +The project uses GitHub Actions for continuous integration. The workflow is defined in `.github/workflows/ci.yml`. |
| 92 | + |
| 93 | +### Workflow Triggers |
| 94 | + |
| 95 | +- Push to `main` branch |
| 96 | +- Pull requests targeting `main` branch |
| 97 | + |
| 98 | +### Workflow Jobs |
| 99 | + |
| 100 | +1. **Checkout**: Retrieves the repository code |
| 101 | +2. **Setup**: Configures Node.js (v18) and Java (JDK 17) |
| 102 | +3. **Dependencies**: Installs npm packages and iOS pods (on macOS) |
| 103 | +4. **Linting**: Runs ESLint to check code quality |
| 104 | +5. **Testing**: Executes Jest test suite |
| 105 | +6. **Building**: |
| 106 | + - Android: Builds debug APK using Gradle |
| 107 | + - iOS: Builds debugger simulator app using xcodebuild (macOS only) |
| 108 | +7. **Artifacts**: Uploads build artifacts for download |
| 109 | + |
| 110 | +### Accessing Build Artifacts |
| 111 | + |
| 112 | +After a workflow run completes: |
| 113 | + |
| 114 | +1. Go to the "Actions" tab in your GitHub repository |
| 115 | +2. Click on the specific workflow run |
| 116 | +3. Scroll down to "Artifacts" section |
| 117 | +4. Download the Android APK or iOS app artifacts |
| 118 | + |
| 119 | +## Release Process |
| 120 | + |
| 121 | +### Preparing for Release |
| 122 | + |
| 123 | +1. Ensure all tests pass on the `main` branch |
| 124 | +2. Update version numbers in: |
| 125 | + - `package.json` (for npm version) |
| 126 | + - `android/app/build.gradle` (versionName and versionCode) |
| 127 | + - `ios/CardSnap/Info.plist` (CFBundleShortVersionString and CFBundleVersion) |
| 128 | +3. Create a git tag for the release: |
| 129 | + ```bash |
| 130 | + git tag -a v1.0.0 -m "Release version 1.0.0" |
| 131 | + git push origin v1.0.0 |
| 132 | + ``` |
| 133 | + |
| 134 | +### Generating Production Builds |
| 135 | + |
| 136 | +#### Android Release Build |
| 137 | + |
| 138 | +```bash |
| 139 | +cd android |
| 140 | +./gradlew assembleRelease |
| 141 | +# Output: android/app/build/outputs/apk/release/app-release.apk |
| 142 | +``` |
| 143 | + |
| 144 | +#### iOS Release Build (macOS only) |
| 145 | + |
| 146 | +```bash |
| 147 | +xcodebuild -workspace ios/CardSnap.xcworkspace -scheme CardSnap \ |
| 148 | + -configuration Release -sdk iphoneos -archivePath ios/build/CardSnap.xcarchive archive |
| 149 | +xcodebuild -exportArchive -archivePath ios/build/CardSnap.xcarchive \ |
| 150 | + -exportOptionsPlist ios/ExportOptions.plist -exportPath ios/build |
| 151 | +``` |
| 152 | + |
| 153 | +## Troubleshooting |
| 154 | + |
| 155 | +### Common Android Build Issues |
| 156 | + |
| 157 | +1. **Java Version Conflicts** |
| 158 | + |
| 159 | + - Ensure JDK 17 is installed and set as JAVA_HOME |
| 160 | + - Clean build: `cd android && ./gradlew clean` |
| 161 | + |
| 162 | +2. **AndroidX Issues** |
| 163 | + - Refer to `docs/BUILD_SUMMARY.md` for known issues and workarounds |
| 164 | + - Ensure proper resolution strategies in `android/build.gradle` |
| 165 | + |
| 166 | +### Common iOS Build Issues |
| 167 | + |
| 168 | +1. **CocoaPods Issues** |
| 169 | + |
| 170 | + - Delete Pods folder and Podfile.lock, then run `pod install` again |
| 171 | + - Update CocoaPods: `sudo gem install cocoapods` |
| 172 | + |
| 173 | +2. **Code Signing Issues** |
| 174 | + - Ensure proper development team is set in Xcode project settings |
| 175 | + - For CI builds, use a simulator destination to avoid code signing requirements |
| 176 | + |
| 177 | +## Environment Variables for CI |
| 178 | + |
| 179 | +The following environment variables are used in the GitHub Actions workflow: |
| 180 | + |
| 181 | +- `NODE_VERSION`: Node.js version to use (default: 18.x) |
| 182 | +- `JAVA_VERSION`: Java version to use (default: 17) |
| 183 | + |
| 184 | +These can be overridden in the workflow file if needed. |
| 185 | + |
| 186 | +## Security Considerations |
| 187 | + |
| 188 | +1. Never commit sensitive information (API keys, credentials) to the repository |
| 189 | +2. Use GitHub Secrets for storing sensitive data needed in CI/CD workflows |
| 190 | +3. Regularly update dependencies to address security vulnerabilities |
| 191 | +4. Consider implementing Firebase App Distribution or TestFlight for beta distribution |
0 commit comments