-
Notifications
You must be signed in to change notification settings - Fork 57
109 lines (109 loc) · 3.58 KB
/
windows.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: Windows
on:
# push代码时触发workflow
push:
# 忽略README.md
paths-ignore:
- 'README.md'
- 'LICENSE'
# pull_request时触发workflow
pull_request:
# 忽略README.md
paths-ignore:
- 'README.md'
- 'LICENSE'
jobs:
build:
name: Build
# 运行平台, windows-latest目前是windows server 2019
runs-on: windows-latest
strategy:
fail-fast: false
# 矩阵配置
matrix:
qt_ver: [5.15.0]
qt_target: [desktop]
# mingw用不了
# qt_arch: [win64_msvc2017_64, win32_msvc2017, win32_mingw53,win32_mingw73]
qt_arch: [win64_msvc2019_64]
# 额外设置msvc_arch
include:
- qt_arch: win64_msvc2019_64
msvc_arch: x64
qt_arch_install: msvc2019_64
env:
targetName: lemon.exe
# 步骤
steps:
- name: cacheQt
id: WindowsCacheQt
uses: actions/cache@v1
with:
path: ../Qt/${{matrix.qt_ver}}/${{matrix.qt_arch_install}}
key: ${{ runner.os }}-Qt/${{matrix.qt_ver}}/${{matrix.qt_arch}}
- name: setupQt
if: steps.WindowsCacheQt.outputs.cache-hit == 'true'
shell: pwsh
env:
QtPath: ../Qt/${{matrix.qt_ver}}/${{matrix.qt_arch_install}}
run: |
$qt_Path=${env:QtPath}
echo "::set-env name=Qt5_Dir::$qt_Path"
echo "::add-path::$qt_Path/bin"
# 安装Qt
- name: Install Qt
if: steps.WindowsCacheQt.outputs.cache-hit != 'true'
# 使用外部action。这个action专门用来安装Qt
uses: jurplel/install-qt-action@v2.6.3
with:
# Version of Qt to install
version: ${{ matrix.qt_ver }}
# Target platform for build
target: ${{ matrix.qt_target }}
# Architecture for Windows/Android
arch: ${{ matrix.qt_arch }}
aqtversion: ">=0.9.0"
# 拉取代码
- uses: actions/checkout@v2
with:
fetch-depth: 1
submodules: true
# 编译msvc
- name: build-msvc
shell: cmd
env:
vc_arch: ${{ matrix.msvc_arch }}
run: |
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" %vc_arch%
qmake lemon.pro
nmake
# tag 打包
- name: package
if: startsWith(github.event.ref, 'refs/tags/')
env:
VCINSTALLDIR: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC'
archiveName: ${{ matrix.qt_ver }}-${{ matrix.qt_target }}-${{ matrix.qt_arch }}
shell: pwsh
run: |
# 创建文件夹
New-Item -ItemType Directory ${env:archiveName}
# 拷贝exe
Copy-Item release\${env:targetName} ${env:archiveName}\
# 拷贝依赖
windeployqt --qmldir . ${env:archiveName}\${env:targetName}
# 打包zip
Compress-Archive -Path ${env:archiveName} ${env:archiveName}'.zip'
# 记录环境变量packageName给后续step
$name = ${env:archiveName}
echo "::set-env name=packageName::$name"
# 打印环境变量packageName
Write-Host 'packageName:'${env:packageName}
- name: uploadRelease
if: startsWith(github.event.ref, 'refs/tags/')
uses: svenstaro/upload-release-action@v1-release
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./${{ env.packageName }}.zip
asset_name: ${{ env.packageName }}.zip
tag: ${{ github.ref }}
overwrite: true