Skip to content

Commit

Permalink
build: setup apk build
Browse files Browse the repository at this point in the history
  • Loading branch information
Veirt committed Dec 11, 2024
1 parent 3d6fa10 commit 05ea82a
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 19 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Build and Release

on:
push:
branches:
- master
workflow_dispatch:

permissions:
contents: write
packages: write

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: "zulu"
java-version: "17"

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

- name: Decode and Set Up Keystore
run: |
echo "${{ secrets.KEYSTORE_BASE64_ENCODED }}" | base64 -d > keystore.jks
- name: Setup keystore.properties
run: |
echo "store.file=keystore.jks" >> keystore.properties
echo "store.password=${{ secrets.KEYSTORE_PASSWORD }}" >> keystore.properties
echo "key.alias=tutortoise" >> keystore.properties
echo "key.password=${{ secrets.KEY_PASSWORD }}" >> keystore.properties
- name: Setup local.properties
run: |
echo "base.url=${{ secrets.BASE_URL }}" >> local.properties
echo "google.oauth.client.id=${{ secrets.GOOGLE_OAUTH_CLIENT_ID }}" >> local.properties
- name: Build Release APK
run: ./gradlew assembleRelease
env:
CI: true

- name: List APK Directory Contents
run: ls -alh app/build/outputs/apk/release/

- name: Upload APK as Artifact
uses: actions/upload-artifact@v3
with:
name: app-release
path: app/build/outputs/apk/release/app-release.apk

- name: Upload APK to Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: app/build/outputs/apk/release/app-release.apk
asset_name: app-release.apk
asset_content_type: application/vnd.android.package-archive
44 changes: 29 additions & 15 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import java.io.FileInputStream
import java.util.Properties

val localProperties = Properties()

localProperties.load(FileInputStream(rootProject.file("local.properties")))

plugins {
Expand All @@ -16,6 +17,13 @@ keystoreProperties.load(FileInputStream(rootProject.file("keystore.properties"))

android {
signingConfigs {
create("release") {
storeFile = file(keystoreProperties.getProperty("store.file"))
storePassword = keystoreProperties.getProperty("store.password")
keyAlias = keystoreProperties.getProperty("key.alias")
keyPassword = keystoreProperties.getProperty("key.password")
}

getByName("debug") {
storeFile = file(keystoreProperties.getProperty("store.file"))
storePassword = keystoreProperties.getProperty("store.password")
Expand All @@ -35,30 +43,42 @@ android {

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

val baseUrl = localProperties.getProperty(
"base.url",
System.getenv("BASE_URL") ?: "https://default-url.com/"
)
val googleOauthClientId = localProperties.getProperty(
"google.oauth.client.id",
System.getenv("GOOGLE_OAUTH_CLIENT_ID") ?: ""
)

buildConfigField(
"String",
"BASE_URL",
"\"${localProperties.getProperty("base.url", "https://default-url.com/")}\""
"\"$baseUrl\""
)

buildConfigField(
"String",
"GOOGLE_OAUTH_CLIENT_ID",
"\"${localProperties.getProperty("google.oauth.client.id", "")}\""
"\"$googleOauthClientId\""
)
signingConfig = signingConfigs.getByName("debug")

multiDexEnabled = true
}

buildTypes {
release {
isMinifyEnabled = true
isShrinkResources = true
isMinifyEnabled = false
isShrinkResources = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
signingConfig = signingConfigs.getByName("release")
}

debug { signingConfig = signingConfigs.getByName("debug") }
}

buildFeatures {
Expand All @@ -71,15 +91,9 @@ android {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
buildFeatures {
viewBinding = true
}
viewBinding {
enable = true
}
kotlinOptions { jvmTarget = "1.8" }
buildFeatures { viewBinding = true }
viewBinding { enable = true }
}

dependencies {
Expand Down Expand Up @@ -126,4 +140,4 @@ dependencies {
implementation(libs.glide)
implementation(libs.shimmer.android)
implementation(libs.ucrop)
}
}
9 changes: 5 additions & 4 deletions app/src/main/res/layout/activity_detail_tutor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -272,27 +272,28 @@
android:id="@+id/groupCategory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="@id/tvCategoryLabel"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvCategoryLabel">

<TextView
android:id="@+id/tvCategoryName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:fontFamily="@font/montserrat_semi_bold"
android:text="@string/category"
android:textColor="@color/black"
android:textSize="14sp" />
android:textSize="14sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<ImageView
android:id="@+id/ivCategoryArrow"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="@drawable/ic_chevron_right"
app:layout_constraintBottom_toBottomOf="@id/tvCategoryName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@id/tvCategoryName"
app:layout_constraintBottom_toBottomOf="@id/tvCategoryName"
app:tint="#757575" />

</androidx.constraintlayout.widget.ConstraintLayout>
Expand Down
Empty file modified gradlew
100644 → 100755
Empty file.

0 comments on commit 05ea82a

Please sign in to comment.