ClashRoot #94
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: ClashRoot | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: 下载代码 | |
| uses: actions/checkout@v6 | |
| - name: 设置Flutter环境 | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| flutter-version: '3.44.4' | |
| - name: 安装依赖 | |
| run: flutter pub get | |
| - name: 获取 commit hash | |
| run: | | |
| echo "SHORT_HASH=$(git rev-parse --short=6 HEAD)" >> $GITHUB_ENV | |
| - name: 注入 pubspec.yaml 版本 hash | |
| run: | | |
| VERSION=$(grep '^version:' pubspec.yaml | awk '{print $2}') | |
| BASE=${VERSION%%+*} | |
| CODE=${VERSION##*+} | |
| sed -i "s/^version:.*/version: ${BASE}-${SHORT_HASH}+${CODE}/" pubspec.yaml | |
| - name: 注入 module.prop 版本 hash | |
| run: | | |
| HASH=$SHORT_HASH | |
| sed -i "s/^version=.*/version=2.2.2-${HASH}/" ClashRoot/module.prop | |
| - name: Build APK (按 ABI 分割) | |
| run: | | |
| flutter build apk --release --target-platform android-arm64 --split-per-abi | |
| - name: 重命名 APK(加入 hash) | |
| run: | | |
| HASH=$SHORT_HASH | |
| mkdir -p output_apk | |
| cp build/app/outputs/flutter-apk/app-arm64-v8a-release.apk \ | |
| output_apk/ClashRoot-${HASH}.apk | |
| - name: 上传 APK | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| path: output_apk/*.apk | |
| archive: false | |
| - name: 下载 GeoIP 和 Geosite | |
| run: | | |
| mkdir -p ClashRoot | |
| curl -L -o ClashRoot/geoip.dat https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat | |
| curl -L -o ClashRoot/geosite.dat https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat | |
| - name: 下载最新版本Clash | |
| run: | | |
| RELEASE_JSON=$(curl -s https://api.github.com/repos/MetaCubeX/mihomo/releases/latest) | |
| CLASH_URL=$(echo "$RELEASE_JSON" | grep -oP '"browser_download_url": "\K.*?mihomo-android-arm64-v8-v[0-9]+\.[0-9]+\.[0-9]+\.gz(?=")' | head -n 1) | |
| echo "Downloading Clash: $CLASH_URL" | |
| curl -L -o ClashRoot/clash.gz "$CLASH_URL" | |
| gunzip -f ClashRoot/clash.gz | |
| chmod +x ClashRoot/clash | |
| - name: 下载最新版本MetaCubeXD | |
| run: | | |
| RELEASE_JSON=$(curl -s https://api.github.com/repos/MetaCubeX/metacubexd/releases/latest) | |
| METACUBEXD_URL=$(echo "$RELEASE_JSON" | grep -oP '"browser_download_url": "\K.*?compressed-dist.tgz(?=")' | head -n 1) | |
| echo "Downloading MetaCubeXD: $METACUBEXD_URL" | |
| mkdir -p ClashRoot/metacubexd | |
| curl -L -o metacubexd.tgz "$METACUBEXD_URL" | |
| tar -xzf metacubexd.tgz -C ClashRoot/metacubexd | |
| rm metacubexd.tgz | |
| - name: 打包 ClashRoot.zip | |
| run: | | |
| HASH=$SHORT_HASH | |
| (cd ClashRoot && zip -r ../ClashRoot-${HASH}.zip .) | |
| - name: 上传 ZIP | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| path: ClashRoot-*.zip | |
| archive: false |