Skip to content

Commit f5f2383

Browse files
author
Mike Lau
committed
Updated Compose version, updated Github workflow
1 parent 89ddad6 commit f5f2383

4 files changed

Lines changed: 75 additions & 42 deletions

File tree

.github/workflows/main.yml

Lines changed: 61 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,76 @@
1-
name: main
2-
'on':
1+
name: Build and Upload APK
2+
3+
on:
34
push:
45
tags:
5-
- '*'
6+
- 'v*'
7+
8+
permissions:
9+
contents: write
10+
611
jobs:
7-
apk:
8-
name: Generate APK
12+
build:
13+
name: Build Pokedex App
914
runs-on: ubuntu-latest
15+
1016
steps:
11-
- name: Checkout
12-
uses: actions/checkout@v2.4.0
13-
- name: Setup JDK
14-
uses: actions/setup-java@v2.5.0
17+
# Checkout the repository
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
# Extract versionName and versionCode from the tag
22+
- name: Extract version info
23+
id: extract_version
24+
run: |
25+
TAG_NAME=${GITHUB_REF#refs/tags/}
26+
VERSION_NAME=$(echo $TAG_NAME | sed 's/^v//' | cut -d'-' -f1)
27+
VERSION_CODE=$(echo $TAG_NAME | cut -d'-' -f2)
28+
echo "VERSION_NAME=$VERSION_NAME" >> $GITHUB_ENV
29+
echo "VERSION_CODE=$VERSION_CODE" >> $GITHUB_ENV
30+
31+
# Set up JDK for Android
32+
- name: Set up JDK 17
33+
uses: actions/setup-java@v3
1534
with:
16-
distribution: temurin
1735
java-version: '17'
18-
- name: Set execution flag for gradlew
19-
run: chmod +x gradlew
36+
distribution: 'temurin'
37+
38+
# Set up Android SDK
39+
- name: Set up Android SDK
40+
uses: android-actions/setup-android@v3
41+
42+
# Build the APK with versionName and versionCode
2043
- name: Build APK
21-
run: bash ./gradlew assembleDebug --stacktrace
22-
- name: Upload APK
23-
uses: actions/upload-artifact@v1
24-
with:
25-
name: apk
26-
path: app/build/outputs/apk/debug/app-debug.apk
27-
release:
28-
name: Release APK
29-
needs: apk
30-
runs-on: ubuntu-latest
31-
steps:
32-
- name: Download APK from build
33-
uses: actions/download-artifact@v1
34-
with:
35-
name: apk
44+
run: |
45+
./gradlew assembleDebug -PversionName=$VERSION_NAME -PversionCode=$VERSION_CODE
46+
47+
# Find the generated APK file
48+
- name: Find APK
49+
id: find_apk
50+
run: |
51+
APK_PATH=$(find app/build/outputs/apk -name "app-*.apk" | head -n 1)
52+
echo "APK_PATH=$APK_PATH" >> $GITHUB_ENV
53+
echo "APK_NAME=$(basename $APK_PATH)" >> $GITHUB_ENV
54+
55+
# Create a GitHub Release
3656
- name: Create Release
3757
id: create_release
3858
uses: actions/create-release@v1
39-
env:
40-
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
4159
with:
4260
tag_name: ${{ github.ref_name }}
43-
release_name: '${{ github.event.repository.name }} v${{ github.ref_name }}'
44-
- name: Upload Release APK
45-
id: upload_release_asset
46-
uses: actions/upload-release-asset@v1.0.1
61+
release_name: Release ${{ github.ref_name }}
62+
draft: false
63+
prerelease: false
4764
env:
48-
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
65+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
67+
# Upload APK to GitHub Release
68+
- name: Upload APK to Release
69+
uses: actions/upload-release-asset@v1
4970
with:
50-
upload_url: '${{ steps.create_release.outputs.upload_url }}'
51-
asset_path: apk/app-debug.apk
52-
asset_name: '${{ github.event.repository.name }}.apk'
53-
asset_content_type: application/zip
71+
upload_url: ${{ steps.create_release.outputs.upload_url }}
72+
asset_path: ${{ env.APK_PATH }}
73+
asset_name: ${{ env.APK_NAME }}
74+
asset_content_type: application/vnd.android.package-archive
75+
env:
76+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

app/build.gradle.kts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,18 @@ android {
1616
applicationId = "com.mikelau.pokedex"
1717
minSdk = 24
1818
targetSdk = 36
19-
versionCode = 3
20-
versionName = "2.1.0"
19+
20+
versionName = if (project.hasProperty("versionName")) {
21+
project.property("versionName") as String
22+
} else {
23+
"2.2.0"
24+
}
25+
26+
versionCode = if (project.hasProperty("versionCode")) {
27+
(project.property("versionCode") as String).toInt()
28+
} else {
29+
5
30+
}
2131

2232
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
2333
vectorDrawables {

feature/pokemon/ui/src/main/java/com/mikelau/feature/pokemon/ui/screen/PokemonViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class PokemonViewModel @Inject constructor(private val getPokemonListUseCase: Ge
5454
})
5555
} else if(_query.value.isNotBlank()) {
5656
_pokemonList.value = PokemonStateHolder(data = it.data?.filter {
57-
filter -> filter.name.contains(_query.value)
57+
filter -> filter.name.contains(_query.value.lowercase())
5858
})
5959
} else {
6060
_pokemonList.value = PokemonStateHolder(data = it.data)

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ androidx-test-ext-junit = "1.2.1"
88
espresso-core = "3.6.1"
99
lifecycle-runtime-ktx = "2.8.7"
1010
activity-compose = "1.10.1"
11-
compose-bom = "2025.04.00"
11+
compose-bom = "2025.04.01"
1212
appcompat = "1.7.0"
1313
material = "1.12.0"
1414
retrofit = "2.11.0"

0 commit comments

Comments
 (0)