Skip to content

Patch QQ #59

Patch QQ #59 #59

Workflow file for this run

name: Release
run-name: "Patch QQ #${{ github.run_number }}"
# 控制工作流何时运行
on:
schedule:
- cron: "30 1 * * 4"
# Runs at 01:30 (UTC time), only on Thursday
# “肯德基疯狂星期四”仅限9:30-23:00供应,具体以餐厅实际营业时间为准。
# https://docs.github.com/zh/actions/using-workflows/events-that-trigger-workflows#repository_dispatch
repository_dispatch:
types: [release]
# 每次提交时运行工作流
push:
branches: ["main"]
# 允许手动运行工作流
workflow_dispatch:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
check-updates:
name: Check for Updates | 检查更新
runs-on: ubuntu-latest
outputs:
patch_needed: ${{ steps.version_check.outputs.patch_needed }}
QQ_version: ${{ steps.get_qq_version.outputs.QQ_version }}
QAuxiliary_version: ${{ steps.QAuxiliary.outputs.release }}
XAutoDaily_version: ${{ steps.XAutoDaily.outputs.release }}
TSBattery_version: ${{ steps.TSBattery.outputs.release }}
QQCleaner_version: ${{ steps.QQCleaner.outputs.release }}
LSPatch_version: ${{ steps.LSPatch.outputs.release }}
QAuxiliary_description: ${{ steps.QAuxiliary.outputs.description }}
XAutoDaily_description: ${{ steps.XAutoDaily.outputs.description }}
TSBattery_description: ${{ steps.TSBattery.outputs.description }}
QQCleaner_description: ${{ steps.QQCleaner.outputs.description }}
steps:
- name: Checkout | 检出代码
uses: actions/checkout@v4
- name: Set ENV values from config.yml | 从配置文件设置环境变量
uses: dcarbone/yaml-to-env-action@v3
with:
yaml-file: config.yml
# 模块版本检测
- name: Get QAuxiliary version | 获取 QAuxiliary 版本
id: QAuxiliary
uses: pozetroninc/github-action-get-latest-release@v0.8.0
with:
repository: cinit/QAuxiliary
excludes: prerelease, draft
token: ${{ secrets.GITHUB_TOKEN }}
- name: Get XAutoDaily version | 获取 XAutoDaily 版本
id: XAutoDaily
uses: pozetroninc/github-action-get-latest-release@v0.8.0
with:
repository: LuckyPray/XAutoDaily
excludes: prerelease, draft
token: ${{ secrets.GITHUB_TOKEN }}
- name: Get TSBattery version | 获取 TSBattery 版本
id: TSBattery
uses: pozetroninc/github-action-get-latest-release@v0.8.0
with:
repository: fankes/TSBattery
excludes: prerelease, draft
token: ${{ secrets.GITHUB_TOKEN }}
- name: Get QQCleaner version | 获取 QQCleaner 版本
id: QQCleaner
uses: pozetroninc/github-action-get-latest-release@v0.8.0
with:
repository: KitsunePie/QQCleaner
excludes: prerelease, draft
token: ${{ secrets.GITHUB_TOKEN }}
- name: Get LSPatch version | 获取LSPatch版本
id: LSPatch
uses: pozetroninc/github-action-get-latest-release@v0.8.0
with:
repository: ${{ ENV.LSPATCH_REPO }}
excludes: prerelease, draft
token: ${{ secrets.GITHUB_TOKEN }}
- name: Get QQ Version | 获取 QQ 版本
id: get_qq_version
run: |
response=$(curl -s -X POST -H "Content-Type: application/json" -d '{"packagename":"com.tencent.mobileqq"}' https://upage.html5.qq.com/wechat-apkinfo)
clean_response=$(echo "$response" | tr -cd '[:print:]')
version_name=$(echo "$clean_response" | jq -r '.app_detail_records."com.tencent.mobileqq".apk_all_data.version_name')
# 设置输出变量
echo "QQ_version=$version_name" >> $GITHUB_OUTPUT
# 版本比对逻辑
- name: Version Comparison | 版本比对
id: version_check
run: |
# 获取历史版本号记录
gh release download -O versions.json --pattern 'versions.json' || echo "{}" > versions.json
# 生成当前版本号数据
current_versions=$(jq -n \
--arg QQ_version "${{ steps.get_qq_version.outputs.QQ_version }}" \
--arg QAuxiliary_version "${{ steps.QAuxiliary.outputs.release }}" \
--arg XAutoDaily_version "${{ steps.XAutoDaily.outputs.release }}" \
--arg TSBattery_version "${{ steps.TSBattery.outputs.release }}" \
--arg QQCleaner_version "${{ steps.QQCleaner.outputs.release }}" \
--arg LSPatch_version "${{ steps.LSPatch.outputs.release }}" \
'{
QQ: $QQ_version,
QAuxiliary: $QAuxiliary_version,
XAutoDaily: $XAutoDaily_version,
TSBattery: $TSBattery_version,
QQCleaner: $QQCleaner_version,
LSPatch: $LSPatch_version
}')
# 版本比对
if [[ "$(cat versions.json)" == "$current_versions" ]]; then
echo "::notice::All versions are up-to-date | 所有版本均为最新版"
# 强制模式检查
if [[ "${{ env.FORCE_ENABLE }}" == "true" ]]; then
echo "::notice::Force mode enabled, patching anyway | 强制模式已启用,仍执行修补"
echo "$current_versions" > versions.json
echo "patch_needed=true" >> $GITHUB_OUTPUT
else
echo "patch_needed=false" >> $GITHUB_OUTPUT
fi
else
echo "::notice::New version detected | 检测到新版本"
echo "$current_versions" > versions.json
echo "patch_needed=true" >> $GITHUB_OUTPUT
fi
# 上传版本信息记录文件
- name: Upload version info | 上传版本信息
uses: actions/upload-artifact@v4
if: steps.version_check.outputs.patch_needed == 'true'
with:
name: version-info
path: versions.json
patch:
name: Patch QQ | 修补 QQ
needs: check-updates
if: needs.check-updates.outputs.patch_needed == 'true'
runs-on: ubuntu-latest
outputs:
module_list: ${{ steps.patch_qq.outputs.module_list }}
steps:
- name: Checkout | 检出代码
uses: actions/checkout@v4
- name: Setup Java JDK | 设置 Java JDK
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "21"
- name: Set ENV values from config.yml | 从配置文件设置环境变量
uses: dcarbone/yaml-to-env-action@v3
with:
yaml-file: config.yml
# 下载版本记录资源
- name: Download version info | 下载版本信息
uses: actions/download-artifact@v4
with:
name: version-info
path: .
- name: Download Custom QQ | 下载自定义 QQ 版本
if: ENV.QQ_CUSTOM_ENABLE == 'true'
run: |
wget -q -U "Mozilla/5.0" -O QQ-${{ env.QQ_CUSTOM_VERSION }}.apk "${{ ENV.QQ_CUSTOM_URL }}"
- name: Download Latest QQ | 下载最新版 QQ
if: ENV.QQ_LATEST_ENABLE == 'true'
run: |
wget -q -U "Mozilla/5.0" -O "QQ-${{ needs.check-updates.outputs.QQ_version }}-latest.apk" \
$(curl -s -X POST -H "Content-Type: application/json" -d '{"packagename":"com.tencent.mobileqq"}' \
https://upage.html5.qq.com/wechat-apkinfo | tr -cd '[:print:]' | jq -r '.app_detail_records."com.tencent.mobileqq".apk_all_data.url')
# 下载 LSPatch
- name: Download LSPatch | 下载 LSPatch
run: |
if [ "${{ env.LSPATCH_REPO }}" = "JingMatrix/LSPatch" ]; then
gh release download -O LSPatch.jar --repo "JingMatrix/LSPatch" --pattern 'lspatch.jar'
else
gh release download -O LSPatch.jar --repo "${{ env.LSPATCH_REPO }}" --pattern '*.jar'
fi
- name: Download Preset Modules | 下载预设模块
run: |
# 动态下载启用的预设模块
if [ "${{ env.MODULES_QAUXILIARY }}" = "true" ]; then
gh release download -O QAuxiliary.apk --repo cinit/QAuxiliary --pattern '*arm64.apk'
fi
if [ "${{ env.MODULES_XAUTODAILY }}" = "true" ]; then
gh release download -O XAutoDaily.apk --repo LuckyPray/XAutoDaily --pattern '*.apk'
fi
if [ "${{ env.MODULES_TSBATTERY }}" = "true" ]; then
gh release download -O TSBattery.apk --repo fankes/TSBattery --pattern '*.apk'
fi
if [ "${{ env.MODULES_QQCLEANER }}" = "true" ]; then
gh release download -O QQCleaner.apk --repo KitsunePie/QQCleaner --pattern '*.apk'
fi
- name: Download Custom Modules | 下载自定义模块
if: env.MODULES_CUSTOM_ENABLE == 'true'
run: |
# 获取模块数量
count=$(yq eval '.modules.custom.list | length' config.yml)
echo "Found $count custom modules | 找到 $count 个自定义模块"
# 遍历下载所有自定义模块
for ((i=0; i<count; i++)); do
name=$(yq eval ".modules.custom.list[$i].name" config.yml)
url=$(yq eval ".modules.custom.list[$i].url" config.yml)
# 替换文件名中的非法字符
safe_name=$(echo "$name" | tr ' ' '_' | tr -cd '[:alnum:]-_')
echo "Downloading $name from $link | 从 $url 下载 $name"
wget -q -U "Mozilla/5.0" -O "custom-module-${safe_name}.apk" "$url" || echo "::warning::Failed to download $name | 下载 $name 失败"
# 检查文件是否下载成功
if [ ! -f "custom-module-${safe_name}.apk" ]; then
echo "::error::Custom module $name failed to download | 自定义模块 $name 下载失败"
fi
done
- name: Patch QQ | 修补 QQ
id: patch_qq
run: |
# 动态生成模块列表
module_list=""
# 添加预设模块
if [ "${{ env.MODULES_QAUXILIARY }}" = "true" ]; then module_list="${module_list},QAuxiliary.apk"; fi
if [ "${{ env.MODULES_XAUTODAILY }}" = "true" ]; then module_list="${module_list},XAutoDaily.apk"; fi
if [ "${{ env.MODULES_TSBATTERY }}" = "true" ]; then module_list="${module_list},TSBattery.apk"; fi
if [ "${{ env.MODULES_QQCLEANER }}" = "true" ]; then module_list="${module_list},QQCleaner.apk"; fi
# 添加自定义模块
if [ "${{ env.MODULES_CUSTOM_ENABLE }}" = "true" ]; then
for file in custom-module-*.apk; do
if [ -f "$file" ]; then
module_list="${module_list},$file"
fi
done
fi
# 移除 module_list 开头的逗号
module_list="${module_list#","}"
# 若 module_list 为空,输出提示
if [ -z "$module_list" ]; then
echo "::warning::No modules selected for patching | 未选择任何模块进行修补"
fi
echo "模块列表: $module_list"
# 输出到 GITHUB_OUTPUT
echo "module_list=$module_list" >> $GITHUB_OUTPUT
# 执行修补
java -jar LSPatch.jar QQ-*.apk -m "$module_list" -l 2
- name: Create Release | 创建 Release
uses: softprops/action-gh-release@v2
with:
files: |
*-lspatched.apk
versions.json
tag_name: Build#${{ github.run_number }} # 仓库中特定工作流程每个运行的唯一编号(从 1 开始递增)
name: "QQ Build #${{ github.run_number }} (with ${{ needs.check-updates.outputs.QQ_version }})" # 使用 QQ 版本号和构建编号作为标题
body: |
### 本次修补使用的模块列表
**${{ steps.patch_qq.outputs.module_list }}**
### 所有默认配置项目的最新版本
| 项目名称 | 对应版本 | 查看项目 |
| ------- | -------- | ------- |
| QQ 最新版本 | ${{ needs.check-updates.outputs.QQ_version }} | [QQ 官网](https://im.qq.com/index) |
| QAuxiliary | ${{ needs.check-updates.outputs.QAuxiliary_version }} | [GitHub](https://github.com/cinit/QAuxiliary) |
| XAutoDaily | ${{ needs.check-updates.outputs.XAutoDaily_version }} | [GitHub](https://github.com/LuckyPray/XAutoDaily) |
| TSBattery | ${{ needs.check-updates.outputs.TSBattery_version }} | [GitHub](https://github.com/fankes/TSBattery) |
| QQCleaner | ${{ needs.check-updates.outputs.QQCleaner_version }} | [GitHub](https://github.com/KitsunePie/QQCleaner) |
| LSPatch | ${{ needs.check-updates.outputs.LSPatch_version }} | [GitHub](https://github.com/${{ ENV.LSPATCH_REPO }}) |
<details><summary>点击展开模块更新日志</summary>
#### QAuxiliary<br>
${{ needs.check-updates.outputs.QAuxiliary_description }}
#### XAutoDaily<br>
${{ needs.check-updates.outputs.XAutoDaily_description }}
#### TSBattery<br>
${{ needs.check-updates.outputs.TSBattery_description }}
#### QQCleaner<br>
${{ needs.check-updates.outputs.QQCleaner_description }}
</details>
### 发行说明
您应该会在页面下方的 Assets 看到如下文件(若启用对应配置项):
- QQ-${{ env.QQ_CUSTOM_VERSION }}-`LSPatch 内部版本号`-lspatched.apk
此为自定义版本(${{ env.QQ_CUSTOM_VERSION }})修补的 QQ APK
- QQ-${{ needs.check-updates.outputs.QQ_version }}-latest-`LSPatch 内部版本号`-lspatched.apk
此为基于 QQ Android 当前最新版本修补的 QQ APK
> 基于最新版 QQ 修补的版本,部分模块功能可能因为未适配而失效,请酌情使用
- versions.json
此为本次修补使用的版本信息
**Have fun!**