Android CI #13
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Android CI | |
env: | |
# The name of the main module repository | |
main_project_module: app | |
# The name of the Play Store | |
playstore_name: LADB | |
on: | |
# Triggers the workflow on push or pull request events but only for default and protected branches | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
# Triggers the workflow when a release has been published | |
release: | |
types: [published] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
# Set Current Date As Env Variable | |
- name: Set current date as env variable | |
run: echo "date_today=$(date +'%Y-%m-%d')" >> $GITHUB_ENV | |
# Set Repository Name As Env Variable | |
- name: Set repository name as env variable | |
run: echo "repository_name=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV | |
- name: Set Up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 11 | |
distribution: 'temurin' | |
cache: 'gradle' | |
- name: Change wrapper permissions | |
run: chmod +x ./gradlew | |
# Create APK Debug | |
- name: Build apk debug project (APK) - ${{ env.main_project_module }} module | |
run: ./gradlew assembleDebug | |
# Create APK Release | |
- name: Build apk release project (APK) - ${{ env.main_project_module }} module | |
run: ./gradlew assemble | |
# Upload Artifact Build | |
# Noted For Output [main_project_module]/build/outputs/apk/debug/ | |
- name: Upload APK Debug - ${{ env.repository_name }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.date_today }} - ${{ env.playstore_name }} - ${{ env.repository_name }} - APK(s) debug generated | |
path: ${{ env.main_project_module }}/build/outputs/apk/debug/ | |
- name: Setup build tool version variable | |
shell: bash | |
run: | | |
BUILD_TOOL_VERSION=$(ls /usr/local/lib/android/sdk/build-tools/ | tail -n 1) | |
echo "BUILD_TOOL_VERSION=$BUILD_TOOL_VERSION" >> $GITHUB_ENV | |
echo Last build tool version is: $BUILD_TOOL_VERSION | |
- uses: r0adkll/sign-android-release@v1 | |
name: Sign app APK | |
# ID used to access action output | |
id: sign_app | |
with: | |
releaseDirectory: ${{ env.main_project_module }}/build/outputs/apk/release | |
signingKeyBase64: ${{ secrets.SIGNING_KEY }} | |
alias: ${{ secrets.ALIAS }} | |
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }} | |
keyPassword: ${{ secrets.KEY_PASSWORD }} | |
env: | |
BUILD_TOOLS_VERSION: ${{ env.BUILD_TOOL_VERSION }} | |
- name: Upload APK Release - ${{ env.repository_name }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.date_today }} - ${{ env.playstore_name }} - ${{ env.repository_name }} - APK(s) release generated | |
path: ${{steps.sign_app.outputs.signedReleaseFile}} | |
- name: Rename APK(s) | |
run: | | |
mv ${{steps.sign_app.outputs.signedReleaseFile}} app-release-signed.apk | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: | | |
${{ env.main_project_module }}/build/outputs/apk/debug/app-debug.apk | |
app-release-signed.apk |