fix: CI/CD #112
This file contains 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: Windows | |
on: | |
push: | |
paths-ignore: | |
- '*.md' | |
pull_request: | |
paths-ignore: | |
- '*.md' | |
jobs: | |
build: | |
name: Build | |
# 运行平台, windows-latest目前是windows server 2022 | |
# 参考文档 https://github.com/actions/runner-images/blob/main/images/windows/Windows2019-Readme.md | |
runs-on: windows-2019 | |
strategy: | |
# 矩阵配置 | |
matrix: | |
qt_target: [desktop] | |
include: | |
# 5.15.2 参考 https://mirrors.cloud.tencent.com/qt/online/qtsdkrepository/windows_x86/desktop/qt5_5152/ | |
- qt_ver: 5.15.2 | |
qt_arch: win32_msvc2019 | |
msvc_arch: x86 | |
qt_arch_install: msvc2019 | |
- qt_ver: 5.15.2 | |
qt_arch: win64_msvc2019_64 | |
msvc_arch: x64 | |
qt_arch_install: msvc2019_64 | |
env: | |
targetName: ChineseChess | |
targetOS: windows | |
steps: | |
- name: Install Qt | |
uses: jurplel/install-qt-action@v3 | |
with: | |
version: ${{ matrix.qt_ver }} | |
arch: ${{ matrix.qt_arch }} | |
set-env: true | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
submodules: true | |
- name: Inspect Qt | |
shell: pwsh | |
run: | | |
Get-ChildItem -Recurse -Path $Env:Qt5_Dir | |
- name: msvc-build | |
id: msvc-build | |
shell: cmd | |
run: | | |
mkdir bin | |
mkdir build | |
cd build | |
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.msvc_arch }} | |
if "${{ matrix.msvc_arch }}" == "x86" ( | |
echo "-------------- x86 --------------" | |
cmake -G "Visual Studio 17 2019" -A Win32 .. | |
devenv "${{ env.targetName }}.sln" /Build "Release|Win32" | |
) else ( | |
echo "-------------- x64 --------------" | |
cmake -G "Visual Studio 16 2019" -A x64 .. | |
devenv "${{ env.targetName }}.sln" /Build "Release|x64" | |
) | |
- name: name version | |
id: name-version | |
if: startsWith(github.event.ref, 'refs/tags/') | |
shell: pwsh | |
run: | | |
$systemInfo="${{ env.targetOS }}-${{ matrix.msvc_arch }}" | |
$productVersion="${{ github.ref }}".substring("refs/tags/v".length) | |
$productName="${{ env.targetName }}-$productVersion-$systemInfo" | |
echo "systemInfo=$systemInfo" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
echo "productVersion=$productVersion" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
echo "productName=$productName" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append | |
# tag打为.zip包 | |
- name: package | |
id: package | |
if: startsWith(github.event.ref, 'refs/tags/') | |
shell: pwsh | |
run: | | |
Copy-Item -Path build/bin/Release/* -Destination bin/ | |
dir bin | |
echo "-------------- debug 1 --------------" | |
# ${{ env.GITHUB_PATH }}/windeployqt bin/${{ env.targetName }}.exe # cache 时使用 | |
windeployqt bin/${{ env.targetName }}.exe | |
echo "-------------- debug 2 --------------" | |
Compress-Archive -Path ${{ github.workspace }}/bin/* -Destination ${{ env.productName }}.zip | |
dir ${{ github.workspace }}/bin | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: my-artifact | |
path: ${{ env.productName }}.zip | |
# tag上传Release | |
- name: uploadRelease | |
if: startsWith(github.event.ref, 'refs/tags/') | |
uses: softprops/action-gh-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.upload_release }} | |
with: | |
draft: false | |
prerelease: false | |
files: | | |
${{ env.productName }}.zip | |
tag: ${{ github.ref }} | |
overwrite: true |