-
Notifications
You must be signed in to change notification settings - Fork 5
178 lines (165 loc) · 6.92 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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
name: Windows Build
on:
push:
release:
types: [prereleased]
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
user: upupming
name: vscode-qt-qml-vcpkg-template
# Disk C has 90GB free size, while disk D only has 11.3GB free disk size
# Override github envs, for vcpkg action to work properly: https://github.com/lukka/run-vcpkg/blob/36477d05567caebad06ad53713dcbde226135205/dist/index.js#L4891
GITHUB_WORKSPACE: C:/vscode-qt-qml-vcpkg-template
BUILD_SOURCESDIRECTORY: C:/vscode-qt-qml-vcpkg-template
srcDir: C:/vscode-qt-qml-vcpkg-template
buildDir: C:/vscode-qt-qml-vcpkg-template/build
jobs:
check_commit_msg:
outputs:
commit_message: ${{ steps.get_message.outputs.message }}
name: Check if the workflow has been disabled.
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Get commit message
id: get_message
run: |
echo "::set-output name=message::$(git log --format=%B -n 1 ${{ github.event.after }})"
echo "::set-env name=message::$(git log --format=%B -n 1 ${{ github.event.after }})"
build:
needs: check_commit_msg
if: ${{ !contains( needs.check_commit_msg.outputs.commit_message, 'NO_WIN') }}
strategy:
matrix:
qt_version: [5.15.0]
platform: [windows-latest]
arch: [
# x86,
x64,
]
include:
# x86 is get error (qt cannot be installed)
# - platform: windows-latest
# arch: x86
# qtarch: win32_msvc2019
- platform: windows-latest
arch: x64
qtarch: win64_msvc2019_64
fail-fast: false
runs-on: ${{ matrix.platform }}
steps:
- name: Get the version
id: get_version
shell: bash
run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3)
- uses: actions/checkout@v2
with:
repository: ${{ env.user }}/${{ env.name }}
submodules: recursive
- name: Copy sources
shell: bash
run: |
cp -r $GITHUB_WORKSPACE/. ${{ env.srcDir }}
ls ${{ env.srcDir }}/
ls ${{ env.srcDir }}/.git
ls ${{ env.srcDir }}/vcpkg
- name: Setup cmake
uses: jwlawson/[email protected]
with:
cmake-version: "3.20"
# =========================================================================================================
- name: Install MSVC compiler
uses: ilammy/msvc-dev-cmd@v1
with:
# 14.1 is for vs2017, 14.2 is vs2019
toolset: 14.2
arch: ${{ matrix.arch }}
# Restore from cache the previously built ports. If cache-miss, download and build vcpkg (aka "bootstrap vcpkg").
- name: Restore from cache and install vcpkg
# Download and build vcpkg, without installing any port. If content is cached already, it is a no-op.
uses: lukka/run-vcpkg@v6
with:
# Just install vcpkg for now, do not install any ports in this step yet.
setupOnly: true
# Location of the vcpkg submodule in the Git repository.
vcpkgDirectory: "${{ env.srcDir }}/vcpkg"
# Since the cache must be invalidated when content of the vcpkg.json file changes, let's
# compute its hash and append this to the computed cache's key.
appendedCacheKey: ${{ hashFiles( '**/vcpkg_manifest/vcpkg.json' ) }}
vcpkgTriplet: ${{ matrix.arch }}-windows
# Ensure the vcpkg artifacts are cached, they are generated in the 'CMAKE_BINARY_DIR/vcpkg_installed' directory.
additionalCachedPaths: ${{ env.buildDir }}/vcpkg_installed
- name: Cache Qt
id: cache-qt
uses: actions/cache@v1
with:
path: ../Qt
key: QtCache-${{ matrix.platform }}-${{ matrix.arch }}-${{ matrix.qt_version }}
- name: Installing Qt - ${{ matrix.arch }}
uses: jurplel/install-qt-action@v2
with:
version: ${{ matrix.qt_version }}
arch: ${{ matrix.qtarch }}
cached: ${{ steps.cache-qt.outputs.cache-hit }}
# =========================================================================================================
- name: Win-${{ matrix.arch }} - ${{ matrix.qt_version }} - Setup Ninja
if: matrix.platform == 'windows-latest'
uses: ashutoshvarma/setup-ninja@master
with:
# ninja version to download. Default: 1.10.0
version: 1.10.0
# ========================================================================================================= Generate MakeFile and Build
- name: Win-${{ matrix.arch }} - ${{ matrix.qt_version }} - Generate Dependencies and Build
shell: powershell
env:
CC: cl.exe
CXX: cl.exe
# https://stackoverflow.com/questions/31262342/cmake-g-ninja-on-windows-specify-x64?rq=1
run: |
Get-PsDrive
cmake --version
ninja --version
cmake -S ${{ env.srcDir }} -B ${{ env.buildDir }} -GNinja -DCMAKE_BUILD_TYPE=Release
cmake --build ${{ env.buildDir }} --target all --parallel $(nproc)
cd ${{ env.buildDir }}
windeployqt.exe --release --qmldir .. ./${{ env.name }}.exe
Get-PsDrive
- name: If the job has failed
if: ${{ failure() }}
run: |
ls ${{ env.srcDir }}/build/
cat ${{ env.srcDir }}/build/vcpkg-manifest-install.log
- name: Set outputs
id: vars
run: |
cd ${{ env.srcDir }}
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
- name: Get Time
id: time
uses: nanzm/[email protected]
with:
timeZone: 8
format: "YYYY-MM-DD-HH-mm-ss"
- name: Win-${{ matrix.arch }} - ${{ matrix.qt_version }} - uploading artifact (whole zip)
uses: actions/upload-artifact@master
with:
name: ${{ env.name }}-${{ steps.time.outputs.time }}-${{ steps.vars.outputs.sha_short }}-windows-${{ matrix.arch }}-package
path: |
${{ env.buildDir }}
!${{ env.buildDir }}/.cmake
!${{ env.buildDir }}/CMakeFiles
!${{ env.buildDir }}/cmake_install.cmake
!${{ env.buildDir }}/CMakeCache.txt
!${{ env.buildDir }}/.ninja_deps
!${{ env.buildDir }}/.ninja_log
!${{ env.buildDir }}/build.ninja
!${{ env.buildDir }}/**/*autogen*
!${{ env.buildDir }}/vcpkg_installed
!${{ env.buildDir }}/**/*.log
!${{ env.buildDir }}/*.manifest
!${{ env.buildDir }}/compile_commands.json
- name: Win-${{ matrix.arch }} - ${{ matrix.qt_version }} - uploading artifact (only the exe)
uses: actions/upload-artifact@master
with:
name: ${{ env.name }}-${{ steps.time.outputs.time }}-${{ steps.vars.outputs.sha_short }}-windows-${{ matrix.arch }}-exe
path: ${{ env.buildDir }}/${{ env.name }}.exe