fix: API 兼容性问题 #22
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Release | |
on: | |
push: | |
tags: | |
- "v*" | |
workflow_dispatch: | |
# 添加权限配置 | |
permissions: | |
contents: write | |
jobs: | |
build: | |
runs-on: windows-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# 获取版本号和提交信息 | |
- name: Get Version Info | |
id: version | |
run: | | |
VERSION=${GITHUB_REF#refs/tags/} | |
echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
if git rev-list --tags --max-count=1 > /dev/null 2>&1; then | |
LAST_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || git rev-list --max-parents=0 HEAD) | |
# 获取所有提交并过滤掉CI相关提交和文档提交 | |
ALL_COMMITS=$(git log --pretty=format:"%h %s (%an)" $LAST_TAG..HEAD | grep -v -E "ci:|docs:" || true) | |
# 分别获取不同类型的提交 | |
FEAT_COMMITS=$(echo "$ALL_COMMITS" | grep "^[a-f0-9]\+ feat:" || true) | |
FIX_COMMITS=$(echo "$ALL_COMMITS" | grep "^[a-f0-9]\+ fix:" || true) | |
OTHER_COMMITS=$(echo "$ALL_COMMITS" | grep -v "^[a-f0-9]\+ \(feat:\|fix:\)" || true) | |
# 组装changelog | |
CHANGELOG="" | |
if [ ! -z "$FEAT_COMMITS" ]; then | |
CHANGELOG+="### 功能改进\n$FEAT_COMMITS\n" | |
fi | |
if [ ! -z "$FIX_COMMITS" ]; then | |
CHANGELOG+="### 问题修复\n$FIX_COMMITS\n" | |
fi | |
if [ ! -z "$OTHER_COMMITS" ]; then | |
CHANGELOG+="### 其他更新\n$OTHER_COMMITS" | |
fi | |
else | |
CHANGELOG="### 首次发布\n$(git log --pretty=format:"- %h %s (%an)" | grep -v "ci:" || true)" | |
fi | |
# 如果changelog为空,添加默认信息 | |
if [ -z "$CHANGELOG" ]; then | |
CHANGELOG="### 无更新内容" | |
fi | |
# 输出 | |
echo -e "$CHANGELOG" | |
# 将 changelog 写入文件 | |
echo -e "$CHANGELOG" > CHANGELOG.md | |
shell: bash | |
# 设置 Java 环境 | |
- name: Set up JDK | |
uses: actions/setup-java@v4 | |
with: | |
distribution: "temurin" | |
java-version: "21" | |
# 设置 Android SDK | |
- name: Set up Android SDK | |
uses: android-actions/setup-android@v3 | |
# 下载替换 android.jar | |
- name: Download android.jar | |
run: | | |
mkdir -p $ANDROID_HOME/platforms/android-34 | |
curl -L https://raw.githubusercontent.com/Reginer/aosp-android-jar/refs/heads/main/android-34/android.jar -o $ANDROID_HOME/platforms/android-34/android.jar | |
shell: bash | |
# 构建 Android APK | |
- name: Build Android APK | |
run: | | |
gradle wrapper | |
chmod +x ./gradlew | |
./gradlew assembleDebug | |
shell: bash | |
# 设置 Go 环境 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: "1.23" | |
# 设置 Node.js 环境 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "21" | |
# 安装 Wails | |
- name: Install Wails | |
run: go install github.com/wailsapp/wails/v2/cmd/wails@latest | |
# 构建 Wails 应用 | |
- name: Build Wails App | |
run: | | |
cd nrfr-client/frontend | |
npm install | |
cd .. | |
wails build | |
shell: bash | |
# 下载最新的 Shizuku APK | |
- name: Download Shizuku APK | |
run: | | |
mkdir -p nrfr-client/build/bin/resources | |
curl -L $(curl -s https://api.github.com/repos/RikkaApps/Shizuku/releases/latest | grep "browser_download_url.*apk" | cut -d '"' -f 4) -o nrfr-client/build/bin/resources/shizuku.apk | |
shell: bash | |
# 复制 Android APK | |
- name: Copy Android APK | |
run: | | |
cp app/build/outputs/apk/debug/app-debug.apk nrfr-client/build/bin/resources/nrfr.apk | |
cp app/build/outputs/apk/debug/app-debug.apk nrfr-${{ steps.version.outputs.version }}.apk | |
shell: bash | |
# 下载 platform-tools | |
- name: Download platform-tools | |
run: | | |
mkdir -p nrfr-client/build/bin/platform-tools | |
if [ "$RUNNER_OS" == "Windows" ]; then | |
curl -L https://dl.google.com/android/repository/platform-tools-latest-windows.zip -o platform-tools.zip | |
elif [ "$RUNNER_OS" == "Linux" ]; then | |
curl -L https://dl.google.com/android/repository/platform-tools-latest-linux.zip -o platform-tools.zip | |
else | |
curl -L https://dl.google.com/android/repository/platform-tools-latest-darwin.zip -o platform-tools.zip | |
fi | |
unzip platform-tools.zip | |
cp -r platform-tools/* nrfr-client/build/bin/platform-tools/ | |
rm -rf platform-tools platform-tools.zip | |
shell: bash | |
# 打包发布文件 | |
- name: Create Release Archive | |
run: | | |
cd nrfr-client/build/bin | |
7z a "../../nrfr-${{ steps.version.outputs.version }}-release.zip" ./* | |
shell: bash | |
# 创建 Release | |
- name: Create Release | |
uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
files: | | |
nrfr-client/nrfr-${{ steps.version.outputs.version }}-release.zip | |
nrfr-${{ steps.version.outputs.version }}.apk | |
body_path: CHANGELOG.md | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |