Skip to content

Commit d296b3c

Browse files
committed
Update project
1 parent 338e691 commit d296b3c

File tree

5 files changed

+80
-23
lines changed

5 files changed

+80
-23
lines changed

.github/workflows/ci.yml

Lines changed: 72 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Check Commit CI
1+
name: CI
22

33
on:
44
push:
@@ -14,12 +14,27 @@ concurrency:
1414
cancel-in-progress: false
1515

1616
jobs:
17-
build:
17+
job-common:
18+
runs-on: ubuntu-latest
19+
outputs:
20+
SHORT_SHA: ${{ steps.expose_sha.outputs.short_sha }}
21+
steps:
22+
- name: expose short commit sha
23+
id: expose_sha
24+
run: |
25+
SHORT_SHA=${GITHUB_SHA::7}
26+
echo "short_sha=$SHORT_SHA" >> $GITHUB_ENV
27+
echo "SHORT_SHA=$SHORT_SHA" >> $GITHUB_OUTPUT
28+
29+
build-android:
30+
if: ${{ vars.ANDROID_BUILD_ENABLED == 'true' }}
31+
needs: job-common
1832
env:
1933
KEYSTORE_FILE: ${{ secrets.KEYSTORE_FILE }}
2034
KEYSTORE_KEY_ALIAS: ${{ secrets.KEYSTORE_KEY_ALIAS }}
2135
KEYSTORE_KEY_PASSWORD: ${{ secrets.KEYSTORE_KEY_PASSWORD }}
2236
KEYSTORE_STORE_PASSWORD: ${{ secrets.KEYSTORE_STORE_PASSWORD }}
37+
SHORT_SHA: ${{ needs.job-common.outputs.SHORT_SHA }}
2338
runs-on: ubuntu-latest
2439
timeout-minutes: 60
2540
steps:
@@ -54,17 +69,32 @@ jobs:
5469
- name: make gradlew executable
5570
run: chmod +x ./gradlew
5671

72+
- name: decode keystore file
73+
id: decode_keystore_file
74+
uses: timheuer/base64-to-file@v1
75+
with:
76+
fileName: 'keystore_release.jks'
77+
encodedString: ${{ secrets.KEYSTORE_FILE }}
78+
79+
- name: set decoded file location as environment
80+
run: echo "KEYSTORE_FILE=${{ steps.decode_keystore_file.outputs.filePath }}" >> $GITHUB_ENV
81+
5782
- name: assemble debug artifact
5883
run: ./gradlew assembleDebug
5984

60-
# - name: assemble release artifact
61-
# run: ./gradlew assembleRelease
85+
- name: assemble release artifact
86+
run: ./gradlew assembleRelease
87+
88+
- name: bundle release artifact
89+
run: ./gradlew bundleRelease
6290

