5. Github workflows
Everything is available to create Github workflow
.
5.1 Trigger Event
We want to trigger the workflow
whenever code is pushed to the main
branch.
5.2 Permission to workflow
We want to give permission to workflow
in order to create Release
over Github
It enables the workflow
to create the release
over Github which will come later in the workflow.
5.3 Setup code and gradle wrapper.
We want to checkout code and enable gradle wrapper as below.
5.4 Decode Keystore
As mentioned earlier to build and sign the release build, we have to decode the Keystore
which was encoded base64
and store it to the location specified inside release signing configuration inside gradle
.
5.5 Build and Sign Release Bundle
Build and sign the release build with the signing configurations.
workflow
is first setting environment variables which will be read inside app build.gradle
signing configurations as mentioned in Step 4 above.
./gradlew bundleRelease
is building only release bundle
, if you want to build apk as well you can use command ./gradlew assembleRelease
.
5.6 Retrieve Version Name.
In the next steps we want to create a release over Github
, in order to do that we need the version name specified in build.gradle
to create a tag and release name.
version_name
is an ext property inside build.gradle
which can be used to set a variable inside gradle using task as below.
tasks.register("appVersionName") {
println rootProject.ext.version_name
}
In the workflow step below we are retrieving the Version Name
from gradle variable appVersionName
and setting and environment variable version_name
so it can be used throughout workflow
using statement ${{ env.version_name }}
5.7 Create Release over Github.
In the last step we want to create a release over Github. The following step in the workflow will achieve that.
Using softprops Github Action to achieve that. ${{env.version_name}}
is the environment variable used to get the versionName configured in the previous step.
For the bundle file path please specify YourAppName and YourAppNameWithVariant , you can check when you create a normal build from Android Studio.