From a8448166f2a44936a8bf1aecdfe699e004c91f16 Mon Sep 17 00:00:00 2001 From: linuxct Date: Tue, 6 Aug 2024 11:09:56 +0200 Subject: [PATCH 1/4] [skip ci] chore: Add initial CI support --- .github/workflows/ci.yaml | 59 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..94eb7cd --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,59 @@ +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 Release APK + - name: Build Release APK + run: bash ./gradlew assembleDebug --stacktrace + + # Generate APK Names + - name: Generate APK Names + id: generate_apk_names + run: | + 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 }}" From b6ecabfb00919391ec1a9602c44e367362a7009d Mon Sep 17 00:00:00 2001 From: linuxct Date: Tue, 6 Aug 2024 11:11:17 +0200 Subject: [PATCH 2/4] chore: Add CI badge to README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 83dd904..898da3f 100644 --- a/README.md +++ b/README.md @@ -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) @@ -26,4 +26,4 @@ - Kotlin `flows` ### Improvements 🚀 -This app is currently in development 🛠️. New features and improvements might be added. \ No newline at end of file +This app is currently in development 🛠️. New features and improvements might be added. From 01267e6e498cfd9a19b1b9f43fcfcc514555ae29 Mon Sep 17 00:00:00 2001 From: linuxct Date: Tue, 6 Aug 2024 11:16:43 +0200 Subject: [PATCH 3/4] chore: Update CI to prevent build failures --- .github/workflows/ci.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 94eb7cd..15c0023 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -32,14 +32,15 @@ jobs: key: ${{ runner.os }}-gradle-cache-${{ hashFiles('**/*.gradle*') }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }} restore-keys: ${{ runner.os }}-gradle-cache- - # Build Release APK - - name: Build Release APK + # 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// /-}" From 142a91a92cba8f5866ebcc057c6078f837e74c30 Mon Sep 17 00:00:00 2001 From: linuxct Date: Tue, 6 Aug 2024 11:17:25 +0200 Subject: [PATCH 4/4] chore: Add printVersionName task to Gradle config --- app/build.gradle.kts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index b383624..92e099d 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -70,4 +70,10 @@ dependencies { androidTestImplementation(libs.androidx.ui.test.junit4) debugImplementation(libs.androidx.ui.tooling) debugImplementation(libs.androidx.ui.test.manifest) -} \ No newline at end of file +} + +task("printVersionName"){ + doLast { + println(android.defaultConfig.versionName) + } +}