Skip to content

Update android-ci.yml #15

Update android-ci.yml

Update android-ci.yml #15

Workflow file for this run

name: Android CI/CD
on:
push:
tags:
- 'v*'
branches:
- main
workflow_dispatch:
env:
SERVICE_ACCOUNT_JSON: ${{ secrets.SERVICE_ACCOUNT_JSON }}
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
SIGNING_KEY_ALIAS: ${{ secrets.SIGNING_KEY_ALIAS }}
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
jobs:
build-and-publish:
name: Build & Publish Android App
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Validate Gradle Wrapper
uses: gradle/wrapper-validation-action@v1
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Download and set up Android SDK
uses: android-actions/setup-android@v2
- name: Cache Gradle directories
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Restore signing keystore
run: |
mkdir -p app
echo "$KEYSTORE_BASE64" | base64 --decode > release.keystore
echo "$KEYSTORE_BASE64" | base64 --decode > app/release.keystore
- name: Get versionCode
id: versionCode
run: |
VERSION_CODE=$(./gradlew printVersionCode -q)
echo versionCode=$VERSION_CODE >> $GITHUB_OUTPUT
- name: Get versionName
id: versionName
run: |
VERSION_NAME=$(./gradlew printVersionName -q)
echo versionName=$VERSION_NAME >> $GITHUB_OUTPUT
- name: Build Release AAB
run: |
./gradlew bundleRelease \
-Pandroid.injected.signing.store.file=release.keystore \
-Pandroid.injected.signing.store.password=$KEYSTORE_PASSWORD \
-Pandroid.injected.signing.key.alias=$SIGNING_KEY_ALIAS \
-Pandroid.injected.signing.key.password=$SIGNING_KEY_PASSWORD
- name: Create GitHub Release
if: startsWith(github.ref, 'refs/tags/v')
id: create_release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
body: |
• versionCode: ${{ steps.versionCode.outputs.versionCode }}
• versionName: ${{ steps.versionName.outputs.versionName }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload AAB to GitHub Release
if: steps.create_release.outputs.upload_url != ''
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: app/build/outputs/bundle/release/app-release.aab
asset_name: app-release-${{ github.ref_name }}.aab
asset_content_type: application/octet-stream
- name: Publish to Google Play Internal Track
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJsonPlainText: ${{ env.SERVICE_ACCOUNT_JSON }}
packageName: com.jaewchoi.barcodescanner
releaseFiles: app/build/outputs/bundle/release/app-release.aab
track: internal
status: completed