Build Android app #21
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: 'Build Android app' | |
on: | |
workflow_dispatch: | |
push: | |
tags: | |
- v2.* | |
- v1.* | |
jobs: | |
version: | |
runs-on: ubuntu-latest | |
outputs: | |
current-version: ${{ steps.package-version.outputs.current-version }} | |
project-name: Signed SeaBattlePaper v-${{ steps.package-version.outputs.current-version }} | |
steps: | |
- name: Checkout the main GitHub branch | |
uses: actions/checkout@v4 | |
with: | |
lfs: 'true' | |
- name: Get the current version of the product | |
id: package-version | |
uses: martinbeentjes/npm-get-version-action@v1.3.1 | |
- name: List current version | |
run: | | |
echo Product version: ${{ steps.package-version.outputs.current-version }} | |
build-android: | |
runs-on: ubuntu-latest | |
needs: [ "version" ] | |
steps: | |
- name: Checkout the main GitHub branch | |
uses: actions/checkout@v4 | |
with: | |
lfs: 'true' | |
- name: Set up JDK | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
cache: 'gradle' | |
- name: Install Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.17 | |
- name: Install dependencies | |
run: npm ci | |
- name: Cache Gradle Wrapper | |
uses: actions/cache@v4 | |
with: | |
path: ~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }} | |
- name: Cache Gradle Dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-caches-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle-caches- | |
# - name: Get the current version of the product | |
# id: package-version | |
# uses: martinbeentjes/npm-get-version-action@v1.3.1 | |
- name: Decode Keystore and google-services.json | |
env: | |
ANDROID_SIGNING_KEY_BASE64: ${{ secrets.ANDROID_SIGNING_KEY_BASE64 }} | |
GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }} | |
run: | | |
echo $ANDROID_SIGNING_KEY_BASE64 | base64 --decode > /home/runner/work/SeaBattlePaper/SeaBattlePaper/android/my-upload-key.keystore | |
echo $ANDROID_SIGNING_KEY_BASE64 | base64 --decode > /home/runner/work/SeaBattlePaper/SeaBattlePaper/android/app/my-upload-key.keystore | |
echo $GOOGLE_SERVICES_JSON | base64 --decode > /home/runner/work/SeaBattlePaper/SeaBattlePaper/android/app/google-services.json | |
# - name: Test signing | |
# env: | |
# ANDROID_SIGNING_ALIAS: ${{ secrets.ANDROID_SIGNING_ALIAS }} | |
# ANDROID_SIGNING_KEY_PASSWORD: ${{ secrets.ANDROID_SIGNING_KEY_PASSWORD }} | |
# ANDROID_SIGNING_STORE_PASSWORD: ${{ secrets.ANDROID_SIGNING_STORE_PASSWORD }} | |
# run: | | |
# cd android | |
# chmod +x ./gradlew | |
# ./gradlew signingReport | |
# - name: List versions | |
# run: | | |
# cd android | |
# chmod +x ./gradlew | |
# ./gradlew -version | |
# echo Product version: ${{ needs.version.outputs.current-version }} | |
# node --version | |
- name: Build signed Android release | |
env: | |
ANDROID_SIGNING_ALIAS: ${{ secrets.ANDROID_SIGNING_ALIAS }} | |
ANDROID_SIGNING_KEY_PASSWORD: ${{ secrets.ANDROID_SIGNING_KEY_PASSWORD }} | |
ANDROID_SIGNING_STORE_PASSWORD: ${{ secrets.ANDROID_SIGNING_STORE_PASSWORD }} | |
run: | | |
cd android | |
chmod +x ./gradlew | |
./gradlew bundleRelease --no-daemon | |
cp /home/runner/work/SeaBattlePaper/SeaBattlePaper/android/app/build/outputs/bundle/release/app-release.aab /home/runner/work/SeaBattlePaper/SeaBattlePaper/app-release.aab | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ needs.version.outputs.project-name }} | |
path: /home/runner/work/SeaBattlePaper/SeaBattlePaper/app-release.aab | |
update-google-play-console: | |
runs-on: ubuntu-latest | |
needs: [ "version", "build-android"] | |
permissions: read-all | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: ${{ needs.version.outputs.project-name }} | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
path: build | |
# - name: Display structure of downloaded files | |
# run: | | |
# ls | |
# cd build | |
# ls | |
- name: Upload App to Google Play | |
uses: r0adkll/upload-google-play@v1 | |
with: | |
serviceAccountJsonPlainText: ${{ secrets.SERVICE_ACCOUNT_JSON }} | |
packageName: com.baitupasaulis.seabattlepaper | |
releaseFiles: build/app-release.aab | |
track: production | |
status: completed |