6391
- name: upload artifacts to outputs
6492
uses: actions/upload-artifact@v4
6593
with:
6694
path: |
67-
app/build/outputs/apk
95+
app/build/outputs/apk/debug
96+
app/build/outputs/apk/release
97+
app/build/outputs/bundle/release
6898
6999
- name: expose version name
70100
id: version_name
@@ -78,21 +108,47 @@ jobs:
78108
VERSION_CODE=$(./gradlew printVersionCode -q)
79109
echo "VERSION_CODE=$VERSION_CODE" >> $GITHUB_ENV
80110
81-
- name: list all apk files
111+
- name: expose artifacts
82112
run: |
83-
echo "APKs:"
84-
for apk in $(find app/build/outputs/apk -name '*.apk'); do
85-
echo "$apk"
86-
done
113+
echo "DEBUG_APK_PATH=$(find app/build/outputs/apk/debug -name '*.apk' -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -d' ' -f2)" >> $GITHUB_ENV
114+
echo "RELEASE_APK_PATH=$(find app/build/outputs/apk/release -name '*.apk' -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -d' ' -f2)" >> $GITHUB_ENV
115+
echo "BUNDLE_APK_PATH=$(find app/build/outputs/bundle/release -name '*.apk' -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -d' ' -f2)" >> $GITHUB_ENV
87116
88-
- name: expose apk path
117+
- name: send telegram message debug
118+
env:
119+
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
120+
CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
121+
THREAD_ID: ${{ secrets.TELEGRAM_THREAD_ID }}
122+
MESSAGE: |
123+
✅ <b>${{ env.VERSION_NAME }} (${{ env.VERSION_CODE }})</b>
124+
<b>Ветка:</b> ${{ github.ref_name }}
125+
<b>Коммит:</b> <code>${{ env.SHORT_SHA }}</code>
89126
run: |
90-
echo "APK_PATH=$(find app/build/outputs/apk -name '*.apk' -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -d' ' -f2)" >> $GITHUB_ENV
127+
curl -s -X POST "https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendDocument" \
128+
-F chat_id="${CHAT_ID}" \
129+
-F document="@${{ env.DEBUG_APK_PATH }}" \
130+
-F caption="${{ env.MESSAGE }}" \
131+
-F message_thread_id="${THREAD_ID}" \
132+
-F parse_mode="HTML"
91133
92-
- name: expose short commit sha
93-
run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV
134+
- name: send telegram message release
135+
env:
136+
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
137+
CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
138+
THREAD_ID: ${{ secrets.TELEGRAM_THREAD_ID }}
139+
MESSAGE: |
140+
✅ <b>${{ env.VERSION_NAME }} (${{ env.VERSION_CODE }})</b>
141+
<b>Ветка:</b> ${{ github.ref_name }}
142+
<b>Коммит:</b> <code>${{ env.SHORT_SHA }}</code>
143+
run: |
144+
curl -s -X POST "https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendDocument" \
145+
-F chat_id="${CHAT_ID}" \
146+
-F document="@${{ env.RELEASE_APK_PATH }}" \
147+
-F caption="${{ env.MESSAGE }}" \
148+
-F message_thread_id="${THREAD_ID}" \
149+
-F parse_mode="HTML"
94150
95-
- name: send telegram message
151+
- name: send telegram message bundle
96152
env:
97153
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
98154
CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
@@ -104,7 +160,7 @@ jobs:
104160
run: |
105161
curl -s -X POST "https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendDocument" \
106162
-F chat_id="${CHAT_ID}" \
107-
-F document="@${{ env.APK_PATH }}" \
163+
-F document="@${{ env.BUNDLE_APK_PATH }}" \
108164
-F caption="${{ env.MESSAGE }}" \
109165
-F message_thread_id="${THREAD_ID}" \
110166
-F parse_mode="HTML"

app/build.gradle.kts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ android {
3434
targetSdk = libs.versions.target.sdk.get().toInt()
3535
versionName = "1.0.0"
3636
versionCode = gitCommitsCount
37-
setProperty("archivesBaseName", "Template-v$versionName($versionCode)") // Replace with your own app's name
3837
}
3938

4039
signingConfigs {
@@ -98,6 +97,10 @@ dependencies {
9897
ksp(libs.androidx.room.compiler)
9998
}
10099

100+
base {
101+
archivesName.set("Template-v${android.defaultConfig.versionName}(${android.defaultConfig.versionCode})") // Replace with your own app's name
102+
}
103+
101104
tasks.register("prepareReleaseNotes") {
102105
doLast {
103106
exec {

app/src/main/kotlin/org/michaelbel/template/ktor/AppService.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ class AppService(
99
private val httpClient: HttpClient
1010
) {
1111

12-
suspend fun getAppResponse(
13-
id: Int
14-
): AppResponse {
12+
suspend fun getAppResponse(id: Int): AppResponse {
1513
return httpClient.get("route/$id") {
1614
parameter("key", "1234")
1715
}.body()

app/src/main/kotlin/org/michaelbel/template/ui/MainActivityContent.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ import org.michaelbel.template.MainViewModel
5151

5252
@Composable
5353
fun MainActivityContent(
54-
viewModel: MainViewModel = koinViewModel(),
55-
modifier: Modifier = Modifier
54+
modifier: Modifier = Modifier,
55+
viewModel: MainViewModel = koinViewModel()
5656
) {
5757
val navHostController = rememberNavController()
5858
var selectedRoute by remember { mutableStateOf("home") }

readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ This Android app template provides a foundation for quickly starting development
2424
* In `settings.gradle.kts`, update `rootProject.name`.
2525
* Rename the application package.
2626
* In the `build.gradle` file of the core module, update the `namespace`.
27-
* In the `build.gradle` file of the app module, update the `namespace`, `applicationId`, and `archivesBaseName`. If a release version is needed, add a `keystore.properties` file in the `config` directory.
27+
* In the `build.gradle` file of the app module, update the `namespace`, `applicationId`, and `archivesName`. If a release version is needed, add a `keystore.properties` file in the `config` directory.
2828
* In `strings.xml`, update `app_name`.

0 commit comments

Comments
 (0)