Skip to content

Commit

Permalink
Update project
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbel committed Nov 19, 2024
1 parent 338e691 commit d296b3c
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 23 deletions.
88 changes: 72 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Check Commit CI
name: CI

on:
push:
Expand All @@ -14,12 +14,27 @@ concurrency:
cancel-in-progress: false

jobs:
build:
job-common:
runs-on: ubuntu-latest
outputs:
SHORT_SHA: ${{ steps.expose_sha.outputs.short_sha }}
steps:
- name: expose short commit sha
id: expose_sha
run: |
SHORT_SHA=${GITHUB_SHA::7}
echo "short_sha=$SHORT_SHA" >> $GITHUB_ENV
echo "SHORT_SHA=$SHORT_SHA" >> $GITHUB_OUTPUT
build-android:
if: ${{ vars.ANDROID_BUILD_ENABLED == 'true' }}
needs: job-common
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 }}
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
Expand Down Expand Up @@ -54,17 +69,32 @@ jobs:
- 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 assembleDebug

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

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

- name: upload artifacts to outputs
uses: actions/upload-artifact@v4
with:
path: |
app/build/outputs/apk
app/build/outputs/apk/debug
app/build/outputs/apk/release
app/build/outputs/bundle/release
- name: expose version name
id: version_name
Expand All @@ -78,21 +108,47 @@ jobs:
VERSION_CODE=$(./gradlew printVersionCode -q)
echo "VERSION_CODE=$VERSION_CODE" >> $GITHUB_ENV
- name: list all apk files
- name: expose artifacts
run: |
echo "APKs:"
for apk in $(find app/build/outputs/apk -name '*.apk'); do
echo "$apk"
done
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
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
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
- name: expose apk path
- 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: |
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
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: expose short commit sha
run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV
- 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
- name: send telegram message bundle
env:
TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }}
CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
Expand All @@ -104,7 +160,7 @@ jobs:
run: |
curl -s -X POST "https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendDocument" \
-F chat_id="${CHAT_ID}" \
-F document="@${{ env.APK_PATH }}" \
-F document="@${{ env.BUNDLE_APK_PATH }}" \
-F caption="${{ env.MESSAGE }}" \
-F message_thread_id="${THREAD_ID}" \
-F parse_mode="HTML"
5 changes: 4 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ android {
targetSdk = libs.versions.target.sdk.get().toInt()
versionName = "1.0.0"
versionCode = gitCommitsCount
setProperty("archivesBaseName", "Template-v$versionName($versionCode)") // Replace with your own app's name
}

signingConfigs {
Expand Down Expand Up @@ -98,6 +97,10 @@ dependencies {
ksp(libs.androidx.room.compiler)
}

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

tasks.register("prepareReleaseNotes") {
doLast {
exec {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ class AppService(
private val httpClient: HttpClient
) {

suspend fun getAppResponse(
id: Int
): AppResponse {
suspend fun getAppResponse(id: Int): AppResponse {
return httpClient.get("route/$id") {
parameter("key", "1234")
}.body()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ import org.michaelbel.template.MainViewModel

@Composable
fun MainActivityContent(
viewModel: MainViewModel = koinViewModel(),
modifier: Modifier = Modifier
modifier: Modifier = Modifier,
viewModel: MainViewModel = koinViewModel()
) {
val navHostController = rememberNavController()
var selectedRoute by remember { mutableStateOf("home") }
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ This Android app template provides a foundation for quickly starting development
* In `settings.gradle.kts`, update `rootProject.name`.
* Rename the application package.
* In the `build.gradle` file of the core module, update the `namespace`.
* 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.
* 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.
* In `strings.xml`, update `app_name`.

0 comments on commit d296b3c

Please sign in to comment.