diff --git a/.github/checkrun.py b/.github/checkrun.py index e04e0f6fa..c8c0f1a2e 100644 --- a/.github/checkrun.py +++ b/.github/checkrun.py @@ -5,13 +5,12 @@ f = open('commit.json') data = load(f) f.close() -message = data['commit']['message'] +data = data['commit']['message'] -if "\n\n" in message: - if message.split("\n\n",1)[-1].split()[0] == "[SILENT]": +if "\n\n" in data: + if data.split("\n\n",1)[-1].split()[0] == "[SILENT]": system('killall -9 python') else: print("Silence not found") else: - print("Empty Description") - + print("Empty Description") \ No newline at end of file diff --git a/.github/tg.py b/.github/tg.py index dc68d1166..5c6f7c409 100644 --- a/.github/tg.py +++ b/.github/tg.py @@ -6,7 +6,7 @@ from os import system from time import sleep as wait def deploy(): - system(f'~/bot-api --local --api-id={TG_API_ID} --api-hash={TG_API_HASH}') + system(f'./bot-api --local --api-id={TG_API_ID} --api-hash={TG_API_HASH}') def bot(): wait(10) @@ -21,7 +21,7 @@ def bot(): Signed-off-by: {data['commit']['author']['name']} ''', parse_mode=telegram.ParseMode.MARKDOWN) - bot.send_media_group(TG_POST_ID, [telegram.InputMediaDocument(open('app-x86-debug.apk', 'rb')), telegram.InputMediaDocument(open('app-x86_64-debug.apk', 'rb')), telegram.InputMediaDocument(open('app-armeabi-v7a-debug.apk', 'rb')), telegram.InputMediaDocument(open('app-arm64-v8a-debug.apk', 'rb'))]) + bot.send_media_group(TG_POST_ID, [telegram.InputMediaDocument(open('app-universal-debug.apk', 'rb')), telegram.InputMediaDocument(open('app-x86-debug.apk', 'rb')), telegram.InputMediaDocument(open('app-x86_64-debug.apk', 'rb')), telegram.InputMediaDocument(open('app-armeabi-v7a-debug.apk', 'rb')), telegram.InputMediaDocument(open('app-arm64-v8a-debug.apk', 'rb'))]) system('killall -9 python') if __name__ == '__main__': diff --git a/.github/workflows/api-compiler.yml b/.github/workflows/api-compiler.yml index 176c2d079..850ab5a6a 100644 --- a/.github/workflows/api-compiler.yml +++ b/.github/workflows/api-compiler.yml @@ -21,10 +21,10 @@ jobs: chmod 755 .github/compiler.sh .github/compiler.sh - - name: Binary Archive + - name: Upload to Archive run: | - git clone https://github.com/LibreTubeAlpha/Telegram-BotAPI bot-api - rm -rf bot-api/* + git clone https://github.com/LibreTubeAlpha/Archive bot-api + rm -rf bot-api/exec mv ~/telegram-bot-api/bin/telegram-bot-api bot-api/exec cd bot-api git add -f * diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3300df239..3c6a667b4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,14 +21,32 @@ jobs: steps: - uses: actions/checkout@v3 - uses: gradle/wrapper-validation-action@v1 + - uses: actions/setup-python@v3 + with: + python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax + architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified - - name: set up JDK 11 + - name: Check for Execution Orders + run: | + cd .github + curl https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }} > commit.json + python checkrun.py + cd .. + + - name: Set up JDK 11 uses: actions/setup-java@v3 with: java-version: 11 distribution: "temurin" cache: "gradle" + - name: Prepare for Compilation + run: | + git config --global user.name "XelXen" + git config --global user.email "78258352+XelXen@users.noreply.github.com" + git config --global credential.helper store + echo "https://XelXen:${{ secrets.GH_TOKEN }}@github.com" > ~/.git-credentials + - name: Patch and Compile run: | cd .github @@ -36,8 +54,36 @@ jobs: cd .. ./gradlew assembleDebug + - name: Upload to Archive + continue-on-error: true + run: | + git clone https://github.com/LibreTubeAlpha/Archive archive + rm -rf archive/*.apk + mv app/build/outputs/apk/debug/*.apk archive/ + cd archive + git add -f * + git commit -m "WORKFLOW: ALPHA BUILDS" + git push -u + + - name: Telegram Bot + continue-on-error: true + run: | + cd archive + curl https://libre-tube.github.io/images/LibreAlpha.png --output alpha.png + curl https://raw.githubusercontent.com/LibreTubeAlpha/Archive/main/exec --output bot-api + chmod 755 ./bot-api + echo "TG_TOKEN = '${{ secrets.TG_TOKEN }}'" > tgconfig.py + echo "TG_API_ID = '${{ secrets.TG_API_ID }}'" >> tgconfig.py + echo "TG_POST_ID = '${{ secrets.TG_POST_ID }}'" >> tgconfig.py + echo "TG_API_HASH = '${{ secrets.TG_API_HASH }}'" >> tgconfig.py + python -m pip install --upgrade pip + pip install python-telegram-bot + mv ../.github/tg.py . + mv ../.github/commit.json . + python tg.py + - name: Upload APK uses: actions/upload-artifact@v3 with: name: app - path: app/build/outputs/apk/debug/*.apk + path: archive/*.apk diff --git a/.github/workflows/tg-bot.yml b/.github/workflows/tg-bot.yml deleted file mode 100644 index 9f142fec7..000000000 --- a/.github/workflows/tg-bot.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: Telegram Bot - -on: - workflow_dispatch: - push: - paths-ignore: - - "README*.md" - - "fastlane/**" - - "assets/**" - - ".github/**/*.md" - -jobs: - debug-builds: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: gradle/wrapper-validation-action@v1 - - uses: actions/setup-python@v3 - with: - python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax - architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified - - - name: Check for Execution Orders - run: | - cd .github - curl https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }} > commit.json - python checkrun.py - cd .. - - - name: set up JDK 11 - uses: actions/setup-java@v3 - with: - java-version: 11 - distribution: "temurin" - cache: "gradle" - - - name: Patch and Compile - run: | - cd .github - python patch.py - cd .. - ./gradlew assembleDebug - - - name: Telegram Bot - continue-on-error: true - run: | - mv ./app/build/outputs/apk/debug/*.apk .github/ - cd .github - curl https://libre-tube.github.io/images/LibreAlpha.png --output alpha.png - curl https://raw.githubusercontent.com/LibreTubeAlpha/Telegram-BotAPI/main/exec --output ~/bot-api - chmod 755 ~/bot-api - echo "TG_TOKEN = '${{ secrets.TG_TOKEN }}'" > tgconfig.py - echo "TG_API_ID = '${{ secrets.TG_API_ID }}'" >> tgconfig.py - echo "TG_POST_ID = '${{ secrets.TG_POST_ID }}'" >> tgconfig.py - echo "TG_API_HASH = '${{ secrets.TG_API_HASH }}'" >> tgconfig.py - python -m pip install --upgrade pip - pip install python-telegram-bot - python tg.py