-
Notifications
You must be signed in to change notification settings - Fork 4
163 lines (163 loc) · 6.04 KB
/
ci.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
name: Continuous Integration
on:
push:
paths-ignore:
- 'docs/**'
- '.github/workflows/pages.yml'
pull_request:
paths-ignore:
- 'docs/**'
- '.github/workflows/pages.yml'
jobs:
build:
name: Build (${{matrix.config}})
runs-on: windows-2022
strategy:
matrix:
config: [RelWithDebInfo, Debug]
steps:
- name: Fetch code-signing key
id: fetch-key
env:
CODE_SIGNING_PFX_BASE64: ${{ secrets.CODE_SIGNING_KEY_PFX_BASE64 }}
run: |
if ("${Env:CODE_SIGNING_PFX_BASE64}" -ne "") {
$pfxPath="${{runner.temp}}/MyCert.pfx"
[System.Convert]::FromBase64String($Env:CODE_SIGNING_PFX_BASE64) | Set-Content $pfxPath -AsByteStream
Add-Content $Env:GITHUB_OUTPUT "HAVE_KEY=true"
Add-Content $Env:GITHUB_OUTPUT "PATH=$pfxPath"
}
- uses: actions/checkout@v4
with:
path: source
fetch-depth: 0
submodules: true
- name: Make build directory
run: cmake -E make_directory build
- name: Configure
working-directory: build
shell: pwsh
run: |
$args = @(
"-DGITHUB_REF_TYPE=${{github.ref_type}}",
"-DGITHUB_REF_NAME=${{github.ref_name}}",
"-DVCPKG_TARGET_TRIPLET=x64-windows-static"
)
if ("${{steps.fetch-key.outputs.HAVE_KEY}}" -eq "true") {
$args += "-DSIGNTOOL_KEY_ARGS=/f;${{steps.fetch-key.outputs.PATH}}"
}
cmake ${{github.workspace}}/source @args
- name: Build
id: build
working-directory: build
run: |
cmake --build . `
--config ${{matrix.config}} `
--parallel `
-- `
/p:CL_MPCount=
$version="$(Get-Content version.txt)"
Add-Content $Env:GITHUB_OUTPUT "VERSION=${version}"
- name: Install debug symbols
id: symbols
working-directory: build
run: |
$prefix="${{runner.temp}}/symbols-inst"
cmake --install . `
--config ${{matrix.config}} `
--prefix $prefix `
--component DebugSymbols
Add-Content $Env:GITHUB_OUTPUT "PATH=$prefix"
echo "::group::Make zip"
$zip = "${{runner.temp}}/DebugSymbols.zip"
cd $prefix
Compress-Archive `
-Path *.pdb `
-DestinationPath $zip
Add-Content $Env:GITHUB_OUTPUT "ZIP_PATH=$zip"
echo "::endgroup::"
- name: Attach debug symbols to build
if: ${{matrix.config != 'Debug' }}
uses: actions/upload-artifact@v4
with:
name: HandTrackedCockpitClicking-GHA-${{github.run_number}}-DebugSymbols
path: ${{steps.symbols.outputs.PATH}}/*.pdb
- name: Create MSI
id: installer
working-directory: build
run: |
# Create MSI
echo "::group::Build 'package' target"
cmake --build . `
--config ${{matrix.config}} `
--target package
echo "::endgroup::"
echo "::group::WiX debug log"
Get-Content _CPack_Packages/win64/WIX/wix.log
echo "::endgroup::"
$version="${{steps.build.outputs.VERSION}}"
$installer="Hand Tracked Cockpit Clicking v${version}.msi"
$installerPath=(Get-ChildItem "${installer}").FullName
echo "File name: ${installer}"
echo "File path: ${installerPath}"
Add-Content $Env:GITHUB_OUTPUT "NAME=${installer}"
Add-Content $Env:GITHUB_OUTPUT "PATH=${installerPath}"
- name: Sign MSI
working-directory: build
if: ${{steps.fetch-key.outputs.HAVE_KEY}}
run: |
# Sign MSI
# Known path for the GitHub Actions windows 2022 runner, may need updating
& 'C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x86\signtool.exe' `
sign `
/d "HTCC Installer" `
/t http://timestamp.digicert.com `
/fd SHA256 `
/f "${{steps.fetch-key.outputs.PATH}}" `
"${{steps.installer.outputs.PATH}}"
- name: Attach installer to build
if: ${{matrix.config != 'Debug' }}
uses: actions/upload-artifact@v4
with:
name: ${{steps.installer.outputs.NAME}}
path: ${{steps.installer.outputs.PATH}}
- name: Generate release notes
if: ${{matrix.config != 'Debug' }}
id: release-notes
run: |
$out = "${{runner.temp}}/release_notes.md"
(Get-Content -Path source/.github/workflows/release_notes.md -raw) `
-replace '@TAG@','${{github.ref_name}}' | `
Set-Content -Path $out -Encoding UTF8
Add-Content $Env:GITHUB_OUTPUT "PATH=$out"
- name: Create draft release
if: github.ref_type == 'tag' && matrix.config != 'Debug'
id: create-release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_name: Release ${{github.ref_name}}
tag_name: ${{github.ref_name}}
draft: true
body_path: ${{steps.release-notes.outputs.PATH}}
- name: Attach MSI to release
if: github.ref_type == 'tag' && matrix.config != 'Debug'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: ${{steps.installer.outputs.PATH}}
asset_name: HTCC-${{github.ref_name}}.msi
asset_content_type: application/msi
- name: Attach debug symbols to release
if: github.ref_type == 'tag' && matrix.config != 'Debug'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN }}
with:
upload_url: ${{steps.create-release.outputs.upload_url}}
asset_path: ${{steps.symbols.outputs.ZIP_PATH}}
asset_name: HTCC-${{github.ref_name}}-DebugSymbols.zip
asset_content_type: application/zip