Skip to content

Commit

Permalink
Merge pull request #13 from linuxct/main
Browse files Browse the repository at this point in the history
feat(ci): Add CI support to build a debug APK on every push
  • Loading branch information
MubarakNative authored Aug 7, 2024
2 parents 4a6735a + 142a91a commit f745a3b
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 3 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Android CI

on:
push:
tags:

jobs:

build:
name: Build MBCompass
runs-on: ubuntu-latest
steps:

# Checkout Code
- uses: actions/checkout@v1

# Setup JDK 17
- name: Setup JDK 17
uses: actions/setup-java@v1
with:
java-version: '17'

# Set Gradle Home
- name: Set Gradle Home
run: export GRADLE_USER_HOME=~/.gradle

# Gradle Cache
- name: Gradle Cache
uses: actions/cache@v1
with:
path: ~/.gradle
key: ${{ runner.os }}-gradle-cache-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: ${{ runner.os }}-gradle-cache-

# Build Debug APK
- name: Build Debug APK
run: bash ./gradlew assembleDebug --stacktrace

# Generate APK Names
- name: Generate APK Names
id: generate_apk_names
run: |
chmod a+x ./gradlew
SHORT_SHA="$(git rev-parse --short ${{ github.sha }})"
VERSION_NAME="$(./gradlew --quiet --console=plain printVersionName)"
VERSION_NAME="${VERSION_NAME// /-}"
echo ::set-output name=NAME_DEBUG::"mbcompass-v${VERSION_NAME}-${SHORT_SHA}-debug.apk"
# Rename APKs
- name: Rename APKs
run: |
mkdir -p app/apks/
mv app/build/outputs/apk/debug/app-debug.apk "app/apks/${{ steps.generate_apk_names.outputs.NAME_DEBUG }}"
# Upload Prod APK
- name: Upload Debug APK
uses: actions/upload-artifact@v1
with:
name: ${{ steps.generate_apk_names.outputs.NAME_DEBUG }}
path: "app/apks/${{ steps.generate_apk_names.outputs.NAME_DEBUG }}"
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## 🧭MBCompass - Compose Compass App
## 🧭MBCompass - Compose Compass App [![Android CI](https://github.com/MubarakNative/MBCompass/actions/workflows/ci.yaml/badge.svg)](https://github.com/MubarakNative/MBCompass/actions/workflows/ci.yaml)

![Banner MBCompass](BannerMBCompass.png)

Expand Down Expand Up @@ -26,4 +26,4 @@
- Kotlin `flows`

### Improvements 🚀
This app is currently in development 🛠️. New features and improvements might be added.
This app is currently in development 🛠️. New features and improvements might be added.
8 changes: 7 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,10 @@ dependencies {
androidTestImplementation(libs.androidx.ui.test.junit4)
debugImplementation(libs.androidx.ui.tooling)
debugImplementation(libs.androidx.ui.test.manifest)
}
}

task("printVersionName"){
doLast {
println(android.defaultConfig.versionName)
}
}

0 comments on commit f745a3b

Please sign in to comment.