Skip to content

Commit

Permalink
setup new gh workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
MostafaMohamed2002 committed Nov 8, 2024
1 parent a8837e8 commit 533931f
Show file tree
Hide file tree
Showing 3 changed files with 155 additions and 47 deletions.
102 changes: 59 additions & 43 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
@@ -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}}
31 changes: 31 additions & 0 deletions .github/workflows/tg_bot.yml
Original file line number Diff line number Diff line change
@@ -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 }})
69 changes: 65 additions & 4 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 533931f

Please sign in to comment.