From 018cb249ab208c732ef8a0d08227498c4d018fc9 Mon Sep 17 00:00:00 2001 From: notify Date: Fri, 7 Apr 2023 16:07:52 +0800 Subject: [PATCH] Build ci (#105) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 构建安卓版的CI 构建win版的CI(未完成) 以上均需要手动触发 --- .github/workflows/build-android.yml | 150 ++++++++++++++++++++ .github/workflows/build-windows.yml | 62 ++++++++ android/src/org/notify/FreeKill/Helper.java | 8 ++ src/server/server.cpp | 2 +- 4 files changed, 221 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build-android.yml create mode 100644 .github/workflows/build-windows.yml diff --git a/.github/workflows/build-android.yml b/.github/workflows/build-android.yml new file mode 100644 index 00000000..43c64a7e --- /dev/null +++ b/.github/workflows/build-android.yml @@ -0,0 +1,150 @@ +name: Build For Android + +on: + workflow_dispatch: + +jobs: + build: + name: Build Android APK + runs-on: ubuntu-latest + + steps: + + - name: Checkout Git Repo + uses: actions/checkout@v3 + with: + submodules: true + + #- name: Setup Debug Session + # uses: csexton/debugger-action@master + + - name: Install swig, flex, bison + run: | + sudo apt-get install -y swig flex bison + + - name: Install Qt for Host + uses: jurplel/install-qt-action@v3 + with: + aqtversion: '==3.1.*' + py7zrversion: '>=0.20.2' + version: '6.4.2' + host: 'linux' + target: 'desktop' + arch: 'gcc_64' + modules: 'qtmultimedia qt5compat qtshadertools' + + - name: Install Qt for Android + uses: jurplel/install-qt-action@v3 + with: + aqtversion: '==3.1.*' + py7zrversion: '>=0.20.2' + version: '6.4.2' + host: 'linux' + target: 'android' + arch: 'android_arm64_v8a' + modules: 'qtmultimedia qt5compat qtshadertools' + + # 快点TM升级到OpenSSL 3!1.1.1今年就走到生命期末尾了! + - name: Setup OpenSSL 1.1.1 headers + run: | + cd .. + wget --quiet https://www.openssl.org/source/openssl-1.1.1t.tar.gz + tar xf ./openssl-1.1.1t.tar.gz + cd openssl-1.1.1t + ./config + make include/openssl/opensslconf.h + cd ../FreeKill + cp -r ../openssl-1.1.1t/include/openssl ./include + + - name: Setup Android for Qt 6.4.x + run: | + cd .. + mkdir android + cd android + wget --quiet https://dl.google.com/android/repository/commandlinetools-linux-9477386_latest.zip + unzip commandlinetools-linux-9477386_latest.zip + yes | ./cmdline-tools/bin/sdkmanager --sdk_root=$(pwd) \ + "platforms;android-31" \ + "platform-tools" \ + "build-tools;31.0.0" \ + "ndk;23.1.7779620" + + - name: Copy android assets + run: | + ${Qt6_DIR}/../gcc_64/bin/lrelease lang/zh_CN.ts + cp lang/zh_CN.qm . + FKVER=$(cat CMakeLists.txt | grep 'project(FreeKill' | cut -d ' ' -f 3) + cd android + sed -i 's/function //g' copy_assets.sh # FIX THIS + ./copy_assets.sh || echo "" # fail on copy cert, ubuntu is not arch + cd assets/res + cp -r /etc/ssl/certs . + cp /usr/share/ca-certificates/mozilla/* certs/ + echo ${FKVER%)} > fk_ver + + - name: Configure CMake Project + working-directory: ${{github.workspace}} + run: | + export QT_HOST_PATH=${Qt6_DIR}/../gcc_64/ + export ANDROID_SDK_ROOT=$(pwd)/../android + export ANDROID_NDK_ROOT=$ANDROID_SDK_ROOT/ndk/23.1.7779620 + sed -i "s/LinguistTools/Linguist/g" CMakeLists.txt + ${Qt6_DIR}/bin/qt-cmake -S . -B ./build -DCMAKE_BUILD_TYPE=MinSizeRel + + - name: Build project + working-directory: ${{github.workspace}}/build + run: make -j2 + + - name: Upload APK + uses: actions/upload-artifact@v3 + with: + name: apk + path: build/android-build/build/outputs/apk/debug/android-build-debug.apk + + release: + name: Release APK + needs: build + runs-on: ubuntu-latest + steps: + - name: Checkout Git Repo + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Get Previous tag + id: previoustag + uses: WyriHaximus/github-action-get-previous-tag@v1 + with: + fallback: 0.0.1 + + - name: Download APK from build + uses: actions/download-artifact@v3 + with: + name: apk + path: apk + + - uses: r0adkll/sign-android-release@v1 + name: Sign app APK + # ID used to access action output + id: sign_app + with: + releaseDirectory: apk + signingKeyBase64: ${{ secrets.KEY_STORE }} + alias: ${{ secrets.KEY_STORE_ALIAS }} + keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }} + env: + # override default build-tools version (29.0.3) -- optional + BUILD_TOOLS_VERSION: "31.0.0" + + - name: Rename APK + run: | + mv ${{ steps.sign_app.outputs.signedReleaseFile }} \ + apk/FreeKill-${{ steps.previoustag.outputs.tag }}.apk + + - name: Upload Release APK + uses: softprops/action-gh-release@v1 + with: + token: ${{ secrets.MY_TOKEN }} + tag_name: ${{ steps.previoustag.outputs.tag }} + files: apk/FreeKill-${{ steps.previoustag.outputs.tag }}.apk + diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml new file mode 100644 index 00000000..b4f661c1 --- /dev/null +++ b/.github/workflows/build-windows.yml @@ -0,0 +1,62 @@ +name: Build For Windows 10+ +# 调试不好,放弃 +# 辣鸡Windows + +on: + workflow_dispatch: + +jobs: + build: + runs-on: windows-latest + + steps: + + - name: Checkout Git Repo + uses: actions/checkout@v3 + with: + submodules: true + + - name: Install swig, winflexbison3 + uses: crazy-max/ghaction-chocolatey@v1 + with: + args: install winflexbison3 swig -y + + - name: Install Qt + uses: jurplel/install-qt-action@v3 + with: + aqtversion: '==3.1.*' + py7zrversion: '>=0.20.2' + version: '6.4.3' + host: 'windows' + target: 'desktop' + arch: 'win64_mingw' + modules: 'qtmultimedia qt5compat qtshadertools' + tools: 'tools_openssl_x64 tools_cmake' + + - name: Configure CMake Project + working-directory: ${{github.workspace}} + env: + CMAKE_PREFIX_PATH: ${{env.Qt6_Dir}} + OPENSSL_ROOT_DIR: ${{github.workspace}}/../Qt/tools/OpenSSL/bin + run: | + ls ../Qt + ls ../Qt/tools + cmake -DCMAKE_BUILD_TYPE=Release -G "MinGW Makefiles" -B ${{github.workspace}}/build + + - name: Build project + working-directory: ${{github.workspace}}/build + run: mingw32-make.exe + + - name: Compress portable program + working-directory: ${{github.workspace}} + run: | + mkdir build/all + cp build/FreeKill.exe build/all + cp build/zh_CN.qm build/all + cp build/fkparse/libfkparse.dll build/all + cp -r audio fonts image lua packages qml server build/all + cp lib/win/* build/all + cd build/all + windeployqt.exe FreeKill.exe --release + ls + Compress-Archive -Path ${{github.workspace}}\build\all\ -DestinationPath ${{github.workspace}}\build\final.zip diff --git a/android/src/org/notify/FreeKill/Helper.java b/android/src/org/notify/FreeKill/Helper.java index dd5f4ba3..da663394 100644 --- a/android/src/org/notify/FreeKill/Helper.java +++ b/android/src/org/notify/FreeKill/Helper.java @@ -2,6 +2,8 @@ package org.notify.FreeKill; import android.app.Activity; import android.view.View; +import android.view.WindowManager; +import android.view.ViewGroup.LayoutParams; import org.qtproject.qt.android.QtNative; public class Helper { @@ -18,9 +20,15 @@ public class Helper { int uiOpt = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | + View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_FULLSCREEN; decorView.setSystemUiVisibility(uiOpt); + // FullScreen + WindowManager.LayoutParams lp = activity.getWindow().getAttributes(); + lp.layoutInDisplayCutoutMode = LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; + activity.getWindow().setAttributes(lp); + decorView.setOnSystemUiVisibilityChangeListener (new View.OnSystemUiVisibilityChangeListener() { @Override diff --git a/src/server/server.cpp b/src/server/server.cpp index 4014521b..47058fd9 100644 --- a/src/server/server.cpp +++ b/src/server/server.cpp @@ -46,7 +46,7 @@ Server::Server(QObject* parent) } // wait for reply - QThread::sleep(5); + QThread::sleep(150); foreach (auto p, this->players.values()) { if (p->getState() == Player::Online && !p->alive) {