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 9, 2024
1 parent a8837e8 commit 664be77
Show file tree
Hide file tree
Showing 10 changed files with 9,182 additions and 6,801 deletions.
105 changes: 62 additions & 43 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
@@ -1,60 +1,79 @@
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 }}" > release_keystore.txt
- name: Create jks file
run: base64 -d "release_keystore.txt" > 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 }} pushed to branch `${{ github.ref_name }}`.
📄 Commit message: ${{ github.event.commits[0].message }}
📂 Repository: ${{ github.repository }}
🔗 See commit: https://github.com/${{ github.repository }}/commit/${{github.sha}}
$(if github.event.pull_request)
🔗 Pull Request: https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }}
$(endif)
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 }})
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
.cxx
local.properties
.log

.kotlin/sessions/
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 {
getByName("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
72 changes: 71 additions & 1 deletion app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,74 @@

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
#-renamesourcefileattribute SourceFile
-dontwarn com.google.devtools.ksp.UtilsKt
-dontwarn com.google.devtools.ksp.processing.CodeGenerator
-dontwarn com.google.devtools.ksp.processing.Dependencies
-dontwarn com.google.devtools.ksp.processing.KSPLogger
-dontwarn com.google.devtools.ksp.processing.Resolver
-dontwarn com.google.devtools.ksp.processing.SymbolProcessor
-dontwarn com.google.devtools.ksp.processing.SymbolProcessorEnvironment
-dontwarn com.google.devtools.ksp.processing.SymbolProcessorProvider
-dontwarn com.google.devtools.ksp.symbol.ClassKind
-dontwarn com.google.devtools.ksp.symbol.KSAnnotated
-dontwarn com.google.devtools.ksp.symbol.KSAnnotation
-dontwarn com.google.devtools.ksp.symbol.KSClassDeclaration
-dontwarn com.google.devtools.ksp.symbol.KSDeclaration
-dontwarn com.google.devtools.ksp.symbol.KSFile
-dontwarn com.google.devtools.ksp.symbol.KSFunctionDeclaration
-dontwarn com.google.devtools.ksp.symbol.KSName
-dontwarn com.google.devtools.ksp.symbol.KSNode
-dontwarn com.google.devtools.ksp.symbol.KSPropertyDeclaration
-dontwarn com.google.devtools.ksp.symbol.KSReferenceElement
-dontwarn com.google.devtools.ksp.symbol.KSType
-dontwarn com.google.devtools.ksp.symbol.KSTypeAlias
-dontwarn com.google.devtools.ksp.symbol.KSTypeArgument
-dontwarn com.google.devtools.ksp.symbol.KSTypeParameter
-dontwarn com.google.devtools.ksp.symbol.KSTypeReference
-dontwarn com.google.devtools.ksp.symbol.KSValueArgument
-dontwarn com.google.devtools.ksp.symbol.KSValueParameter
-dontwarn com.google.devtools.ksp.symbol.Modifier
-dontwarn com.google.devtools.ksp.symbol.Origin
-dontwarn com.google.devtools.ksp.symbol.Variance
-dontwarn com.google.devtools.ksp.symbol.Visibility
-dontwarn javax.lang.model.SourceVersion
-dontwarn javax.lang.model.element.AnnotationMirror
-dontwarn javax.lang.model.element.AnnotationValue
-dontwarn javax.lang.model.element.AnnotationValueVisitor
-dontwarn javax.lang.model.element.Element
-dontwarn javax.lang.model.element.ElementKind
-dontwarn javax.lang.model.element.ElementVisitor
-dontwarn javax.lang.model.element.ExecutableElement
-dontwarn javax.lang.model.element.Modifier
-dontwarn javax.lang.model.element.Name
-dontwarn javax.lang.model.element.NestingKind
-dontwarn javax.lang.model.element.PackageElement
-dontwarn javax.lang.model.element.QualifiedNameable
-dontwarn javax.lang.model.element.TypeElement
-dontwarn javax.lang.model.element.VariableElement
-dontwarn javax.lang.model.type.ArrayType
-dontwarn javax.lang.model.type.DeclaredType
-dontwarn javax.lang.model.type.ErrorType
-dontwarn javax.lang.model.type.ExecutableType
-dontwarn javax.lang.model.type.IntersectionType
-dontwarn javax.lang.model.type.NoType
-dontwarn javax.lang.model.type.NullType
-dontwarn javax.lang.model.type.PrimitiveType
-dontwarn javax.lang.model.type.TypeKind
-dontwarn javax.lang.model.type.TypeMirror
-dontwarn javax.lang.model.type.TypeVariable
-dontwarn javax.lang.model.type.TypeVisitor
-dontwarn javax.lang.model.type.UnionType
-dontwarn javax.lang.model.type.WildcardType
-dontwarn javax.lang.model.util.AbstractTypeVisitor8
-dontwarn javax.lang.model.util.ElementFilter
-dontwarn javax.lang.model.util.Elements
-dontwarn javax.lang.model.util.SimpleAnnotationValueVisitor8
-dontwarn javax.lang.model.util.SimpleElementVisitor8
-dontwarn javax.lang.model.util.SimpleTypeVisitor8
-dontwarn javax.lang.model.util.Types
-dontwarn javax.tools.Diagnostic$Kind
-dontwarn javax.tools.FileObject
-dontwarn javax.tools.JavaFileManager$Location
-dontwarn javax.tools.StandardLocation
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.semantics.testTagsAsResourceId
Expand Down Expand Up @@ -138,11 +139,6 @@ fun NavigationBottomBar(navController: NavController) {
)
}
),
NavItem(
"/fav",
"Favourite",
icon = { Icon(imageVector = Icons.Default.FavoriteBorder, contentDescription = null) }
),
NavItem(
"/settings",
"Settings",
Expand All @@ -153,7 +149,11 @@ fun NavigationBottomBar(navController: NavController) {
val navBackStackEntry by navController.currentBackStackEntryAsState()
val currentRoute = navBackStackEntry?.destination?.route

BottomAppBar {
BottomAppBar(
modifier = Modifier.semantics {
testTagsAsResourceId = true
}
){
items.forEach { item ->
val animatedWeight by animateFloatAsState(
targetValue = if (currentRoute == item.route) 1.5f else 1f
Expand All @@ -176,7 +176,9 @@ fun NavigationBottomBar(navController: NavController) {
Text(item.title)
},
alwaysShowLabel = true,
modifier = Modifier.weight(animatedWeight)
modifier = Modifier
.weight(animatedWeight)
.testTag("bottom:${item.title}")
)
}
}
Expand Down
Loading

0 comments on commit 664be77

Please sign in to comment.