Skip to content

Commit

Permalink
chore: Update AGP
Browse files Browse the repository at this point in the history
  • Loading branch information
omg-xtao committed Mar 15, 2024
1 parent 7965ae4 commit c3ed461
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 107 deletions.
73 changes: 10 additions & 63 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,6 @@ jobs:
runs-on: ubuntu-latest
needs:
- native
strategy:
matrix:
flavor:
# - FullRelease
- MiniRelease
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down Expand Up @@ -227,88 +222,40 @@ jobs:
- name: Release Build
run: |
export LOCAL_PROPERTIES="${{ secrets.LOCAL_PROPERTIES }}"
./gradlew TMessagesProj:assemble${{ matrix.flavor }}
./gradlew TMessagesProj:assembleMiniRelease
APK=$(find TMessagesProj/build/outputs/apk -name '*arm64-v8a*.apk')
APK=$(dirname $APK)
echo "APK=$APK" >> $GITHUB_ENV
- uses: actions/upload-artifact@v2
with:
name: ${{ matrix.flavor }}
name: MiniRelease
path: ${{ env.APK }}
upload:
name: Upload release
if: github.event.inputs.upload != 'y'
runs-on: ubuntu-latest
needs:
- build
- telegram-bot-api
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Donwload Artifacts
uses: actions/download-artifact@v2
with:
path: artifacts
- name: Download Telegram Bot API Binary
uses: actions/download-artifact@master
- name: Set up Python
uses: actions/setup-python@v5
with:
name: telegram-bot-api-binary
path: .
python-version: 3.12
- name: Send to Telegram
run: |
chmod +x telegram-bot-api-binary
function start() {
./telegram-bot-api-binary --api-id=11535358 --api-hash=33d372962fadb01df47e6ceed4e33cd6 --local 2>&1 > /dev/null &
}
start
curl http://127.0.0.1:8081/ || start
curl http://127.0.0.1:8081/ || start
curl http://127.0.0.1:8081/ || start
# send release via telegram bot api
export mini64=$(find artifacts -name "*arm64-v8a.apk")
export mini32=$(find artifacts -name "*armeabi-v7a.apk")
# export full64=$(find artifacts -name "*full-arm64-v8a.apk")
# export full32=$(find artifacts -name "*full-armeabi-v7a.apk")
# export mini64nogcm=$(find artifacts -name "*arm64-v8aNoGcm.apk")
# export mini32nogcm=$(find artifacts -name "*armeabi-v7aNoGcm.apk")
# export full64nogcm=$(find artifacts -name "*full-arm64-v8aNoGcm.apk")
# export full32nogcm=$(find artifacts -name "*full-armeabi-v7aNoGcm.apk")
echo $mini64
curl --http0.9 http://127.0.0.1:8081/bot${{ secrets.HELPER_BOT_TOKEN }}/sendMediaGroup --form-string chat_id=${{ secrets.HELPER_BOT_TARGET }} --form apk1=@"${mini64}" --form apk2=@"${mini32}" --form-string media="[{\"type\": \"document\",\"media\": \"attach://apk1\",\"caption\": \"\",\"parse_mode\": \"Markdown\"},{\"type\": \"document\",\"media\": \"attach://apk2\",\"caption\": \"${{ github.event.head_commit.message }}\",\"parse_mode\": \"Markdown\"}]" --verbose >/dev/null
echo $mini32
pkill telegram-bot
telegram-bot-api:
name: Telegram Bot API
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Clone Telegram Bot API
run: |
git clone --recursive https://github.com/tdlib/telegram-bot-api.git
git status telegram-bot-api >> telegram-bot-api-status
- name: Cache Bot API Binary
id: cache-bot-api
uses: actions/cache@v2
with:
path: telegram-bot-api-binary
key: CI-telegram-bot-api-${{ hashFiles('telegram-bot-api-status') }}
- name: Compile Telegram Bot API
if: steps.cache-bot-api.outputs.cache-hit != 'true'
run: |
sudo apt-get update
sudo apt-get install make git zlib1g-dev libssl-dev gperf cmake g++
cd telegram-bot-api
rm -rf build
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=.. ..
cmake --build . --target install -j$(nproc)
cd ../..
ls -l telegram-bot-api/bin/telegram-bot-api*
cp telegram-bot-api/bin/telegram-bot-api telegram-bot-api-binary
- name: Upload Binary
uses: actions/upload-artifact@master
with:
name: telegram-bot-api-binary
path: telegram-bot-api-binary
python -m pip install -r bin/scripts/requirements.txt
python bin/scripts/upload.py ${{ secrets.HELPER_BOT_TOKEN }} ${{ secrets.HELPER_BOT_TARGET }} release
57 changes: 21 additions & 36 deletions TMessagesProj/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ android {
universalApk true
} else {
enable true
reset()
universalApk false
if (!nativeTarget.isBlank()) {
reset()
include nativeTarget
universalApk false
} else {
universalApk true
include 'armeabi-v7a', 'arm64-v8a'
}
}
}
Expand Down Expand Up @@ -220,15 +220,13 @@ android {
sourceSets {

main {
jni.srcDirs = []
assets.srcDirs = ["src/main/assets", "src/emojis/twitter"]
}

debug {
java {
srcDirs "src/main/java", "src/gservcies/java"
}
jni.srcDirs = []
jniLibs {
srcDir "src/main/libs"
}
Expand All @@ -238,7 +236,6 @@ android {
}

releaseNoGcm {
jni.srcDirs = []
jniLibs {
srcDir "src/main/libs"
}
Expand All @@ -248,7 +245,6 @@ android {
java {
srcDirs "src/main/java", "src/gservcies/java"
}
jni.srcDirs = []
jniLibs {
srcDir "src/main/libs"
}
Expand All @@ -257,16 +253,8 @@ android {
}
}

foss {
jni {
srcDirs = ["./jni/"]
}
}

fdroidRelease {
jni {
srcDirs = ["./jni/"]
}
jniLibs.srcDirs = []
}

Expand All @@ -280,7 +268,7 @@ android {
}
}

tasks.all { task ->
tasks.configureEach { task ->
if (((task.name.endsWith("Ndk") || task.name.startsWith("generateJsonModel") || task.name.startsWith("externalNativeBuild"))) && !(task.name.contains("Debug") || task.name.contains("Foss") || task.name.contains("Fdroid"))) {
task.enabled = false
}
Expand All @@ -292,8 +280,8 @@ android {
}
}

applicationVariants.all { variant ->
variant.outputs.all { output ->
applicationVariants.configureEach { variant ->
variant.outputs.configureEach { output ->
String gramName = "PagerGram"
String first = String.format("%s-v%s(%s)", gramName, versionName, versionCode)
String name = outputFileName.replace("TMessagesProj", first)
Expand All @@ -305,18 +293,18 @@ android {

}

def fcmVersion = "23.0.7"
def crashlyticsVersion = "18.2.12"
def fcmVersion = "23.4.1"
def crashlyticsVersion = "18.6.2"
def playCoreVersion = "1.10.3"

dependencies {

implementation "androidx.browser:browser:1.5.0"
implementation 'androidx.fragment:fragment:1.2.0'
implementation "androidx.core:core-ktx:1.9.0"
implementation "androidx.core:core-ktx:1.10.0"
implementation "androidx.palette:palette-ktx:1.0.0"
implementation "androidx.viewpager:viewpager:1.0.0"
implementation "androidx.exifinterface:exifinterface:1.3.6"
implementation "androidx.exifinterface:exifinterface:1.3.7"
implementation "androidx.interpolator:interpolator:1.0.0"
implementation "androidx.dynamicanimation:dynamicanimation:1.0.0"
implementation "androidx.multidex:multidex:2.0.1"
Expand All @@ -330,10 +318,10 @@ dependencies {
//noinspection GradleDependency
implementation "com.googlecode.mp4parser:isoparser:1.0.6"

implementation "com.google.code.gson:gson:2.8.9"
implementation "com.google.code.gson:gson:2.10"
implementation "org.osmdroid:osmdroid-android:6.1.10"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1"
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.23'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.0'

implementation "com.squareup.okhttp3:okhttp:5.0.0-alpha.10"
implementation 'com.neovisionaries:nv-websocket-client:2.14'
Expand All @@ -348,9 +336,6 @@ dependencies {

implementation 'com.google.android.gms:play-services-mlkit-subject-segmentation:16.0.0-beta1'

compileOnly 'org.yaml:snakeyaml:1.29'
implementation 'org.yaml:snakeyaml:1.29'

implementation project(":openpgp-api")

compileOnly fileTree("libs")
Expand All @@ -360,10 +345,8 @@ dependencies {
compileOnly "com.google.android.play:core:$playCoreVersion"

implementation 'com.google.android.gms:play-services-vision:20.1.3'
debugImplementation 'com.google.android.gms:play-services-maps:18.1.0'
debugImplementation 'com.google.android.gms:play-services-location:20.0.0'
releaseImplementation 'com.google.android.gms:play-services-maps:18.1.0'
releaseImplementation 'com.google.android.gms:play-services-location:20.0.0'
implementation 'com.google.android.gms:play-services-maps:18.2.0'
implementation 'com.google.android.gms:play-services-location:21.2.0'

debugImplementation "com.google.firebase:firebase-messaging:$fcmVersion"
debugImplementation "com.google.firebase:firebase-crashlytics:$crashlyticsVersion"
Expand All @@ -383,11 +366,11 @@ dependencies {
// add for undo and redo
implementation 'org.lsposed.hiddenapibypass:hiddenapibypass:4.3'
// add splash screen
implementation("androidx.core:core-splashscreen:1.0.0-beta02")
implementation("androidx.core:core-splashscreen:1.0.1")
// add for music tag flac...
implementation 'org:jaudiotagger:2.0.3'
// add for auto translate
implementation 'com.google.mlkit:language-id:17.0.4'
implementation 'com.google.mlkit:language-id:17.0.5'
// add for emoji
implementation 'com.jaredrummler:truetypeparser-light:1.0.0'
}
Expand Down Expand Up @@ -416,8 +399,11 @@ android {
lint {
disable 'MissingTranslation', 'ExtraTranslation', 'BlockedPrivateApi'
}
buildFeatures {
buildConfig true
}

tasks.all { task ->
tasks.configureEach { task ->
if (task.name.startsWith("uploadCrashlyticsMappingFile")) {
task.enabled = false
} else if (task.name.contains("Crashlytics") && task.name.contains("NoGcm")) {
Expand All @@ -426,5 +412,4 @@ android {
task.enabled = false
}
}

}
8 changes: 8 additions & 0 deletions TMessagesProj/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,11 @@
-dontwarn org.osmdroid.**

-keepattributes SourceFile,LineNumberTable

-dontwarn java.beans.**
-dontwarn java.lang.management.**
-dontwarn javax.swing.**
-dontwarn lombok.**
-dontwarn org.slf4j.**
-dontwarn org.w3c.dom.bootstrap.**
-dontwarn sun.net.spi.nameservice.**
2 changes: 2 additions & 0 deletions bin/scripts/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
git+https://github.com/KurimuzonAkuma/pyrogram
PyroTgCrypto==1.2.6a0
87 changes: 87 additions & 0 deletions bin/scripts/upload.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import contextlib
import subprocess
from pathlib import Path
from sys import argv

from pyrogram import Client
from pyrogram.types import InputMediaDocument

api_id = 11535358
api_hash = "33d372962fadb01df47e6ceed4e33cd6"
artifacts_path = Path("artifacts")
test_version = argv[3] == "test"


def find_apk(abi: str) -> Path:
apks = list(artifacts_path.glob("*.apk"))
for apk in apks:
if abi in apk.name:
return apk


def get_thumb() -> str:
return "TMessagesProj/src/main/" + "ic_launcher_nagram_round_blue-playstore.png"


def get_caption() -> str:
pre = "Test version, " if test_version else ""
return pre + subprocess.check_output('git log -1 --pretty=format:"%s"').decode('utf-8')


def get_document() -> list[InputMediaDocument]:
return [
InputMediaDocument(
media=str(find_apk("arm64-v8a")),
thumb=get_thumb(),
),
InputMediaDocument(
media=str(find_apk("armeabi-v7a")),
thumb=get_thumb(),
caption=get_caption(),
),
]


def retry(func):
async def wrapper(*args, **kwargs):
for _ in range(3):
try:
return await func(*args, **kwargs)
except Exception as e:
print(e)

return wrapper


@retry
async def send_to_channel(client: "Client", cid: str):
with contextlib.suppress(ValueError):
cid = int(cid)
await client.send_media_group(
cid,
media=get_document(),
)


def get_client(bot_token: str):
return Client(
"helper_bot",
api_id=api_id,
api_hash=api_hash,
bot_token=bot_token,
)


async def main():
bot_token = argv[1]
chat_id = argv[2]
client = get_client(bot_token)
await client.start()
await send_to_channel(client, chat_id)
await client.log_out()


if __name__ == "__main__":
from asyncio import run

run(main())
Loading

0 comments on commit c3ed461

Please sign in to comment.