Skip to content

Create Release Build #71

Create Release Build

Create Release Build #71

Workflow file for this run

name: Create Release Build
on:
workflow_dispatch:
inputs:
upload_to_google:
description: "Upload to Google Play"
required: true
type: boolean
default: true
upload_to_huawei:
description: "Upload to Huawei AppGallery"
required: true
type: boolean
default: true
upload_to_amazon:
description: "Upload to Amazon Appstore"
required: true
type: boolean
default: true
jobs:
build:
runs-on: ubuntu-latest
env:
JAVA_VERSION: '17'
CREDENTIALS_DIR: 'credentials'
AAB_FILE: 'app/build/outputs/bundle/release/app-release.aab'
APK_FILE: 'app/build/outputs/apk/release/app-release.apk'
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: 'temurin'
cache: 'gradle'
- name: Run Detekt
run: ./gradlew detekt
- name: Run Lint
run: ./gradlew lintRelease
- name: Run unit tests
run: ./gradlew testReleaseUnitTest
- name: Build App Bundle and APK
run: |
mkdir "$CREDENTIALS_DIR"
echo "$RELEASE_KEYSTORE_PROPERTIES" > "$CREDENTIALS_DIR/keystore.properties"
echo "$RELEASE_KEYSTORE" | base64 -d > "$CREDENTIALS_DIR/keystore.jks"
./gradlew bundleRelease assembleRelease
env:
RELEASE_KEYSTORE_PROPERTIES: ${{ secrets.RELEASE_KEYSTORE_PROPERTIES }}
RELEASE_KEYSTORE: ${{ secrets.RELEASE_KEYSTORE }}
- name: Remove any credentials
if: always()
run: rm -rd "$CREDENTIALS_DIR"
- name: Extract version code and version name
run: |
echo "VERSION_NAME="$(scripts/get_version_name)"" >> $GITHUB_ENV
echo "VERSION_CODE="$(scripts/get_version_code)"" >> $GITHUB_ENV
- name: Create tag and release on GitHub if not already done
uses: ncipollo/release-action@v1
with:
tag: ${{ env.VERSION_CODE }}
name: ${{ env.VERSION_NAME }}
bodyFile: fastlane/metadata/android/en-US/changelogs/${{ env.VERSION_CODE }}.txt
artifacts: ${{ env.APK_FILE }}
makeLatest: true
skipIfReleaseExists: true
artifactErrorsFailBuild: true
- name: Setup Ruby
if: ${{ inputs.upload_to_amazon || inputs.upload_to_google || inputs.upload_to_huawei }}
uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Upload app to Google Play
if: ${{ inputs.upload_to_google }}
run: |
export PLAYSTORE_KEY=$(echo "$PLAY_STORE_CREDENTIALS" | base64 -d)
bundle exec fastlane google
env:
PLAY_STORE_CREDENTIALS: ${{ secrets.PLAY_STORE_CREDENTIALS }}
- name: Upload app to Huawei AppGallery
if: ${{ inputs.upload_to_huawei }}
run: bundle exec fastlane huawei
env:
HUAWEI_CLIENT_ID: ${{ secrets.HUAWEI_CLIENT_ID }}
HUAWEI_CLIENT_SECRET: ${{ secrets.HUAWEI_CLIENT_SECRET }}
- name: Upload app to Amazon Appstore
if: ${{ inputs.upload_to_amazon }}
run: bundle exec fastlane amazon
env:
AMAZON_CLIENT_ID: ${{ secrets.AMAZON_CLIENT_ID }}
AMAZON_CLIENT_SECRET: ${{ secrets.AMAZON_CLIENT_SECRET }}
- name: Upload test reports
uses: actions/upload-artifact@v4
if: always()
with:
name: test_reports
path: |
app/build/reports/detekt/detekt.html
app/build/reports/lint-results-release.html
app/build/reports/tests/testReleaseUnitTest/