diff --git a/.github/workflows/build-qv2ray-cmake.yml b/.github/workflows/build-qv2ray-cmake.yml new file mode 100644 index 000000000..8f87c4a26 --- /dev/null +++ b/.github/workflows/build-qv2ray-cmake.yml @@ -0,0 +1,250 @@ +name: Qv2ray build matrix - cmake + +on: + push: + branches-ignore: + - l10n_dev + release: + types: [prereleased] + +jobs: + check_commit_msg: + outputs: + commit_message: ${{ steps.get_message.outputs.message }} + name: Check if the workflow has been disabled. + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Get commit message + id: get_message + run: | + echo "::set-output name=message::$(git log --format=%B -n 1 ${{ github.event.after }} | tr '\n' ' ')" + echo "message=\"$(git log --format=%B -n 1 ${{ github.event.after }} | tr '\n' ' ')\"" >> $GITHUB_ENV + build: + needs: check_commit_msg + if: ${{ !contains( needs.check_commit_msg.outputs.commit_message, '!QT5') }} + strategy: + matrix: +# platform: [ubuntu-16.04, macos-latest, windows-latest] + platform: [macos-latest] + arch: [x64] + build_type: [Release] + qt_version: [5.15.0] +# include: +# - platform: windows-latest +# arch: x64 +# qtarch: win64_msvc2019_64 + fail-fast: false + + runs-on: ${{ matrix.platform }} + env: + _QV2RAY_BUILD_INFO_: "Qv2ray built from Github Action" + _QV2RAY_BUILD_EXTRA_INFO_: "qt${{ matrix.qt_version }}-${{ github.sha }}-ci.${{ matrix.platform }}" + ACTIONS_ALLOW_UNSECURE_COMMANDS: true + + steps: + - name: Get the version + id: get_version + shell: bash + run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3) + - name: Checking out sources + uses: actions/checkout@v2 + with: + submodules: "recursive" + - name: Install Python 3.7 version + uses: actions/setup-python@v1 + with: + python-version: "3.7" + architecture: ${{ matrix.arch }} + # ========================================================================================================= + - name: Install MSVC compiler + if: matrix.platform == 'windows-latest' + uses: ilammy/msvc-dev-cmd@v1 + with: + # 14.1 is for vs2017, 14.2 is vs2019, following the upstream vcpkg build from Qv2ray-deps repo + toolset: 14.2 + arch: ${{ matrix.arch }} + - name: Cache Qt + id: cache-qt + uses: actions/cache@v1 + with: + path: ../Qt + key: QtCache-${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.qt_version }} + - name: Installing Qt - ${{ matrix.arch }} + uses: jurplel/install-qt-action@v2 + with: + version: ${{ matrix.qt_version }} + arch: ${{ matrix.qtarch }} + cached: ${{ steps.cache-qt.outputs.cache-hit }} + # ========================================================================================================= + - name: Linux - ${{ matrix.qt_version }} - Build preparation - Install Packages + if: matrix.platform == 'ubuntu-16.04' + run: | + sudo add-apt-repository ppa:webispy/grpc + sudo add-apt-repository ppa:ondrej/nginx + sudo apt update + sudo apt install -y libgl-dev libx11-dev libxkbcommon-x11-dev libxcb-image0-dev libxcb-icccm4-dev libxcb-keysyms1 libxcb-render-util0 libxcb-xinerama0 \ + libprotobuf-dev protobuf-compiler protobuf-c-compiler libgrpc++-dev protobuf-compiler-grpc \ + ninja-build \ + fcitx-frontend-qt5 \ + libcurl4-openssl-dev libssl-dev + # -------------------------------------------------------- + - name: macOS - ${{ matrix.qt_version }} - Build preparation - Install Packages + if: matrix.platform == 'macos-latest' + run: | + brew install protobuf grpc ninja pkg-config openssl + git clone https://github.com/Qv2ray/macdeployqt-patched + cd macdeployqt-patched + mkdir build; cd build; + cmake .. -DCMAKE_BUILD_TYPE=Release; cmake --build . + cp -v ./macdeployqt ${Qt5_DIR}/bin/macdeployqt + # -------------------------------------------------------- + - name: Win-${{ matrix.arch }} - ${{ matrix.qt_version }} - Setup Ninja + if: matrix.platform == 'windows-latest' + uses: ashutoshvarma/setup-ninja@master + with: + # ninja version to download. Default: 1.10.0 + version: 1.10.0 + - name: Win-${{ matrix.arch }} - ${{ matrix.qt_version }} - Build preparation - Download Dependencies + shell: bash + if: matrix.platform == 'windows-latest' + run: | + cd ./libs + ./setup-libs.sh windows ${{ matrix.arch }} + # ========================================================================================================= Generate MakeFile and Build + - uses: actions/setup-node@v1 + if: matrix.platform == 'macos-latest' + with: + node-version: "12.x" + - run: npm install -g appdmg + if: matrix.platform == 'macos-latest' + - name: macOS - ${{ matrix.qt_version }} - Generate Dependencies and Build + shell: bash + if: matrix.platform == 'macos-latest' + env: + PKG_CONFIG_PATH: /usr/local/opt/openssl@1.1/lib/pkgconfig + run: | + mkdir build + cd build + cmake .. -GNinja \ + -DCMAKE_INSTALL_PREFIX=installed \ + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ + -DCMAKE_OSX_DEPLOYMENT_TARGET=10.13 \ + -DDS_STORE_SCRIPT=ON \ + -DQV2RAY_DEFAULT_VASSETS_PATH=/usr/local/opt/v2ray/share/v2ray \ + -DQV2RAY_DEFAULT_VCORE_PATH=/usr/local/opt/v2ray/bin/v2ray + cmake --build . --parallel $(sysctl -n hw.logicalcpu) + sudo cmake --install . + appdmg ../assets/package_dmg.json ../Qv2ray.dmg + # -------------------------------------------------------- + - name: Windows - ${{ matrix.qt_version }} - Generate Dependencies and Build + shell: bash + if: matrix.platform == 'windows-latest' + env: + CC: cl.exe + CXX: cl.exe + run: | + mkdir build + cd build + cmake .. -GNinja \ + -DCMAKE_INSTALL_PREFIX=./deployment \ + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + cmake --build . --parallel $(nproc) + cmake --install . + cp -v ./*.pdb ./deployment || true + # -------------------------------------------------------- + - name: Linux - ${{ matrix.qt_version }} - Generate Dependencies and Build + if: matrix.platform == 'ubuntu-16.04' + shell: bash + env: + CC: /usr/bin/gcc-9 + CXX: /usr/bin/g++-9 + run: | + mkdir build + cd build + cmake .. -GNinja \ + -DCMAKE_INSTALL_PREFIX=./AppDir/usr \ + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ + -DQV2RAY_TRANSLATION_PATH=QApplication::applicationDirPath\(\)+"/../share/qv2ray/lang" + cmake --build . --parallel $(nproc) + cmake --install . + # ========================================================================================================= Deployments + - name: Linux - ${{ matrix.qt_version }} - Generating AppImage + if: matrix.platform == 'ubuntu-16.04' + run: | + cd build + cd AppDir + mkdir -p ./usr/{lib,optional}/ + mkdir -p ./usr/optional/libstdc++/ + mkdir -p ./usr/optional/libgcc_s/ + mkdir -p ./usr/plugins/platforminputcontexts/ + wget -c https://github.com/darealshinji/AppImageKit-checkrt/releases/download/continuous/AppRun-patched-x86_64 -O AppRun + wget -c https://github.com/darealshinji/AppImageKit-checkrt/releases/download/continuous/exec-x86_64.so -O ./usr/optional/exec.so + wget https://github.com/Qv2ray/qt-pkg/releases/download/bruh/libfcitx5platforminputcontextplugin.so -O ./usr/plugins/platforminputcontexts/libfcitx5platforminputcontextplugin.so + cp -fv /usr/lib/x86_64-linux-gnu/libstdc++.so.6 ./usr/optional/libstdc++/ + cp -fv /lib/x86_64-linux-gnu/libgcc_s.so.1 ./usr/optional/libgcc_s/ + cp -fv /usr/lib/x86_64-linux-gnu/{libssl.so.1.1,libcrypto.so.1.1} ./usr/lib/ + cp -fv /usr/lib/x86_64-linux-gnu/qt5/plugins/platforminputcontexts/libfcitxplatforminputcontextplugin.so ./usr/plugins/platforminputcontexts/ + chmod a+x AppRun + cd .. + wget https://github.com/probonopd/linuxdeployqt/releases/download/6/linuxdeployqt-6-x86_64.AppImage + chmod +x ./linuxdeployqt-6-x86_64.AppImage + ./linuxdeployqt-6-x86_64.AppImage AppDir/usr/share/applications/qv2ray.desktop \ + -appimage \ + -no-strip \ + -always-overwrite \ + -extra-plugins=iconengines,imageformats,platforminputcontexts + mv ./Qv2ray*.AppImage ./Qv2ray.AppImage + - name: Linux - ${{ matrix.qt_version }} - Uploading Artifact + if: matrix.platform == 'ubuntu-16.04' + uses: actions/upload-artifact@master + with: + name: Qv2ray-${{ github.sha }}.linux-${{ matrix.arch }}.qt${{ matrix.qt_version }}-${{ matrix.build_type }}.AppImage + path: build/Qv2ray.AppImage + - name: Linux - ${{ matrix.qt_version }} - Upload binaries to release + uses: svenstaro/upload-release-action@v1-release + if: github.event_name == 'release' && matrix.platform == 'ubuntu-16.04' && matrix.qt_version == '5.15.0' && matrix.build_type == 'Release' + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: build/Qv2ray.AppImage + asset_name: Qv2ray.${{ steps.get_version.outputs.VERSION }}.linux-${{ matrix.arch }}.AppImage + tag: ${{ github.ref }} + overwrite: true + # -------------------------------------------------------- + - name: macOS - ${{ matrix.qt_version }} - Uploading Artifact + if: matrix.platform == 'macos-latest' + uses: actions/upload-artifact@master + with: + name: Qv2ray-${{ github.sha }}.macOS-${{ matrix.arch }}.qt${{ matrix.qt_version }}-${{ matrix.build_type }}.dmg + path: Qv2ray.dmg + - name: macOS - ${{ matrix.qt_version }} - Upload binaries to release + uses: svenstaro/upload-release-action@v1-release + if: github.event_name == 'release' && matrix.platform == 'macos-latest' && matrix.qt_version == '5.15.0' && matrix.build_type == 'Release' + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: Qv2ray.dmg + asset_name: Qv2ray.${{ steps.get_version.outputs.VERSION }}.macOS-${{ matrix.arch }}.dmg + tag: ${{ github.ref }} + overwrite: true + # -------------------------------------------------------- + - name: Win-${{ matrix.arch }} - ${{ matrix.qt_version }} - Create 7z Release + if: matrix.platform == 'windows-latest' + uses: DuckSoft/create-7z-action@v1.0 + with: + pathSource: ./build/deployment/ + pathTarget: ./release.7z + - name: Win-${{ matrix.arch }} - ${{ matrix.qt_version }} - Uploading Artifact + if: matrix.platform == 'windows-latest' + uses: actions/upload-artifact@master + with: + name: Qv2ray-${{ github.sha }}.Windows-${{ matrix.arch }}.qt${{ matrix.qt_version }}-${{ matrix.build_type }}.7z + path: release.7z + - name: Win-${{ matrix.arch }} - ${{ matrix.qt_version }} - Upload binaries to release + uses: svenstaro/upload-release-action@v1-release + if: github.event_name == 'release' && matrix.platform == 'windows-latest' && matrix.qt_version == '5.15.0' && matrix.build_type == 'Release' + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: release.7z + asset_name: Qv2ray.${{ steps.get_version.outputs.VERSION }}.Windows-${{ matrix.arch }}.7z + tag: ${{ github.ref }} + overwrite: true