|
| 1 | +name: Build, Test, and Deploy |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + workflow_dispatch: # Allows manual triggering |
| 8 | + |
| 9 | +jobs: |
| 10 | + build-and-test: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + steps: |
| 14 | + - name: Checkout code |
| 15 | + uses: actions/checkout@v3 |
| 16 | + |
| 17 | + - name: Set up Node.js |
| 18 | + uses: actions/setup-node@v3 |
| 19 | + with: |
| 20 | + node-version: '18' |
| 21 | + cache: 'npm' |
| 22 | + |
| 23 | + - name: Install dependencies |
| 24 | + run: npm ci |
| 25 | + |
| 26 | + - name: Lint code |
| 27 | + run: npm run lint |
| 28 | + |
| 29 | + - name: Run tests |
| 30 | + run: npm test |
| 31 | + |
| 32 | + - name: Build application |
| 33 | + run: npm run build |
| 34 | + |
| 35 | + - name: Upload production build artifact |
| 36 | + uses: actions/upload-artifact@v3 |
| 37 | + with: |
| 38 | + name: production-build |
| 39 | + path: dist |
| 40 | + |
| 41 | + deploy-android: |
| 42 | + needs: build-and-test |
| 43 | + runs-on: ubuntu-latest |
| 44 | + |
| 45 | + steps: |
| 46 | + - name: Checkout code |
| 47 | + uses: actions/checkout@v3 |
| 48 | + |
| 49 | + - name: Set up Node.js |
| 50 | + uses: actions/setup-node@v3 |
| 51 | + with: |
| 52 | + node-version: '18' |
| 53 | + |
| 54 | + - name: Set up Java |
| 55 | + uses: actions/setup-java@v3 |
| 56 | + with: |
| 57 | + distribution: 'temurin' |
| 58 | + java-version: '17' |
| 59 | + |
| 60 | + - name: Download production build artifact |
| 61 | + uses: actions/download-artifact@v3 |
| 62 | + with: |
| 63 | + name: production-build |
| 64 | + path: dist |
| 65 | + |
| 66 | + - name: Install dependencies |
| 67 | + run: npm ci |
| 68 | + |
| 69 | + - name: Install Capacitor CLI |
| 70 | + run: npm install -g @capacitor/cli |
| 71 | + |
| 72 | + - name: Sync web assets to Android |
| 73 | + run: npx cap sync android |
| 74 | + |
| 75 | + - name: Build Android App Bundle (AAB) |
| 76 | + run: cd android && ./gradlew bundleRelease |
| 77 | + |
| 78 | + - name: Sign Android App Bundle |
| 79 | + uses: r0adkll/sign-android-release@v1 |
| 80 | + with: |
| 81 | + releaseDirectory: android/app/build/outputs/bundle/release |
| 82 | + signingKeyBase64: ${{ secrets.ANDROID_SIGNING_KEY }} |
| 83 | + alias: ${{ secrets.ANDROID_ALIAS }} |
| 84 | + keyStorePassword: ${{ secrets.ANDROID_KEY_STORE_PASSWORD }} |
| 85 | + keyPassword: ${{ secrets.ANDROID_KEY_PASSWORD }} |
| 86 | + # NOTE: This step will fail without the required secrets being set in the repository. |
| 87 | + # These secrets (ANDROID_SIGNING_KEY, ANDROID_ALIAS, etc.) must be created |
| 88 | + # in your GitHub repository settings under "Secrets and variables" > "Actions". |
| 89 | + |
| 90 | + - name: Deploy to Google Play (Internal Testing) |
| 91 | + uses: r0adkll/upload-google-play@v1 |
| 92 | + with: |
| 93 | + serviceAccountJsonPlainText: ${{ secrets.GOOGLE_PLAY_SERVICE_ACCOUNT_JSON }} |
| 94 | + packageName: app.medicompanion.app |
| 95 | + releaseFiles: android/app/build/outputs/bundle/release/app-release.aab |
| 96 | + track: internal |
| 97 | + # NOTE: This step will also fail without the GOOGLE_PLAY_SERVICE_ACCOUNT_JSON secret. |
| 98 | + # This secret contains the JSON key for a Google Cloud service account that has |
| 99 | + # permissions to upload releases to the Google Play Console. |
| 100 | + |
| 101 | + deploy-ios: |
| 102 | + needs: build-and-test |
| 103 | + runs-on: macos-latest |
| 104 | + |
| 105 | + steps: |
| 106 | + - name: Checkout code |
| 107 | + uses: actions/checkout@v3 |
| 108 | + |
| 109 | + - name: Set up Node.js |
| 110 | + uses: actions/setup-node@v3 |
| 111 | + with: |
| 112 | + node-version: '18' |
| 113 | + |
| 114 | + - name: Download production build artifact |
| 115 | + uses: actions/download-artifact@v3 |
| 116 | + with: |
| 117 | + name: production-build |
| 118 | + path: dist |
| 119 | + |
| 120 | + - name: Install dependencies |
| 121 | + run: npm ci |
| 122 | + |
| 123 | + - name: Install Capacitor CLI |
| 124 | + run: npm install -g @capacitor/cli |
| 125 | + |
| 126 | + - name: Sync web assets to iOS |
| 127 | + run: npx cap sync ios |
| 128 | + |
| 129 | + - name: Build and Deploy to TestFlight |
| 130 | + uses: apple-actions/upload-testflight-build@v1 |
| 131 | + with: |
| 132 | + apple-id: ${{ secrets.APPLE_ID }} |
| 133 | + app-specific-password: ${{ secrets.APP_SPECIFIC_PASSWORD }} |
| 134 | + team-id: ${{ secrets.APPLE_TEAM_ID }} |
| 135 | + project-path: "ios/App/App.xcworkspace" |
| 136 | + scheme: "App" |
| 137 | + # The following secrets are base64 encoded certificate and provisioning profile files |
| 138 | + p12-base64: ${{ secrets.IOS_DIST_P12_BASE64 }} |
| 139 | + p12-password: ${{ secrets.IOS_DIST_P12_PASSWORD }} |
| 140 | + mobileprovision-base64: ${{ secrets.IOS_PROVISIONING_PROFILE_BASE64 }} |
| 141 | + # NOTE: This step will fail without the required secrets being set in the repository. |
| 142 | + # These secrets must be created in your GitHub repository settings. This includes |
| 143 | + # your Apple ID, an app-specific password, your team ID, and base64 encoded |
| 144 | + # versions of your distribution certificate (.p12) and provisioning profile. |
0 commit comments