Skip to content

优化

优化 #809

Workflow file for this run

# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml
name: CMake on Windows platforms
permissions:
contents: write
discussions: write
on:
push:
branches: [ main, develop, develop-windows ]
tags:
- "v*.*.*"
paths-ignore:
- '**.md'
- 'changelog.txt'
- 'LEGAL'
- 'LICENSE'
- '.clang-*'
- '.gitignore'
- 'lib/xdg/**'
- 'snap/**'
- 'docs/**'
- 'flatpak/**'
- '.github/**'
- 'src/base/platform/linux/**'
- 'src/base/platform/macos/**'
- '!.github/workflows/win.yml'
pull_request:
branches: [ main, develop, develop-windows ]
jobs:
build:
env:
UPLOAD_ARTIFACT: "true"
ARTIFACT_PATH: "ok-msg-desktop"
ARTIFACT_Setup_Path: "${{ github.workspace }}/deploy-setup"
ARTIFACT_Setup_FileName: "ok-msg-desktop_${{ matrix.os }}_${{ matrix.arch }}_setup"
VCPKG_DEFAULT_TRIPLET: ${{ matrix.arch }}-windows
VCPKG_INSTALLED_DIR: /vcpkg_installed
VCPKG_BUILD_TYPE: ${{ matrix.build_type }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
arch: [x64]
os: [windows-latest]
build_type: [ Release ]
c_compiler: [cl]
cpp_compiler: [cl]
steps:
- name: Checkout repository and submodules
uses: actions/checkout@v4
with:
submodules: 'true'
- name: Set up windows 10 SDK
uses: GuillaumeFalourd/setup-windows10-sdk-action@v2
with:
sdk-version: 20348
- name: Native Tools Command Prompt.
uses: ilammy/[email protected]
with:
arch: ${{ matrix.arch }}
- name: vcpkg build
uses: lukka/run-vcpkg@v11
with:
runVcpkgInstall: true
- name: Install Yasm
run: choco install yasm
- name: Install pkg-conf
run: |
choco install strawberryperl --pre
- name: Install ok-rtc
shell: powershell
run: |
git clone -b master https://github.com/okstar-org/ok-rtc.git
cd ok-rtc
git submodule update --init
cmake -B out -DPKG_CONFIG_EXECUTABLE=C:\Strawberry\perl\bin\pkg-config.bat -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT"/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=${{ env.VCPKG_DEFAULT_TRIPLET }} -DCMAKE_PREFIX_PATH=${{ env.VCPKG_INSTALLED_DIR }}\${{ env.VCPKG_DEFAULT_TRIPLET }}
cmake --build out --config=${{ matrix.build_type }}
cmake --install out --config=${{ matrix.build_type }} --prefix=${{ github.workspace }}/
- name: Install ok-gloox
shell: powershell
run: |
git clone -b main https://github.com/okstar-org/ok-gloox.git
cd ok-gloox
cmake -B out -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
cmake --build out --config=${{ matrix.build_type }}
cmake --install out --config=${{ matrix.build_type }} --prefix=${{ github.workspace }}/
- name: Install Qt
uses: jurplel/install-qt-action@v3
with:
version: '5.15.2'
arch: ${{ matrix.arch == 'x64' && 'win64_msvc2019_64' || 'win32_msvc2019' }}
modules: 'qtwebengine'
- name: Set reusable strings
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- name: Configure CMake for windows
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_PREFIX_PATH="${{ github.workspace }}/lib/cmake/ok-rtc;${{ github.workspace }}/lib/cmake/ok-gloox"
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake"
-DVCPKG_TARGET_TRIPLET=${{ env.VCPKG_DEFAULT_TRIPLET }}
-A ${{ matrix.arch == 'x64' && 'x64' || 'win32' }}
-S ${{ github.workspace }}
- name: Build
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
run: ctest --build-config ${{ matrix.build_type }}
- name: Move artifact.
if: env.UPLOAD_ARTIFACT == 'true'
run: |
mkdir ${{ env.ARTIFACT_PATH }}
cp ${{ steps.strings.outputs.build-output-dir }}\bin\${{ matrix.build_type }}\ok-msg-desktop.exe ${{ env.ARTIFACT_PATH }}
xcopy build\vcpkg_installed\${{ env.VCPKG_DEFAULT_TRIPLET }}\bin\*.dll ${{ env.ARTIFACT_PATH }}
xcopy "$env:Qt5_Dir\bin\*.dll" ${{ env.ARTIFACT_PATH }}
xcopy "C:\Program Files\OpenSSL\bin\libcrypto-1_1-x64.dll" ${{ env.ARTIFACT_PATH }}
xcopy "C:\Program Files\OpenSSL\bin\libssl-1_1-x64.dll" ${{ env.ARTIFACT_PATH }}
Copy-Item -Recurse $env:Qt5_Dir\plugins ${{ env.ARTIFACT_PATH }}
xcopy LICENSE ${{ env.ARTIFACT_PATH }}
rm ${{ env.ARTIFACT_PATH }}\*d.dll
xcopy ChineseSimplified.isl "C:\Program Files (x86)\Inno Setup 6\Languages\"
- name: Compile .ISS to .EXE Installer
uses: Minionguyjpro/[email protected]
with:
path: inno-setup-script.iss
- name: Move setup binary.
if: env.UPLOAD_ARTIFACT == 'true'
run: |
mv ${{ env.ARTIFACT_Setup_Path}}\${{ env.ARTIFACT_Setup_FileName }}.exe ${{ env.ARTIFACT_PATH }}
- name: Upload setup binary to release.
uses: softprops/action-gh-release@v1
if: ${{ startsWith(github.ref, 'refs/tags/') }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: |
${{ env.ARTIFACT_PATH }}/${{ env.ARTIFACT_Setup_FileName }}.exe
- name: Delete setup binary in the origin package release.
if: env.UPLOAD_ARTIFACT == 'true'
run: |
rm ${{ env.ARTIFACT_PATH }}\${{ env.ARTIFACT_Setup_FileName }}.exe
- name: Archive Release
uses: thedoctor0/[email protected]
with:
type: 'zip'
path: ${{ env.ARTIFACT_PATH }}
filename: ok-msg-desktop_${{ matrix.os }}_${{ matrix.arch }}.zip
- name: Upload artifact.
uses: actions/upload-artifact@master
if: env.UPLOAD_ARTIFACT == 'true'
with:
name: ok-msg-desktop_${{matrix.arch}}_${{ matrix.arch }}
path: ${{ env.ARTIFACT_PATH }}
- name: Upload binaries to release
uses: softprops/action-gh-release@v1
if: ${{ startsWith(github.ref, 'refs/tags/') }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
files: |
ok-msg-desktop_${{ matrix.os }}_${{ matrix.arch }}.zip