Skip to content

Commit

Permalink
Update project
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbel committed Nov 22, 2024
1 parent a2a8f7c commit 653a05f
Show file tree
Hide file tree
Showing 45 changed files with 1,124 additions and 30 deletions.
14 changes: 0 additions & 14 deletions .github/scripts/gitlog.sh

This file was deleted.

136 changes: 136 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,142 @@ jobs:
-F message_thread_id="${THREAD_ID}" \
-F parse_mode="HTML"
- name: send telegram message bundle
env:
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
THREAD_ID: ${{ secrets.TELEGRAM_THREAD_ID }}
MESSAGE: |
✅ <b>${{ env.VERSION_NAME }} (${{ env.VERSION_CODE }})</b>
<b>Ветка:</b> ${{ github.ref_name }}
<b>Коммит:</b> <code>${{ env.SHORT_SHA }}</code>
run: |
curl -s -X POST "https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendDocument" \
-F chat_id="${CHAT_ID}" \
-F document="@${{ env.BUNDLE_APK_PATH }}" \
-F caption="${{ env.MESSAGE }}" \
-F message_thread_id="${THREAD_ID}" \
-F parse_mode="HTML"
build-wear:
if: ${{ vars.ANDROID_BUILD_ENABLED == 'true' }}
needs: job-common
runs-on: ubuntu-latest
timeout-minutes: 60
env:
KEYSTORE_FILE: ${{ secrets.KEYSTORE_FILE }}
KEYSTORE_KEY_ALIAS: ${{ secrets.KEYSTORE_KEY_ALIAS }}
KEYSTORE_KEY_PASSWORD: ${{ secrets.KEYSTORE_KEY_PASSWORD }}
KEYSTORE_STORE_PASSWORD: ${{ secrets.KEYSTORE_STORE_PASSWORD }}
SHORT_SHA: ${{ needs.job-common.outputs.SHORT_SHA }}
steps:
- name: checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0 # клонирует репозиторий с историей коммитов

- name: setup jdk 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'

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

- name: make gradlew executable
run: chmod +x ./gradlew

- name: decode keystore file
id: decode_keystore_file
uses: timheuer/base64-to-file@v1
with:
fileName: 'keystore_release.jks'
encodedString: ${{ secrets.KEYSTORE_FILE }}

- name: set decoded file location as environment
run: echo "KEYSTORE_FILE=${{ steps.decode_keystore_file.outputs.filePath }}" >> $GITHUB_ENV

- name: assemble debug artifact
run: ./gradlew wear:assembleDebug

- name: assemble release artifact
run: ./gradlew wear:assembleRelease

- name: bundle release artifact
run: ./gradlew wear:bundleRelease

- name: upload artifacts to outputs
uses: actions/upload-artifact@v4
with:
path: |
wear/build/outputs/apk/debug
wear/build/outputs/apk/release
wear/build/outputs/bundle/release
- name: expose version name
id: version_name
run: |
VERSION_NAME=$(./gradlew wear:printVersionName -q)
echo "VERSION_NAME=$VERSION_NAME" >> $GITHUB_ENV
- name: expose version code
id: version_code
run: |
VERSION_CODE=$(./gradlew wear:printVersionCode -q)
echo "VERSION_CODE=$VERSION_CODE" >> $GITHUB_ENV
- name: expose artifacts
run: |
echo "DEBUG_APK_PATH=$(find wear/build/outputs/apk/debug -name '*.apk' -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -d' ' -f2)" >> $GITHUB_ENV
echo "RELEASE_APK_PATH=$(find wear/build/outputs/apk/release -name '*.apk' -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -d' ' -f2)" >> $GITHUB_ENV
echo "BUNDLE_APK_PATH=$(find wear/build/outputs/bundle/release -name '*.aab' -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -d' ' -f2)" >> $GITHUB_ENV
- name: send telegram message debug
env:
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
THREAD_ID: ${{ secrets.TELEGRAM_THREAD_ID }}
MESSAGE: |
✅ <b>${{ env.VERSION_NAME }} (${{ env.VERSION_CODE }})</b>
<b>Ветка:</b> ${{ github.ref_name }}
<b>Коммит:</b> <code>${{ env.SHORT_SHA }}</code>
run: |
curl -s -X POST "https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendDocument" \
-F chat_id="${CHAT_ID}" \
-F document="@${{ env.DEBUG_APK_PATH }}" \
-F caption="${{ env.MESSAGE }}" \
-F message_thread_id="${THREAD_ID}" \
-F parse_mode="HTML"
- name: send telegram message release
env:
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
THREAD_ID: ${{ secrets.TELEGRAM_THREAD_ID }}
MESSAGE: |
✅ <b>${{ env.VERSION_NAME }} (${{ env.VERSION_CODE }})</b>
<b>Ветка:</b> ${{ github.ref_name }}
<b>Коммит:</b> <code>${{ env.SHORT_SHA }}</code>
run: |
curl -s -X POST "https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendDocument" \
-F chat_id="${CHAT_ID}" \
-F document="@${{ env.RELEASE_APK_PATH }}" \
-F caption="${{ env.MESSAGE }}" \
-F message_thread_id="${THREAD_ID}" \
-F parse_mode="HTML"
- name: send telegram message bundle
env:
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
Expand Down
10 changes: 10 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ kotlinx-atomicfu = "0.26.0"
google-ksp = "2.0.21-1.0.27"
google-services = "4.4.2"
google-gson = "2.11.0"
google-horologist = "0.6.20"

