Update: 来自[DelegateUI]的一些更新. #25
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: CMake on Windows | |
on: | |
push: | |
pull_request: | |
jobs: | |
build: | |
permissions: write-all | |
name: Build | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [windows-latest] | |
build_types: [Release] | |
c_compiler: [cl] | |
cxx_compiler: [cl] | |
include: | |
- qt_ver: 5.15.2 | |
qt_arch: win64_msvc2019_64 | |
qt_arch_install: msvc2019_64 | |
msvc_arch: x64 | |
env: | |
fileName: 'QmlControls' | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
- name: Setup ninja | |
uses: seanmiddleditch/gha-setup-ninja@master | |
with: | |
version: 1.10.2 | |
- name: Install Qt | |
uses: jurplel/install-qt-action@v3 | |
with: | |
version: ${{ matrix.qt_ver }} | |
arch: ${{ matrix.qt_arch }} | |
- name: Set reusable strings | |
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file. | |
id: strings | |
shell: bash | |
run: | | |
echo "build-output-dir=${{ github.workspace }}\build" >> "$GITHUB_OUTPUT" | |
- name: Build | |
id: build | |
shell: cmd | |
run: | | |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.msvc_arch }} | |
ninja --version | |
cmake -B ${{ steps.strings.outputs.build-output-dir }} -S ${{ github.workspace }} ^ | |
-DCMAKE_MESSAGE_LOG_LEVEL=STATUS ^ | |
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} ^ | |
-DCMAKE_CXX_COMPILER=${{ matrix.cxx_compiler }} ^ | |
-DCMAKE_BUILD_TYPE=${{ matrix.build_types }} ^ | |
-GNinja | |
cd ${{ steps.strings.outputs.build-output-dir }} | |
cmake --build . --config ${{ matrix.build_types }} --parallel --target all -- | |
cmake --build . --config ${{ matrix.build_types }} --parallel --target Script-DeployRelease -- | |
echo winSdkDir=%WindowsSdkDir% >> %GITHUB_ENV% | |
echo winSdkVer=%WindowsSdkVersion% >> %GITHUB_ENV% | |
echo vcToolsInstallDir=%VCToolsInstallDir% >> %GITHUB_ENV% | |
echo vcToolsRedistDir=%VCToolsRedistDir% >> %GITHUB_ENV% | |
- name: Package | |
id: package | |
env: | |
archiveName: ${{ env.fileName }}-${{ matrix.qt_arch }}-${{ matrix.qt_ver }} | |
msvcArch: ${{ matrix.msvc_arch }} | |
shell: pwsh | |
run: | | |
#删除 vc_redist.x64.exe | |
Remove-Item -Path "package\vc_redist.x64.exe" -ErrorAction SilentlyContinue | |
# 拷贝vcRedist dll | |
$redistDll="{0}{1}\*.CRT\*.dll" -f $env:vcToolsRedistDir.Trim(),$env:msvcArch | |
Copy-Item $redistDll package\ | |
# 拷贝WinSDK dll | |
$sdkDll="{0}Redist\{1}ucrt\DLLs\{2}\*.dll" -f $env:winSdkDir.Trim(),$env:winSdkVer.Trim(),$env:msvcArch | |
Copy-Item $sdkDll package\ | |
# 打包zip | |
Compress-Archive -Path package\* -DestinationPath "${env:archiveName}.zip" | |
# 记录 packageName 给后续 step | |
$name = ${env:archiveName} | |
echo "packageName=$name" >> $env:GITHUB_OUTPUT | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.package.outputs.packageName }} | |
path: package | |
- name: Upload Release | |
if: startsWith(github.event.ref, 'refs/tags/') | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: ${{ steps.package.outputs.packageName }}.zip | |
asset_name: ${{ env.fileName }}_${{ github.ref_name }}_${{ matrix.os }}_Qt${{ matrix.qt_ver }}.zip | |
tag: ${{ github.ref }} | |
overwrite: true |