Skip to content

Commit bfc699d

Browse files
authored
Update build-apk.yml
1 parent 70940ee commit bfc699d

File tree

1 file changed

+39
-25
lines changed

1 file changed

+39
-25
lines changed

.github/workflows/build-apk.yml

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -43,56 +43,70 @@ jobs:
4343
- name: Build release APK
4444
run: ./gradlew assembleRelease --stacktrace
4545

46-
- name: Find APK path dynamically
47-
id: find_apk
46+
47+
- name: Get App Version from Gradle
48+
id: get_version
4849
run: |
49-
APK_PATH=$(find app/build/outputs -name "*.apk" | head -n 1)
50-
echo "APK_PATH=$APK_PATH" >> $GITHUB_ENV
51-
echo "apk=$APK_PATH" >> $GITHUB_OUTPUT
50+
# build.gradle'dan versionName ve versionCode'u oku (örneğin)
51+
# Bu, APK'nızın gerçek versiyonuyla eşleşmesini sağlar
52+
VERSION_NAME=$(grep "versionName" app/build.gradle | awk -F "'" '{print $2}')
53+
VERSION_CODE=$(grep "versionCode" app/build.gradle | awk '{print $2}')
54+
echo "APP_VERSION_NAME=$VERSION_NAME" >> $GITHUB_ENV
55+
echo "APP_VERSION_CODE=$VERSION_CODE" >> $GITHUB_ENV
56+
echo "RELEASE_TAG=v${VERSION_NAME}-$(date +'%Y.%m.%d-%H%M%S')" >> $GITHUB_ENV # Daha detaylı bir etiket
57+
58+
# Eğer build.gradle'da versionCode dinamik ise, buraya uygun bir şekilde okuyun.
59+
# Örneğin: versionCode 1
60+
# VEYA, her build'de benzersiz bir versionCode oluşturmak için:
61+
# echo "APP_VERSION_CODE=$(date +%s)" >> $GITHUB_ENV # Unix timestamp olarak
5262
53-
- name: Rename and move APK to root
63+
- name: Find APK path dynamically
64+
id: find_apk
5465
run: |
55-
cp app/build/outputs/apk/release/app-release.apk ./BirthdayReminder-${{ env.RELEASE_TAG }}.apk
56-
66+
# Bu adımı APK'yı dinamik bulmak için kullanmaya devam edebiliriz.
67+
# Ancak, daha sonra daha iyi bir isimlendirme ve taşıma yapacağız.
68+
# find app/build/outputs -name "*.apk" | head -n 1
69+
# Yukarıdaki satırı silebiliriz, çünkü bir sonraki adımda doğrudan doğru APK'yı alacağız.
5770
58-
- name: Generate pretty version tag
59-
id: version
71+
- name: Rename and move APK for consistent naming
6072
run: |
61-
RELEASE_TAG="v1.0.0-$(date +'%Y.%m.%d')"
62-
echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV
63-
echo "release_tag=$RELEASE_TAG" >> $GITHUB_OUTPUT
64-
73+
# app-release.apk'yi gerçek versiyon ve etiketle yeniden adlandır
74+
# 'app/build/outputs/apk/release' yolu Gradle sürümüne veya varyantına göre değişebilir
75+
APK_INPUT_PATH=$(find app/build/outputs -name "app-release.apk" -print -quit)
76+
if [ -z "$APK_INPUT_PATH" ]; then
77+
echo "Error: app-release.apk not found!"
78+
exit 1
79+
fi
80+
NEW_APK_NAME="BirthdayReminder-${{ env.RELEASE_TAG }}.apk"
81+
cp "$APK_INPUT_PATH" "./$NEW_APK_NAME"
82+
echo "NEW_APK_NAME=$NEW_APK_NAME" >> $GITHUB_ENV # update.json için kullanmak üzere ayarla
6583
6684
- name: Create update.json
6785
run: |
68-
VERSION_NAME=1.0.0
69-
VERSION_CODE=$(date +%s) # otomatik versiyon kodu
70-
echo "VERSION_NAME=$VERSION_NAME" >> $GITHUB_ENV
7186
echo '{
72-
"versionCode": '"$VERSION_CODE"',
73-
"versionName": "'"$VERSION_NAME"'",
74-
"apkUrl": "https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/BirthdayReminder-v'"$VERSION_NAME"'.apk",
75-
"changelog": "Otomatik yayın"
87+
"versionCode": '"${{ env.APP_VERSION_CODE }}"',
88+
"versionName": "'"${{ env.APP_VERSION_NAME }}"'",
89+
"apkUrl": "https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/releases/${{ env.NEW_APK_NAME }}",
90+
"changelog": "Otomatik yayın - ${{ env.RELEASE_TAG }}"
7691
}' > update.json
7792
7893
- name: Upload update.json and APK to GitHub Pages
7994
uses: peaceiris/actions-gh-pages@v3
8095
with:
8196
github_token: ${{ secrets.GITHUB_TOKEN }}
82-
publish_dir: ./ # Burada hem APK hem update.json var
83-
destination_dir: releases
97+
publish_dir: ./
98+
destination_dir: releases
8499

85100
- name: Create GitHub Release and upload APK
86101
uses: softprops/action-gh-release@v1
87102
with:
88103
tag_name: ${{ env.RELEASE_TAG }}
89104
name: ${{ env.RELEASE_TAG }}
90105
body: "Otomatik yayın"
91-
files: BirthdayReminder-${{ env.RELEASE_TAG }}.apk
106+
files: ${{ env.NEW_APK_NAME }}
92107
env:
93108
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
94109

95-
96110
env:
97111
KEYSTORE_FILE_PATH: ${{ secrets.KEYSTORE_FILE_PATH }}
98112
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}

0 commit comments

Comments
 (0)