Search code examples
androidreact-nativegithub-actionskeystorecicd

React native: I'm getting error with Keystore file in GitHub Actions with android build apk


I converted my-upload-key.keystore to base64 and imported the content as ANDROID_SIGNING_KEY in my repository secrets. But I get this error when I try to run CI/CD actions.

> Keystore file '/home/runner/work/SampleApp/SampleApp/android/app/my-upload-key.keystore' not found for signing config 'release'.

my yml code:

  - name: Sign APK
        id: sign_app
        uses: r0adkll/sign-android-release@v1
        with:
          releaseDirectory: android/app/build/outputs/apk/release
          signingKeyBase64: ${{ secrets.ANDROID_SIGNING_KEY }}
          alias: ${{ secrets.ANDROID_ALIAS }}
          keyStorePassword: ${{ secrets.ANDROID_KEY_STORE_PASSWORD }}
          keyPassword: ${{ secrets.ANDROID_KEY_PASSWORD }}

/app/build.gradle

    signingConfigs {

         release {
            if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
                storeFile file(MYAPP_UPLOAD_STORE_FILE)
                storePassword MYAPP_UPLOAD_STORE_PASSWORD
                keyAlias MYAPP_UPLOAD_KEY_ALIAS
                keyPassword MYAPP_UPLOAD_KEY_PASSWORD
            }
        }
    }
    buildTypes {
        release {
            signingConfig signingConfigs.release
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }

I know my-upload-key.keystore is not supposed to upload to my repository but the thing is, why does it need this file while I've already imported it as a base64 action secter?


Solution

  • Solution: I removed the release section from /app/build.gradle and it works. Basically, we need to create an unsigned release before run signing job. The updated /app/build.gradle is:

     signingConfigs {
            //  release {
            //     if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
            //         storeFile file(MYAPP_UPLOAD_STORE_FILE)
            //         storePassword MYAPP_UPLOAD_STORE_PASSWORD
            //         keyAlias MYAPP_UPLOAD_KEY_ALIAS
            //         keyPassword MYAPP_UPLOAD_KEY_PASSWORD
            //     }
            // }
        }
        buildTypes {
            release {
                //  signingConfig signingConfigs.release
                minifyEnabled enableProguardInReleaseBuilds
                proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
            }
        }