README.md

July 30, 2024 ยท View on GitHub

Sign Android Release

A GitHub action to sign an APK or AAB.

Test License


This action will help you sign an Android .apk or .aab (Android App Bundle) file for release.

Usage

steps:
  - uses: NoCrypt/sign-android@main
    name: Sign app APK
    id: sign_app
    with:
      releaseDir: app/build/outputs/apk/release
      signingKey: ${{ secrets.ANDROID_SIGNING_KEY }}
      keyAlias: ${{ secrets.ANDROID_KEY_ALIAS }}
      keyStorePassword: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
      keyPassword: ${{ secrets.ANDROID_KEY_PASSWORD }}

  # Upload your signed file if you want
  - uses: actions/upload-artifact@v3
    with:
      name: Signed app bundle
      path: ${{steps.sign_app.outputs.signedFile}}

If you have multiple files to sign:

steps:
  - uses: NoCrypt/sign-android@main
    id: sign_app
    with:
      releaseDir: app/build/outputs/apk/release
      signingKey: ${{ secrets.ANDROID_SIGNING_KEY }}
      keyAlias: ${{ secrets.ANDROID_KEY_ALIAS }}
      keyStorePassword: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
      keyPassword: ${{ secrets.ANDROID_KEY_PASSWORD }}

  - uses: jungwinter/split@v2
    id: signed_files
    with:
      msg: ${{ steps.sign_app.outputs.signedFiles }}
      separator: ':'

  - name: Example Release
    uses: 'marvinpinto/action-automatic-releases@latest'
    with:
      repo_token: '${{ secrets.GITHUB_TOKEN }}'
      automatic_release_tag: 'latest'
      prerelease: true
      title: 'Release X'
      files: |
        ${{ steps.signed_files.outputs._0 }}
        ${{ steps.signed_files.outputs._1 }}
        ${{ steps.signed_files.outputs._2 }}
        ${{ steps.signed_files.outputs._3 }}
        ${{ steps.signed_files.outputs._4 }}

Or you can also do this using signedFileX:

steps:
  - uses: NoCrypt/sign-android@main
    id: sign_app
    with:
      releaseDir: app/build/outputs/apk/release
      signingKey: ${{ secrets.ANDROID_SIGNING_KEY }}
      keyAlias: ${{ secrets.ANDROID_KEY_ALIAS }}
      keyStorePassword: ${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
      keyPassword: ${{ secrets.ANDROID_KEY_PASSWORD }}

  - name: Example Release
    uses: 'marvinpinto/action-automatic-releases@latest'
    with:
      repo_token: '${{ secrets.GITHUB_TOKEN }}'
      automatic_release_tag: 'latest'
      prerelease: true
      title: 'Release X'
      files: |
        ${{ steps.sign_app.outputs.signedFile0 }}
        ${{ steps.sign_app.outputs.signedFile1 }}
        ${{ steps.sign_app.outputs.signedFile2 }}
        ${{ steps.sign_app.outputs.signedFile3 }}
        ${{ steps.sign_app.outputs.signedFile4 }}

Inputs

You can set either inputs (in with section) or env (in env section).

KeyENVUsage
releaseDirANDROID_RELEASE_DIRRequired. The relative directory path in your project where your Android release file will be located.
Defaults to app/build/outputs/apk/release.
signingKeyANDROID_SIGNING_KEYRequired. The base64 encoded signing key used to sign your app.
keyAliasANDROID_KEY_ALIASRequired. The alias of your signing key.
keyStorePasswordANDROID_KEYSTORE_PASSWORDRequired. The password for your signing keystore.
keyPasswordANDROID_KEY_PASSWORDOptional. The private password for your signing key.
buildToolsVersionANDROID_BUILD_TOOLS_VERSIONOptional. The version of Android build tools to use. Defaults to Auto Detect.
appNameANDROID_APP_NAMEOptional. Prefered App Name for renaming. Defaults to app. Example: name will results android-name-1.2.3.apk
appVersionANDROID_APP_VERSIONOptional. Prefered App Version for renaming. Example: 1.2.3 will results android-name-1.2.3.apk
appPrefixANDROID_APP_PREFIXOptional. Prefered App Prefix for renaming. Example: android will results android-name-1.2.3.apk

You can prepare your signingKey by running this command:

openssl base64 < some_signing_key.jks | tr -d '\n' | tee some_signing_key.jks.base64.txt

Then copy the text to Settings - Secrets - Action in your account or organization.

Outputs

KeyENVUsage
signedFileANDROID_SIGNED_FILEThe path to the single release file that have been signed.
Not set if multiple release files have been signed.
signedFilesANDROID_SIGNED_FILESThe paths to the release files that have been signed with this action, separated by :.
signedFileXANDROID_SIGNED_FILE_XThe paths to the release files that have been signed with this action. The X is index number starting from 0. Example: signedFile0, signedFile1 or ANDROID_SIGNED_FILE_0
signedFilesCountANDROID_SIGNED_FILES_COUNTThe count of signed release files.

BUGs & Issues

Feel free to open issues.

Contributions

PRs are welcome! Feel free to contribute.

LICENSE

MIT