openssl base64 < Keys.jks | tr -d 'n' | tee signing.txt
Note commands only works on Linux/MacOs if you have windows use Git bash.
After you run this command as a result it will give a text file which includes a encripted version of for keys.
-
Navigate to your repo settings -> Secrets and Variables -> Action
-
Add this content of txt file into github secrets. Here is the example
-
Then Provide the details for the key in 3 more variable include Store's Password,ALias,ALias's Password.Here is the example
.github/workflows/Build & Release.yml
name: Build and Release 🚀
on:
push:
branches:
- master
tags:
- v*
jobs:
build:
runs-on: ubuntu-latest
steps:
# Step 1: Decode Keystore
- name: Decode Keystore
id: decode_keystore
uses: timheuer/base64-to-file@v1
with:
fileName: 'keystore/keystore.jks'
encodedString: ${{ secrets.KEYSTORE }}
# Step 2: Checkout the repository
- uses: actions/checkout@v2
# Step 3: Set up JDK 11
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
distribution: 'temurin'
cache: gradle
# Step 4: Add Keystore to Project
- name: Copy Keystore to Project
run: |
mkdir -p ./app/keystore
cp ${{ steps.decode_keystore.outputs.filePath }} './app/keystore/keystore.jks'
echo ${{ steps.decode_keystore.outputs.filePath }}
ls -la ./app
# Step 5: Make gradlew executable
- name: Make gradlew executable
run: chmod +x ./gradlew
# Step 6: Build Release APK
- name: Build Release APK
run: ./gradlew :app:assembleRelease --stacktrace :app:bundleRelease --stacktrace
env:
SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }}
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
SIGNING_STORE_PASSWORD: ${{ secrets.SIGNING_STORE_PASSWORD }}
# Step 7: Upload APK and AAB artifacts
- name: Upload APK
uses: actions/upload-artifact@v2
with:
name: apk
path: app/build/outputs/apk/release/app-release.apk
- name: Upload AAB
uses: actions/upload-artifact@v2
with:
name: aab
path: app/build/outputs/bundle/release/app-release.aab
Here's an overview of the changes I made to your workflow file:
-
In the
on
section, the workflow is triggered when a tag matching the pattern v* is pushed to the repository or when a commit is pushed to the master branch. -
The
build
job runs on anubuntu-latest
runner. -
In
Copy Keystore to Project
step, I added als -la ./app
command to list the contents of theapp
directory. -
In the
steps
section, I added a comment for each step to explain what it does. -
The
Build Release APK
andBuild Release AAB
steps build the APK and AAB artifacts. -
The
Upload APK
andUpload AAB
steps upload the APK and AAB artifacts to the workflow run, which can be used in later steps or downloaded from the GitHub Actions UI.
4. After doing all the above steps the last step include some changes on app level build.gradle file.
signingConfigs {
release {
storeFile file('keystore/keystore.jks')
storePassword System.getenv("SIGNING_STORE_PASSWORD")
keyAlias System.getenv("SIGNING_KEY_ALIAS")
keyPassword System.getenv("SIGNING_KEY_PASSWORD")
}
}
Than assign this config to release block
buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
And file should apper at the bottom of that page
Here is the repo-link used in this project
If you just change your root project name to some other name you can check out my BIT-App which include multimodule setup and different root module name..