|
45 | 45 |
|
46 | 46 | - name: Initialize Capacitor (if not exists) |
47 | 47 | run: | |
48 | | - if [ ! -d "android" ] && [ ! -f "capacitor.config.json" ] && [ ! -f "capacitor.config.ts" ]; then |
| 48 | + # Check if Capacitor is already configured by looking for config file |
| 49 | + CAPACITOR_CONFIG="" |
| 50 | + if [ -f "capacitor.config.json" ]; then |
| 51 | + CAPACITOR_CONFIG="capacitor.config.json" |
| 52 | + elif [ -f "capacitor.config.ts" ]; then |
| 53 | + CAPACITOR_CONFIG="capacitor.config.ts" |
| 54 | + fi |
| 55 | + |
| 56 | + # Initialize only if no config exists AND no android directory |
| 57 | + if [ -z "$CAPACITOR_CONFIG" ] && [ ! -d "android" ]; then |
| 58 | + echo "No Capacitor configuration found, initializing..." |
49 | 59 | npx cap init "SVMSeek Wallet" "com.svmseek.wallet" --web-dir=build |
| 60 | + else |
| 61 | + echo "Capacitor already configured with: ${CAPACITOR_CONFIG:-android directory}" |
50 | 62 | fi |
51 | 63 | |
52 | 64 | - name: Add Android platform (if not exists) |
@@ -103,10 +115,16 @@ jobs: |
103 | 115 | if: github.ref == 'refs/heads/main' && github.event_name == 'push' |
104 | 116 | working-directory: ./android |
105 | 117 | run: | |
106 | | - if [ ! -z "${{ secrets.ANDROID_KEYSTORE_BASE64 }}" ]; then |
| 118 | + # Use environment variable instead of direct secret interpolation in shell |
| 119 | + if [ ! -z "$ANDROID_KEYSTORE_BASE64" ]; then |
107 | 120 | echo "Setting up production keystore..." |
108 | | - echo "${{ secrets.ANDROID_KEYSTORE_BASE64 }}" | base64 -d > release.keystore |
109 | | - echo "Production keystore created" |
| 121 | + # Decode safely with error handling |
| 122 | + if echo "$ANDROID_KEYSTORE_BASE64" | base64 -d > release.keystore 2>/dev/null; then |
| 123 | + echo "Production keystore created successfully" |
| 124 | + else |
| 125 | + echo "ERROR: Failed to decode keystore base64 data" |
| 126 | + exit 1 |
| 127 | + fi |
110 | 128 | else |
111 | 129 | echo "No production keystore secrets found, skipping production build" |
112 | 130 | fi |
@@ -177,13 +195,11 @@ jobs: |
177 | 195 | fi |
178 | 196 | |
179 | 197 | # 5. Check APK size is reasonable (not empty or suspiciously small) |
180 | | - APK_SIZE=$(stat -f%z "$APK_FILE" 2>/dev/null || stat -c%s "$APK_FILE" 2>/dev/null || echo "0") |
181 | | - MIN_SIZE=$((1024 * 1024)) # 1MB minimum |
182 | | - if [ "$APK_SIZE" -lt "$MIN_SIZE" ]; then |
183 | | - echo "ERROR: APK size ($APK_SIZE bytes) is suspiciously small" |
| 198 | + echo "Validating APK size..." |
| 199 | + if ! ./scripts/check-apk-size.sh "$APK_FILE" 1; then |
| 200 | + echo "ERROR: APK size validation failed" |
184 | 201 | exit 1 |
185 | 202 | fi |
186 | | - echo "✓ APK size validation passed: $(( APK_SIZE / 1024 / 1024 ))MB" |
187 | 203 | |
188 | 204 | # 6. Verify APK contains expected Android components |
189 | 205 | REQUIRED_FILES="AndroidManifest.xml classes.dex resources.arsc" |
|
0 commit comments