Добавление workflow для сборки apk

This commit is contained in:
2025-09-13 20:25:47 +03:00
parent cc49aad2aa
commit 5986d8b069
2 changed files with 118 additions and 28 deletions
+65
View File
@@ -0,0 +1,65 @@
name: Сборка мода
on:
workflow_dispatch:
#schedule: # раз в 36 часов
# - cron: "0 0 */3 * *" # каждые 3 дня в 00:00
# - cron: "0 12 */3 * *" # каждые 3 дня в 12:00
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Download APK
run: |
curl -L -o app.apk "https://mirror-dl.anixart-app.com/anixart-beta.apk"
- name: Ensure aapt is installed
run: |
if ! command -v aapt &> /dev/null; then
echo "aapt не найден, устанавливаем..."
sudo apt-get update && sudo apt-get install -y --no-install-recommends android-sdk-build-tools
fi
- name: Export secrets
env:
KEYSTORE: ${{ secrets.KEYSTORE }}
KEYSTORE_PASS: ${{ secrets.KEYSTORE_PASS }}
run: |
# Export so later steps can reference them
echo "$KEYSTORE" | base64 -d > keystore.jks
echo "$KEYSTORE_PASS" > keystore.pass
- name: Build APK
id: build
run: |
mkdir original
mv app.apk original/
python ./main.py -f
- name: Read title from report.log
id: get_title
run: |
TITLE=$(head -n 1 modified/report.log)
echo "title=${TITLE}" >> $GITHUB_OUTPUT
- name: Setup go
if: steps.build.outputs.BUILD_EXIT == '0'
uses: actions/setup-go@v4
with:
go-version: '>=1.20'
- name: Make release
if: steps.build.outputs.BUILD_EXIT == '0'
uses: https://gitea.com/actions/release-action@main
with:
title: ${{ steps.get_title.outputs.title }}
body_path: modified/report.log
draft: true
api_key: '${{secrets.RELEASE_TOKEN}}'
files: |-
modified/**-mod.apk
modified/report.log
+26 -1
View File
@@ -1,7 +1,9 @@
import os
import sys
import json
import yaml
import requests
import argparse
import colorama
import importlib
import traceback
@@ -141,6 +143,13 @@ def compile_apk(apk: str):
stdout=subprocess.DEVNULL,
stderr=subprocess.PIPE,
)
title = "anixart mod "
with open('./decompiled/apktool.yml') as f:
package = yaml.safe_load(f)
title += ' '.join([f'{k}: {v}' for k, v in package['versionInfo'].items()])
with open("./modified/report.log", "w") as log_file:
log_file.write(title+'\n')
log_file.write("\n".join([f"{patch.name}: {'applied' if patch.applied else 'failed'}" for patch in patches]))
except subprocess.CalledProcessError as e:
print("Ошибка при выполнении команды:")
print(e.stderr)
@@ -167,11 +176,27 @@ class Patch:
traceback.print_exc()
return False
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Автоматический патчер anixart"
)
parser.add_argument("-v", "--verbose",
action="store_true",
help="Выводить подробные сообщения")
parser.add_argument("-f", "--force",
action="store_true",
help="Принудительно собрать APK")
args = parser.parse_args()
conf = init()
apk = select_apk()
patch = decompile_apk(apk)
if args.verbose: conf["verbose"] = True
patches = []
for filename in os.listdir("patches/"):
if filename.endswith(".py") and filename != "__init__.py" and not filename.startswith("todo_"):
@@ -196,7 +221,7 @@ if all(statuses.values()):
compile_apk(apk)
elif any(statuses.values()):
print(f"{colorama.Fore.YELLOW}{colorama.Style.RESET_ALL} Некоторые патчи не были успешно применены")
if input("Продолжить? (y/n): ").lower() == "y":
if args.force or input("Продолжить? (y/n): ").lower() == "y":
compile_apk(apk)
else:
print(colorama.Fore.RED + "Операция отменена" + colorama.Style.RESET_ALL)