google-gms-play-services-ads = "23.5.0"
google-gms-play-services-ads-identifier = "18.1.0"
Expand Down Expand Up @@ -550,6 +551,15 @@ google-material-compose-theme-adapter = { module = "com.google.android.material:
google-material-compose-theme-adapter3 = { module = "com.google.android.material:compose-theme-adapter-3", version.ref = "google-material-compose-theme-adapter" }
google-material-compose-theme-core = { module = "com.google.android.material:compose-theme-adapter-core", version.ref = "google-material-compose-theme-adapter" }
google-gson = { module = "com.google.code.gson:gson", version.ref = "google-gson" }
google-horologist-audio-ui = { module = "com.google.android.horologist:horologist-audio-ui", version.ref = "google-horologist" }
google-horologist-composables = { module = "com.google.android.horologist:horologist-composables", version.ref = "google-horologist" }
google-horologist-compose-layout = { module = "com.google.android.horologist:horologist-compose-layout", version.ref = "google-horologist" }
google-horologist-compose-material = { module = "com.google.android.horologist:horologist-compose-material", version.ref = "google-horologist" }
google-horologist-compose-tools = { module = "com.google.android.horologist:horologist-compose-tools", version.ref = "google-horologist" }
google-horologist-images-coil = { module = "com.google.android.horologist:horologist-images-coil", version.ref = "google-horologist" }
google-horologist-media-data = { module = "com.google.android.horologist:horologist-media-data", version.ref = "google-horologist" }
google-horologist-media-ui = { module = "com.google.android.horologist:horologist-media-ui", version.ref = "google-horologist" }
google-horologist-roboscreenshots = { module = "com.google.android.horologist:horologist-roboscreenshots", version.ref = "google-horologist" }
#endregion
#region firebase
google-firebase-abt = { module = "com.google.firebase:firebase-abt", version.ref = "google-firebase-abt" }
Expand Down
14 changes: 0 additions & 14 deletions mobile/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,6 @@ base {
archivesName.set("Template-v${android.defaultConfig.versionName}(${android.defaultConfig.versionCode})") // Replace with your own app's name
}

tasks.register("prepareReleaseNotes") {
doLast {
exec {
workingDir(rootDir)
executable("./.github/scripts/gitlog.sh")
}
}
}

tasks.register("printVersionName") {
doLast {
println(android.defaultConfig.versionName)
Expand All @@ -120,9 +111,4 @@ tasks.register("printVersionCode") {
doLast {
println(android.defaultConfig.versionCode.toString())
}
}

afterEvaluate {
tasks.findByName("assembleDebug")?.finalizedBy("prepareReleaseNotes")
tasks.findByName("assembleRelease")?.finalizedBy("prepareReleaseNotes")
}
3 changes: 1 addition & 2 deletions mobile/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:ignore="ImpliedTouchscreenHardware,MissingLeanbackLauncher,MissingLeanbackSupport">
xmlns:tools="http://schemas.android.com/tools">

<application
android:name=".App"
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dependencyResolutionManagement {
}
include(
":mobile",
":wear",
":core"
)
rootProject.name = "android-template" // todo Replace with your own app’s name
122 changes: 122 additions & 0 deletions wear/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
import org.apache.commons.io.output.ByteArrayOutputStream
import java.io.FileInputStream
import java.nio.charset.Charset
import java.util.Properties

plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.google.ksp)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.kotlin.compose)
}

