-
Notifications
You must be signed in to change notification settings - Fork 93
197 lines (188 loc) · 7.68 KB
/
windows_build.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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
name: Windows_Build
on:
workflow_dispatch:
inputs:
ref:
description: 'Ref/hash/tag - blank for head'
required: false
type: string
configuration:
description: 'Configuration'
required: true
default: 'Release'
type: choice
options:
- Release
- Debug
platform:
description: 'Platform'
required: true
default: 'Win32'
type: choice
options:
- Win32
# - ARM
architecture:
description: 'Architecture'
required: true
default: x64
type: choice
options:
- x64
- x86
- arm64
dispose:
description: 'Disposition'
required: true
default: 'Discard'
type: choice
options:
- 'Discard'
- 'Snapshot'
- 'Release'
pull_request:
types: closed
branches: [ 'master', 'Supnik-Current' ]
push:
branches: [ 'master', 'Supnik-Current' ]
# min hr mday mon dow UTC
schedule:
- cron: '23 8 * * 1,3,5' # x64 snapshots
- cron: '13 16 * * 2,4,6' # x86 snapshots
# - cron: '46 20 * * 1,4,7' # Arm snapshots
# GITHUB_SHA last commit GITHUB_REF refs/tags/name
release:
types: published
env:
SOLUTION_FILE: 'Visual Studio Projects\Simh.ci.sln'
REF: ${{ inputs.ref || github.sha }}
BUILD_CONFIGURATION: ${{ inputs.configuration || 'Release' }}
BUILD_PLATFORM: ${{ inputs.platform || 'Win32' }}
BUILD_ARCH: ${{ inputs.architecture || ( github.event_name == 'schedule' && ( ( contains(github.event.schedule, '16') && 'x86' ) || ( contains(github.event.schedule, '20') && 'arm64' ) ) ) || 'x64' }}
DISPOSE: ${{ inputs.dispose || ( github.event_name == 'schedule' && 'Snapshot' ) || ( github.event_name == 'release' && 'Release' ) || 'Discard' }}
permissions:
contents: read
jobs:
build-on-windows:
environment: open-simh-ci
runs-on: windows-latest
steps:
- name: 'Verify configuration'
if: ( env.BUILD_PLATFORM == 'Win32' && env.BUILD_ARCH != 'x86' && env.BUILD_ARCH != 'x64' ) || ( env.BUILD_PLATFORM == 'ARM' && env.BUILD_ARCH != 'arm64' )
shell: cmd
run: |
echo ::error file=windows_build.yml,title=Invalid configuration::Platform ${{ env.BUILD_PLATFORM }} does not support Architecture ${{ env.BUILD_ARCH }}
exit 1
- name: 'Deal with CRLF files in repo'
run: git config --global core.autocrlf input
- name: 'Checkout branch'
uses: actions/checkout@v3
with:
ref: ${{ env.REF }}
- name: Identify branch
shell: pwsh
run: |
$br="${{ github.ref_name || github.head_ref }}"
if ( $null -eq $br ) {
"DISPOSE=Discard" >>$env:GITHUB_ENV
"BRANCH=null" >>$env:GITHUB_ENV
} else {
$br=$br.Trim()
if( $br -eq '' ) {
"DISPOSE=Discard" >>$env:GITHUB_ENV
"BRANCH=empty" >>$env:GITHUB_ENV
} elseif ( $br -match '[Ss]upnik' ) {
"BRANCH=V3" >>$env:GITHUB_ENV
} else {
"BRANCH=V4" >>$env:GITHUB_ENV
}}
- name: Get external libraries
#(Required for V3, V4 will see and skip)
shell: pwsh
run: |
Invoke-WebRequest -Uri "https://github.com/simh/windows-build/archive/windows-build.zip" -UseBasicParsing -OutFile windows-build.zip
Expand-Archive -Path .\windows-build.zip -DestinationPath .\windows-build.tmp
move .\windows-build.tmp\windows-build-windows-build ..\windows-build
del windows-build.tmp
del windows-build.zip
- name: Add MSBuild to PATH for Visual Studio
uses: microsoft/[email protected]
with:
msbuild-architecture: ${{ env.BUILD_ARCH }}
- name: Install PuTTY
run: |
choco install --no-progress putty
- name: Build Simulators with Visual Studio
shell: cmd
working-directory: ${{env.GITHUB_WORKSPACE}}
run: |
msbuild "${{env.SOLUTION_FILE}}" -property:Configuration=${{env.BUILD_CONFIGURATION}} -property:Platform=${{env.BUILD_PLATFORM}}
- name: Compute zipfile name step 1
if: env.DISPOSE != 'Discard'
shell: pwsh
run: |
git log -1 --pretty="COMMIT=%H" >>$env:GITHUB_ENV
$(git log -1 --pretty="#=%aI").Replace("T","-").Replace("#","CDATE").Replace(":","-") >>$env:GITHUB_ENV
echo PACNAME=${{env.BUILD_PLATFORM}}-${{env.BUILD_ARCH}}-${{env.BUILD_CONFIGURATION}} >>$env:GITHUB_ENV
- name: Compute zipfile name step 2
if: env.DISPOSE != 'Discard'
shell: pwsh
run: |
"ZIPNAME=${{env.CDATE}}-${{env.COMMIT}}-${{env.PACNAME}}.zip" >>$env:GITHUB_ENV
- name: Collect results for deployment
if: env.DISPOSE != 'Discard'
shell: cmd
working-directory: ${{env.GITHUB_WORKSPACE}}
run: |
mkdir "${{env.PACNAME}}"
copy "LICENSE.txt" "${{env.PACNAME}}\"
echo This software was created by the Open SIMH Project>"${{env.PACNAME}}\README.txt"
echo For more information, see https://opensimh.org>>"${{env.PACNAME}}\README.txt"
move "BIN\NT\${{env.BUILD_PLATFORM}}-${{env.BUILD_CONFIGURATION}}\*.exe" "${{env.PACNAME}}"
echo Built in ${{ github.repository }} by ${{ github.actor }} (${{ github.event_name }}) from ${{ github.ref_type }}/${{ github.ref_name }}>${{ env.ZIPNAME }}-contents.txt
echo In the zip file, the files reside in ${{env.PACNAME}}\*>>${{ env.ZIPNAME }}-contents.txt
echo Dates/times are UTC>>${{ env.ZIPNAME }}-contents.txt
echo .>>${{ env.ZIPNAME }}-contents.txt
dir "${{env.PACNAME}}" >>${{ env.ZIPNAME }}-contents.txt
- name: Import signing key
if: env.DISPOSE != 'Discard'
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.GPG_KIT_SIGNING_KEY }}
- name: Create and sign zip file
if: env.DISPOSE != 'Discard'
shell: pwsh
working-directory: ${{env.GITHUB_WORKSPACE}}
run: |
Compress-Archive -Path "${{ env.PACNAME }}" -DestinationPath "${{ env.ZIPNAME }}"
gpg --output "${{ env.ZIPNAME }}.sig" --detach-sig "${{ env.ZIPNAME }}"
- name: Deploy new executables to kits server
id: scp-ppk
if: env.DISPOSE != 'Discard'
shell: pwsh
working-directory: ${{env.GITHUB_WORKSPACE}}
env:
SCP_DEPLOY_KEY: '${{ secrets.SCP_DEPLOY_KEY }}'
run: |
$fn = Join-Path -Path $env:RUNNER_TEMP -ChildPath "sdk.ppk";
$eb = [System.Convert]::FromBase64String($env:SCP_DEPLOY_KEY);
Set-Content $fn -Value $eb -AsByteStream;
"SDK=$fn" >>$env:GITHUB_OUTPUT
"KITS_HOST_KEY=" + "${{ vars.KITS_HOST_KEY }}".Trim() + "`n" >>$env:GITHUB_ENV
- name: Save as snapshot
if: ${{ env.DISPOSE == 'Snapshot' }}
shell: cmd
run: |
pscp -p -r -q -batch -noagent -i ${{ steps.scp-ppk.outputs.SDK }} -hostkey "${{ env.KITS_HOST_KEY }}" ${{ env.ZIPNAME }} ${{ env.ZIPNAME }}.sig ${{ env.ZIPNAME }}-contents.txt [email protected]:/var/www/kits/html/${{ env.BRANCH }}/Windows/Snapshots/${{ env.BUILD_ARCH }}/
- name: Save as release
if: env.DISPOSE == 'Release'
shell: cmd
run: |
pscp -p -r -q -batch -noagent -i ${{ steps.scp-ppk.outputs.SDK }} -hostkey "${{ env.KITS_HOST_KEY }}" ${{ env.ZIPNAME }} ${{ env.ZIPNAME }}.sig ${{ env.ZIPNAME }}-contents.txt [email protected]:/var/www/kits/html/${{ env.BRANCH }}/Windows/Releases/${{ env.BUILD_ARCH }}/
- name: cleanup ppk
env:
FN: ${{ steps.scp-ppk.outputs.SDK }}
shell: pwsh
if: always() && ( env.FN != '' )
run: |
Remove-Item -Path $env:FN;