chore: fix some problems #677
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代码时触发workflow | |
push: | |
# 忽略README.md | |
paths-ignore: | |
- "README.md" | |
- "LICENSE" | |
- "BUILD.md" | |
# pull_request时触发workflow | |
pull_request: | |
# 忽略README.md | |
paths-ignore: | |
- "README.md" | |
- "LICENSE" | |
- "BUILD.md" | |
release: | |
types: [published] | |
jobs: | |
build: | |
name: Build | |
strategy: | |
matrix: | |
qt_version: [5.15.2] | |
platform: [windows-latest] | |
build_type: [Release, RelWithDebInfo] | |
arch: [x64] | |
include: | |
- platform: windows-latest | |
arch: x64 | |
qtarch: win64_msvc2019_64 | |
fail-fast: false | |
runs-on: ${{ matrix.platform }} | |
env: | |
targetName: lemon.exe | |
# 步骤 | |
steps: | |
- name: Get the version | |
id: get_version | |
shell: bash | |
run: echo "VERSION=$(echo $GITHUB_REF | cut -d / -f 3)" >> $GITHUB_OUTPUT | |
- name: Checking out sources | |
uses: actions/checkout@v4 | |
with: | |
submodules: "recursive" | |
- name: Install Python 3.9 version | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.9" | |
architecture: ${{ matrix.arch }} | |
- name: Restoring submodules | |
run: git submodule update --init | |
# ========================================================================================================= | |
- name: Install MSVC compiler | |
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@v4 | |
with: | |
path: ../Qt | |
key: QtCache-${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.qt_version }} | |
- name: Installing Qt - ${{ matrix.arch }} | |
uses: jurplel/install-qt-action@v3 | |
with: | |
version: ${{ matrix.qt_version }} | |
arch: ${{ matrix.qtarch }} | |
cached: ${{ steps.cache-qt.outputs.cache-hit }} | |
setup-python: "false" | |
- name: Win-${{ matrix.arch }} - ${{ matrix.qt_version }} - Generate Dependencies and Build | |
shell: bash | |
env: | |
CC: cl.exe | |
CXX: cl.exe | |
run: | | |
cmake . -GNinja -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DLEMON_BUILD_INFO="Build for Windows" -DLEMON_BUILD_EXTRA_INFO="Build on Windows ${{matrix.arch}}" -DENABLE_XLS_EXPORT=ON | |
cmake --build . --parallel $(nproc) | |
- name: package | |
env: | |
archiveName: lemon.${{ steps.get_version.outputs.VERSION }}.Windows-${{ matrix.arch }} | |
shell: pwsh | |
run: | | |
# 创建文件夹 | |
New-Item -ItemType Directory ${{ env.archiveName }} | |
# 拷贝exe | |
Copy-Item ${{ env.targetName }} ${{ env.archiveName}}\ | |
# 拷贝依赖 | |
windeployqt --qmldir . ${{ env.archiveName }}\${{ env.targetName }} | |
# 打包zip | |
Compress-Archive -Path ${{ env.archiveName }} ${{ env.archiveName }}'.zip' | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
env: | |
archiveName: lemon.${{ steps.get_version.outputs.VERSION }}.Windows-${{ matrix.arch }} | |
with: | |
name: lemon-win-${{matrix.arch}}-${{ matrix.build_type }}.zip | |
path: ${{ env.archiveName }}.zip | |
- name: uploadRelease | |
if: startsWith(github.event.ref, 'refs/tags/') | |
uses: svenstaro/upload-release-action@v2 | |
env: | |
archiveName: lemon.${{ steps.get_version.outputs.VERSION }}.Windows-${{ matrix.arch }} | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: ./${{ env.archiveName }}.zip | |
asset_name: lemon-win-${{matrix.arch}}-${{ matrix.build_type }}.zip | |
tag: ${{ github.ref }} | |
overwrite: true |