private val gitCommitsCount: Int by lazy {
val stdout = ByteArrayOutputStream()
exec {
commandLine("git", "rev-list", "--count", "HEAD")
standardOutput = stdout
}
stdout.toString(Charset.defaultCharset()).trim().toInt()
}

kotlin {
jvmToolchain(libs.versions.jdk.get().toInt())
}

android {
namespace = "org.michaelbel.template" // Replace with your own namespace
compileSdk = libs.versions.compile.sdk.get().toInt()

defaultConfig {
applicationId = "org.michaelbel.template" // Replace with your own applicationId
minSdk = libs.versions.min.sdk.get().toInt()
targetSdk = libs.versions.target.sdk.get().toInt()
versionName = "1.0.0"
versionCode = gitCommitsCount
}

signingConfigs {
val keystoreProperties = Properties()
val keystorePropertiesFile: File = rootProject.file("config/keystore.properties")
if (keystorePropertiesFile.exists()) {
keystoreProperties.load(FileInputStream(keystorePropertiesFile))

create("release") {
keyAlias = keystoreProperties["keyAlias"] as String
keyPassword = keystoreProperties["keyPassword"] as String
storeFile = file(keystoreProperties["storeFile"] as String)
storePassword = keystoreProperties["storePassword"] as String
}
} else {
val keystoreAlias = System.getenv("KEYSTORE_KEY_ALIAS").orEmpty()
val keystorePassword = System.getenv("KEYSTORE_KEY_PASSWORD").orEmpty()
val keystoreStorePassword = System.getenv("KEYSTORE_STORE_PASSWORD").orEmpty()
val keystoreFile = System.getenv("KEYSTORE_FILE").orEmpty()
if (keystoreAlias.isNotEmpty()) {
keystoreProperties["keyAlias"] = keystoreAlias
keystoreProperties["keyPassword"] = keystorePassword
keystoreProperties["storePassword"] = keystoreStorePassword
keystoreProperties["storeFile"] = keystoreFile

create("release") {
keyAlias = keystoreProperties["keyAlias"] as String
keyPassword = keystoreProperties["keyPassword"] as String
storeFile = file(keystoreProperties["storeFile"] as String)
storePassword = keystoreProperties["storePassword"] as String
}
}
}
}

buildTypes {
release {
isDebuggable = false
isMinifyEnabled = true
isShrinkResources = true
signingConfig = if (signingConfigs.findByName("release") != null) signingConfigs.getByName("release") else null
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
}
debug {
isDebuggable = true
isMinifyEnabled = false
isShrinkResources = false
applicationIdSuffix = ".debug"
}
}

buildFeatures {
buildConfig = true
compose = true
}
}

dependencies {
implementation(project(":core"))
api(libs.androidx.room.ktx)
ksp(libs.androidx.room.compiler)

implementation(libs.androidx.wear.compose.foundation)
implementation(libs.androidx.wear.compose.material3)
implementation(libs.androidx.wear.compose.navigation)
implementation(libs.androidx.wear.compose.ui.tooling)
implementation(libs.google.horologist.composables)
implementation(libs.google.horologist.compose.layout)
implementation(libs.google.horologist.compose.material)
}

base {
archivesName.set("Template-v${android.defaultConfig.versionName}(${android.defaultConfig.versionCode})") // Replace with your own app's name
}

tasks.register("printVersionName") {
doLast {
println(android.defaultConfig.versionName)
}
}

tasks.register("printVersionCode") {
doLast {
println(android.defaultConfig.versionCode.toString())
}
}
26 changes: 26 additions & 0 deletions wear/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.kts.kts.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile

# DataStore
-keepclassmembers class * extends androidx.datastore.preferences.protobuf.GeneratedMessageLite {
<fields>;
}
Loading

0 comments on commit 653a05f

Please sign in to comment.