-
Notifications
You must be signed in to change notification settings - Fork 2
444 lines (397 loc) · 14.4 KB
/
build.yml
File metadata and controls
444 lines (397 loc) · 14.4 KB
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
name: Build
on:
push:
pull_request:
schedule:
- cron: '0 0 * * *'
workflow_dispatch:
inputs:
force:
description: 'Force new release'
type: boolean
jobs:
msys2:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: windows-2022
sys: mingw64
env: x86_64
- os: windows-2022
sys: ucrt64
env: ucrt-x86_64
- os: windows-11-arm
sys: clangarm64
env: clang-aarch64
steps:
- name: Setup MSYS2
uses: msys2/setup-msys2@v2
id: msys2
with:
msystem: ${{ matrix.sys }}
update: true
install: >-
autoconf-wrapper
autogen
automake-wrapper
bison
compression
diffutils
libtool
m4
make
patch
re2c
texinfo
texinfo-tex
mingw-w64-${{ matrix.env }}-curl
mingw-w64-${{ matrix.env }}-gcc
mingw-w64-${{ matrix.env }}-make
mingw-w64-${{ matrix.env }}-pkgconf
mingw-w64-${{ matrix.env }}-libmangle-git
mingw-w64-${{ matrix.env }}-tools-git
mingw-w64-${{ matrix.env }}-gdbm
mingw-w64-${{ matrix.env }}-gmp
mingw-w64-${{ matrix.env }}-libffi
mingw-w64-${{ matrix.env }}-libyaml
mingw-w64-${{ matrix.env }}-openssl
mingw-w64-${{ matrix.env }}-ragel
mingw-w64-${{ matrix.env }}-readline
- name: Archive MSYS2
run: |
cd "${env:MSYS2_LOCATION}"
7z a "${env:GITHUB_WORKSPACE}\msys2-${{ matrix.sys }}.7z"
env:
MSYS2_LOCATION: ${{ steps.msys2.outputs.msys2-location }}
- name: Upload MSYS2
uses: actions/upload-artifact@v4
with:
name: msys2-${{ matrix.sys }}
path: msys2-${{ matrix.sys }}.7z
compression-level: 0
if-no-files-found: error
- name: Download MSYS2 Package Cache
run: pacman -Qq | xargs pacman -Sw --noconfirm
shell: msys2 {0}
- name: Archive MSYS2 Package Cache
run: |
cd "${env:MSYS2_LOCATION}\var\cache\pacman\pkg"
7z a "${env:GITHUB_WORKSPACE}\msys2-${{ matrix.sys }}-var-cache-pacman-pkg.7z"
env:
MSYS2_LOCATION: ${{ steps.msys2.outputs.msys2-location }}
- name: Upload MSYS2 Package Cache
uses: actions/upload-artifact@v4
with:
name: msys2-${{ matrix.sys }}-var-cache-pacman-pkg
path: msys2-${{ matrix.sys }}-var-cache-pacman-pkg.7z
compression-level: 0
if-no-files-found: error
- name: Create MSYS2 Package List
run: pacman -Q | tee msys2-${{ matrix.sys }}.packages.txt
shell: msys2 {0}
- name: Upload MSYS2 Package List
uses: actions/upload-artifact@v4
with:
name: msys2-${{ matrix.sys }}-packages-txt
path: msys2-${{ matrix.sys }}.packages.txt
if-no-files-found: error
msys2-extra:
needs: [msys2]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: windows-2022
sys: mingw64
env: x86_64
variant: -gcc@14-openssl@1.1
install: >-
gcc-14.2.0-3
gcc-libs-14.2.0-3
openssl-1.1.1.w-1
- os: windows-2022
sys: ucrt64
env: ucrt-x86_64
variant: -gcc@14
install: >-
gcc-14.2.0-3
gcc-libs-14.2.0-3
- os: windows-2022
sys: ucrt64
env: ucrt-x86_64
variant: -gcc@14-openssl@1.1
install: >-
gcc-14.2.0-3
gcc-libs-14.2.0-3
openssl-1.1.1.w-1
steps:
- name: Download MSYS2
uses: actions/download-artifact@v4
with:
name: msys2-${{ matrix.sys }}
- name: Setup MSYS2
id: msys2
run: |
7z x msys2-${{ matrix.sys }}.7z "-o${env:RUNNER_TEMP}\msys64"
md ${env:RUNNER_TEMP}\setup-msys2
echo @"
@echo off
setlocal
set CHERE_INVOKING=1
IF NOT DEFINED MSYSTEM set MSYSTEM=$("${{ matrix.sys }}".ToUpper())
IF NOT DEFINED MSYS2_PATH_TYPE set MSYS2_PATH_TYPE=minimal
${env:RUNNER_TEMP}\msys64\usr\bin\bash.exe -leo pipefail %*
"@ | tee ${env:RUNNER_TEMP}\setup-msys2\msys2.cmd
echo "${env:RUNNER_TEMP}\setup-msys2" | Tee-Object -FilePath "${env:GITHUB_PATH}" -Encoding UTF8
echo "msys2-location=${env:RUNNER_TEMP}\msys64" | Tee-Object -FilePath "${env:GITHUB_OUTPUT}" -Append -Encoding UTF8
- name: Download
run: |
foreach ($pkg in (-split $env:INSTALL)) {
gh release download msys2-packages --repo ${{ github.repository }} --pattern "${pkg}*" --pattern "mingw-w64-${{ matrix.env }}-${pkg}*"
}
Get-ChildItem
env:
GH_TOKEN: ${{ github.token }}
INSTALL: ${{ matrix.install }}
- name: Trust ri2 package signing key
if: contains(matrix.install, 'openssl-1.1')
run: |
pacman-key --recv-keys 79D1D4E12FF93365DEAA8DCEF98B8484BE8BF1C5
pacman-key --lsign-key 79D1D4E12FF93365DEAA8DCEF98B8484BE8BF1C5
shell: msys2 {0}
- name: Backup openssl dll/cnf files
if: contains(matrix.install, 'openssl-1.1')
run: pacman -Qql mingw-w64-${{ matrix.env }}-openssl | grep '/bin/[^/]\+\.dll$\|/etc/ssl/[^/]\+\.cnf$' | xargs -- tar -cvf openssl.orig.tar -PC / --
shell: msys2 {0}
- name: Install
run: find . -name '*.pkg.*' -not -name '*.sig' -print0 | xargs -0 -- pacman -Udd --noconfirm
shell: msys2 {0}
- name: Restore openssl dll/cnf files
if: contains(matrix.install, 'openssl-1.1')
run: tar -xvf openssl.orig.tar -PC /
shell: msys2 {0}
- name: Archive MSYS2
run: |
cd "${env:MSYS2_LOCATION}"
7z a "${env:GITHUB_WORKSPACE}\msys2-${{ matrix.sys }}${{ matrix.variant }}.7z"
env:
MSYS2_LOCATION: ${{ steps.msys2.outputs.msys2-location }}
- name: Upload MSYS2
uses: actions/upload-artifact@v4
with:
name: msys2-${{ matrix.sys }}${{ matrix.variant }}
path: msys2-${{ matrix.sys }}${{ matrix.variant }}.7z
compression-level: 0
if-no-files-found: error
- name: Create MSYS2 Package List
run: pacman -Q | tee msys2-${{ matrix.sys }}${{ matrix.variant }}.packages.txt
shell: msys2 {0}
- name: Upload MSYS2 Package List
uses: actions/upload-artifact@v4
with:
name: msys2-${{ matrix.sys }}${{ matrix.variant }}-packages-txt
path: msys2-${{ matrix.sys }}${{ matrix.variant }}.packages.txt
if-no-files-found: error
vcpkg:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: windows-2022
triplet: x64-windows
- os: windows-11-arm
triplet: arm64-windows
steps:
- name: Create vcpkg.json
run: |
echo @'
{
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
"dependencies": [
"gmp",
"libyaml",
"libffi",
"pkgconf",
"openssl",
"readline-win32",
"zlib"
]
}
'@ | Tee-Object -FilePath vcpkg.json -Encoding UTF8
- name: Dry Run
run: vcpkg install --dry-run | Tee-Object -FilePath vcpkg-install.log -Encoding UTF8
- name: Cache
uses: actions/cache@v4
with:
path: vcpkg_binary_cache
key: ${{ runner.os }}-${{ runner.arch }}-vcpkg-${{ hashFiles('vcpkg-install.log') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-vcpkg-
- name: Install
run: vcpkg install
env:
VCPKG_BINARY_SOURCES: clear;files,${{ github.workspace }}\vcpkg_binary_cache,readwrite
- name: Export
run: |
vcpkg export --raw --output vcpkg_exported --output-dir=$pwd
mkdir vcpkg
mv vcpkg_exported\installed vcpkg\installed
cd vcpkg
7z a ..\vcpkg-${{ matrix.triplet }}.7z
- name: Upload vcpkg Export
uses: actions/upload-artifact@v4
with:
name: vcpkg-${{ matrix.triplet }}
path: vcpkg-${{ matrix.triplet }}.7z
compression-level: 0
if-no-files-found: error
- name: Create vcpkg Package List
run: vcpkg list | Tee-Object -FilePath "vcpkg-${{ matrix.triplet }}.packages.txt" -Encoding UTF8
- name: Upload vcpkg Package List
uses: actions/upload-artifact@v4
with:
name: vcpkg-${{ matrix.triplet }}-packages-txt
path: vcpkg-${{ matrix.triplet }}.packages.txt
if-no-files-found: error
test:
needs: [msys2, msys2-extra, vcpkg]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: windows-2022
ruby-version: '3.0'
sys: mingw64
variant: -gcc@14-openssl@1.1
- os: windows-2022
ruby-version: '3.1'
sys: ucrt64
variant: -gcc@14-openssl@1.1
- os: windows-2022
ruby-version: '3.2'
sys: ucrt64
variant: -gcc@14
- os: windows-11-arm
ruby-version: '3.4'
sys: clangarm64
steps:
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
windows-toolchain: none
- name: Download MSYS2
uses: actions/download-artifact@v4
with:
name: msys2-${{ matrix.sys }}${{ matrix.variant }}
- name: Setup MSYS2
id: msys2
run: |
$rubyPrefix = ruby -e 'puts RbConfig::TOPDIR.tr(File::SEPARATOR, File::ALT_SEPARATOR)'
7z x msys2-${{ matrix.sys }}${{ matrix.variant }}.7z "-o${env:RUNNER_TEMP}\msys64"
New-Item -ItemType Junction -Path "${rubyPrefix}\msys64" -value "${env:RUNNER_TEMP}\msys64"
echo "msys2-location=${rubyPrefix}\msys64" | Tee-Object -FilePath "${env:GITHUB_OUTPUT}" -Append -Encoding UTF8
- name: Setup PATH
run: |
echo "${env:MSYS2_LOCATION}\usr\bin" | Tee-Object -FilePath "${env:GITHUB_PATH}" -Append -Encoding UTF8
echo "${env:MSYS2_LOCATION}\${{ matrix.sys }}\bin" | Tee-Object -FilePath "${env:GITHUB_PATH}" -Append -Encoding UTF8
env:
MSYS2_LOCATION: ${{ steps.msys2.outputs.msys2-location }}
- name: Enable ridk
run: |
ruby -r json -e @'
JSON
.parse(`ridk.cmd enable >NUL 2>&1 && ruby -r json -e "puts JSON.fast_generate(ENV.to_h)"`)
.each do |name, value|
puts "#{name}=#{value}" if name != 'Path' && ENV[name] != value
end
'@ | Tee-Object -FilePath "${env:GITHUB_ENV}" -Append -Encoding UTF8
# Subset of tests copied from ruby/setup-ruby
- run: ruby -v
- name: PATH
shell: pwsh
run: |
# Show PATH with Powershell
$f, $r = $env:PATH.split([IO.Path]::PathSeparator); $r
- name: build compiler
run: |
ruby -e "puts 'build compiler: ' + RbConfig::CONFIG.fetch('CC_VERSION_MESSAGE', 'unknown').lines.first"
- name: gcc and ridk version (mingw)
if: startsWith(matrix.os, 'windows')
run: |
$abi, $plat = $(ruby -e "STDOUT.write RbConfig::CONFIG['ruby_version'] + ' ' + RUBY_PLATFORM").split(' ')
if ($plat.Contains('mingw')) {
gcc --version
if ($abi -ge '2.4') {
ridk version
} else {
echo 'ridk is unavailable'
}
} elseif ($plat.Contains('mswin')) {
&"$env:VCPKG_INSTALLATION_ROOT\vcpkg" list
}
- name: RbConfig::CONFIG
run: ruby -rrbconfig -rpp -e 'pp RbConfig::CONFIG'
- name: RbConfig::MAKEFILE_CONFIG
run: ruby -rrbconfig -rpp -e 'pp RbConfig::MAKEFILE_CONFIG'
- name: OpenSSL compiled version
run: ruby -ropenssl -e 'puts OpenSSL::OPENSSL_VERSION'
- name: OpenSSL loaded version
run: ruby -ropenssl -e 'puts OpenSSL::OPENSSL_LIBRARY_VERSION'
- name: OpenSSL test
run: ruby -ropen-uri -e 'puts URI.send(:open, %{https://rubygems.org/}) { |f| f.read(1024) }'
- run: gem env
- name: C extension test
run: gem install json -v 2.2.0
changelog:
needs: [msys2, msys2-extra, vcpkg]
runs-on: ubuntu-latest
outputs:
diff: ${{ steps.diff.outputs.diff }}
changelog: ${{ steps.changelog.outputs.changelog }}
steps:
- name: Download Latest Release
run: |
mkdir a
cd a
gh release download --repo ${{ github.repository }} --pattern '*.packages.txt' || true
env:
GH_TOKEN: ${{ github.token }}
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: b
pattern: '*-packages-txt'
merge-multiple: true
- name: Diff
id: diff
run: echo "diff=$(diff -qr a b &>/dev/null && echo false || echo true)" | tee -a "$GITHUB_OUTPUT"
- name: Changelog
id: changelog
run: |
{ echo '``` diff'; diff -rNU0 a b; echo '```'; } | tee CHANGELOG.md
echo "changelog=$(base64 -w0 <CHANGELOG.md)" | tee -a "$GITHUB_OUTPUT"
release:
needs: [test, changelog]
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && needs.changelog.outputs.diff == 'true' || inputs.force
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
merge-multiple: true
- name: Release
run: |
tag=v$(date +%Y%m%d.%H%M%S)
gh release create "$tag" ./* --repo ${{ github.repository }} --draft --notes "$(echo "$CHANGELOG" | base64 -d)"
gh release edit "$tag" --repo ${{ github.repository }} --draft=false
env:
CHANGELOG: ${{ needs.changelog.outputs.changelog }}
GH_TOKEN: ${{ github.token }}