From 533931f7de49ad8b315233193bc117a836810e9c Mon Sep 17 00:00:00 2001 From: Mostafa Date: Sat, 9 Nov 2024 01:47:21 +0200 Subject: [PATCH] setup new gh workflow --- .github/workflows/android.yml | 102 ++++++++++++++++++++-------------- .github/workflows/tg_bot.yml | 31 +++++++++++ app/build.gradle.kts | 69 +++++++++++++++++++++-- 3 files changed, 155 insertions(+), 47 deletions(-) create mode 100644 .github/workflows/tg_bot.yml diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 4d4154e..7dc8e78 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -1,60 +1,76 @@ -name: Android CI/CD Pipeline ๐Ÿš€ +name: Android CI + +env: + # The name of the main module repository + main_project_module: app on: push: - branches: [ 'master' ] + branches: [ "master" ] pull_request: - branches: [ 'master' ] - workflow_dispatch: # Allows manual trigger + branches: [ "master" ] jobs: build: + runs-on: ubuntu-latest steps: - - name: ๐Ÿ›Ž๏ธ Check out code - uses: actions/checkout@v3 - - - name: โ˜• Set up JDK 17 - uses: actions/setup-java@v2 + - uses: actions/checkout@v3 + - name: set up JDK 17 + uses: actions/setup-java@v3 with: java-version: '17' - distribution: 'temurin' + distribution: 'corretto' + cache: gradle - - name: ๐Ÿ—‚๏ธ Cache Gradle dependencies - uses: actions/cache@v3 + - uses: gradle/gradle-build-action@v2 with: - path: ~/.gradle/caches - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradlew*') }} - restore-keys: | - ${{ runner.os }}-gradle- - - - name: ๐Ÿ”‘ Grant execute permission for gradlew - run: chmod +x ./gradlew - - - name: ๐Ÿ—๏ธ Build with Gradle - run: ./gradlew assembleRelease --scan --no-daemon - -# - name: ๐Ÿงช Run Unit Tests -# run: ./gradlew test -# -# - name: ๐Ÿ“ค Upload Test Reports -# uses: actions/upload-artifact@v4 -# with: -# name: test-report -# path: build/reports/tests/test - - - name: ๐ŸŽจ Check Code Style with KtLint - run: ./gradlew ktlintCheck - - - name: ๐Ÿ“ค Upload KtLint Reports - uses: actions/upload-artifact@v4 + gradle-version: 7.5 + - name: Create base64 jks file + run: echo "${{ secrets.BASE_64_SIGNING_KEY }}" > app/release_keystore.txt + - name: Create jks file + run: base64 -d "app/release_keystore.txt" > app/release_keystore.jks + - name: Create Blank Local Properties FIle + run: touch local.properties + - name: Create Keystore Properties File + run: echo "${{ secrets.LOCAL_PROPERTIES }}" > keystore.properties + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Build with Gradle + run: ./gradlew build + - name: Set current date as env variable + run: echo "date_today=$(date +'%Y-%m-%d')" >> $GITHUB_ENV + # Create APK Debug + - name: Build apk debug project (APK) + run: ./gradlew assembleDebug + # Create APK Release + - name: Build apk release project (APK) + run: ./gradlew assemble + # Upload Artifact Build + # Noted For Output [main_project_module]/build/outputs/apk/debug/ + - name: Upload APK Debug + uses: actions/upload-artifact@v3 + with: + name: GameVault APK debug generated + path: ${{ env.main_project_module }}/build/outputs/apk/debug/ + + # Noted For Output [main_project_module]/build/outputs/apk/release/ + - name: Upload APK Release + uses: actions/upload-artifact@v3 with: - name: ktlint-report - path: build/reports/ktlint/ + name: GameVault APK release generated + path: ${{ env.main_project_module }}/build/outputs/apk/release/ - - name: ๐Ÿ“ฒ Upload APK - uses: actions/upload-artifact@v4 + - name: send telegram message on push or pull + uses: appleboy/telegram-action@master with: - name: release-apk - path: app/build/outputs/apk/release/*.apk + to: ${{ secrets.TELEGRAM_TO }} + token: ${{ secrets.TELEGRAM_TOKEN }} + message: | + ${{ github.actor }} created commit: + Commit message: ${{ github.event.commits[0].message }} + + Repository: ${{ github.repository }} + + See changes: https://github.com/${{ github.repository }}/commit/${{github.sha}} diff --git a/.github/workflows/tg_bot.yml b/.github/workflows/tg_bot.yml new file mode 100644 index 0000000..c3f468a --- /dev/null +++ b/.github/workflows/tg_bot.yml @@ -0,0 +1,31 @@ +name: Telegram Builder + +on: + release: + types: [published] + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: send telegram message on push + uses: appleboy/telegram-action@master + with: + to: ${{ secrets.TELEGRAM_TO }} + token: ${{ secrets.TELEGRAM_TOKEN }} + format: markdown + photo: https://raw.githubusercontent.com/MostafaMohamed2002/GameVault/refs/heads/master/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp + disable_web_page_preview: false + message: | + GameVault has a new release: [${{ github.event.release.tag_name }}](https://github.com/${{ github.repository }}/releases/tag/${{ github.event.release.tag_name }}) + ```markdown + ${{ github.event.release.body }} + ``` + + [${{ github.event.release.assets[0].name }}](${{ github.event.release.assets[0].browser_download_url }}) + [${{ github.event.release.assets[1].name }}](${{ github.event.release.assets[1].browser_download_url }}) + [${{ github.event.release.assets[2].name }}](${{ github.event.release.assets[2].browser_download_url }}) + [${{ github.event.release.assets[3].name }}](${{ github.event.release.assets[3].browser_download_url }}) + [${{ github.event.release.assets[4].name }}](${{ github.event.release.assets[4].browser_download_url }}) + [${{ github.event.release.assets[5].name }}](${{ github.event.release.assets[5].browser_download_url }}) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 72e3a33..1c2fd80 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,4 +1,7 @@ import org.jlleitschuh.gradle.ktlint.reporter.ReporterType +import java.io.FileInputStream +import java.io.IOException +import java.util.Properties plugins { alias(libs.plugins.android.application) @@ -9,17 +12,53 @@ plugins { alias(libs.plugins.baselineprofile) // hilt id("org.jlleitschuh.gradle.ktlint") // ktlint } +val properties = Properties() +val versionMajor = 1 +val versionMinor = 0 +val versionPatch = 0 +val versionBuild = 0 // bump for dogfood builds, public betas, etc. +val isBeta = true +var versionExt = "" +if (versionBuild > 0) { + versionExt += ".$versionBuild" +} +if (isBeta) { + versionExt += "-beta" +} android { namespace = "com.mostafadevo.freegames" compileSdk = 35 + try { + val propertiesFile = rootProject.file("keystore.properties") + val properties = Properties() + + if (propertiesFile.readText().isNotEmpty()) { + FileInputStream(propertiesFile).use { inputStream -> + properties.load(inputStream) + } + + signingConfigs { + create("debug") { + storeFile = file(properties["signingConfig.storeFile"] as String) + storePassword = properties["signingConfig.storePassword"] as String + keyAlias = properties["signingConfig.keyAlias"] as String + keyPassword = properties["signingConfig.keyPassword"] as String + } + } + } + } catch (ignored: IOException) { + // Handle exception if necessary + } + defaultConfig { applicationId = "com.mostafadevo.freegames" minSdk = 24 targetSdk = 35 - versionCode = 1 - versionName = "1.0" + versionCode = + versionMajor * 1000000 + versionMinor * 10000 + versionPatch * 100 + versionBuild + versionName = "${versionMajor}.${versionMinor}.${versionPatch}${versionExt}" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" vectorDrawables { @@ -28,15 +67,25 @@ android { } buildTypes { - release { - isMinifyEnabled = false + getByName("release") { + isMinifyEnabled = true + isShrinkResources = true proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" ) + isDebuggable = false + signingConfig = signingConfigs.getByName("debug") + } + + getByName("debug") { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + isDebuggable = true signingConfig = signingConfigs.getByName("debug") } } + compileOptions { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 @@ -64,6 +113,18 @@ android { reporter(ReporterType.HTML) } } + splits { + abi { + isEnable = true + reset() + include("x86", "x86_64", "armeabi-v7a", "arm64-v8a") + isUniversalApk = true + } + } + dependenciesInfo { + includeInApk = false + includeInBundle = false + } } dependencies {