Skip to content

Commit c0b352c

Browse files
hsbtntkmeclaude
committed
Add the mswin release builds as mswin-X.Y and mswin-head
cache.ruby-lang.org publishes mswin builds of the 3.4 and 4.0 releases, so `mswin-X.Y` installs them and `mswin-head` the master build. `mswin` and `ruby-mswin` keep installing master until their known users move to `mswin-head`. 3.3 and older are left out because their mkmf ignores ENV['PKG_CONFIG'] and would not use the vcpkg pkgconf. mswin is CRuby built with MSVC, so it stays the ruby engine and the CRuby rules apply. `common.inputs.mswin` only selects the builds and keeps them out of the tool cache, where runners hold RubyInstaller builds of the same versions, and in their own bundler-cache key. Co-authored-by: なつき <i@ntk.me> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 5d31ed3 commit c0b352c

13 files changed

Lines changed: 195 additions & 52 deletions

‎.github/workflows/test.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,10 @@ jobs:
8787
run: gem install json -v 2.2.0
8888
- name: C extension test with vcpkg libraries (mswin)
8989
run: gem install fiddle:1.1.8 zlib:3.2.4
90-
if: matrix.ruby == 'mswin'
90+
if: startsWith(matrix.ruby, 'mswin')
9191
- name: Load C extensions linked to vcpkg libraries (mswin)
9292
run: ruby -rfiddle -e 'gem %q(zlib), %q(3.2.4); require %q(zlib); p Zlib.crc32(%q(a))'
93-
if: matrix.ruby == 'mswin'
93+
if: startsWith(matrix.ruby, 'mswin')
9494
- run: bundle --version
9595
# This step is redundant with `bundler-cache: true` but is there to check a redundant `bundle install` still works
9696
- run: bundle install
@@ -123,7 +123,7 @@ jobs:
123123
shell: bash
124124
run: which -a bundle
125125
# https://github.com/ruby/setup-ruby/issues/658
126-
if: "matrix.ruby != 'mingw' && matrix.ruby != 'mswin' && matrix.ruby != 'ucrt'"
126+
if: "matrix.ruby != 'mingw' && matrix.ruby != 'ucrt'"
127127
- name: which rake
128128
run: which -a rake
129129
if: runner.os != 'Windows'

‎README.md‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This action currently supports these versions of MRI, JRuby and TruffleRuby:
1515

1616
| Interpreter | Versions |
1717
| ----------- | -------- |
18-
| `ruby` | 1.9.3, 2.0.0, 2.1.9, 2.2, all versions from 2.3.0 until 4.1.0-preview1, head, debug, mingw, mswin, ucrt |
18+
| `ruby` | 1.9.3, 2.0.0, 2.1.9, 2.2, all versions from 2.3.0 until 4.1.0-preview1, head, debug, mingw, ucrt |
1919
| `jruby` | 9.1.17.0 - 10.1.3.0, head |
2020
| `truffleruby` | 19.3.0 - 40.0.0, head |
2121
| `truffleruby+graalvm` | 21.2.0 - 40.0.0, head |
@@ -28,14 +28,18 @@ Native extensions are automatically compiled with AddressSanitizer when using `r
2828

2929
`ruby-asan` and `asan-release` are currently only available on `ubuntu-24.04` and `ubuntu-26.04`.
3030

31-
Regarding Windows ruby master builds, `mingw` is a MSYS2/MinGW build, `head` & `ucrt` are MSYS2/UCRT64
32-
builds, and `mswin` is a MSVC build.
31+
Regarding Windows ruby master builds, `mingw` is a MSYS2/MinGW build, and `head` & `ucrt` are MSYS2/UCRT64 builds.
32+
33+
`mswin` is CRuby built with MSVC, available on Windows only.
34+
`mswin-4.0` installs the latest 4.0.x release and `mswin-head` the master build.
35+
`mswin` alone also installs the master build for now but will install the latest release in the future, so use `mswin-head` to keep testing master.
36+
The available versions are listed in [windows-mswin-versions.json](windows-mswin-versions.json).
3337

3438
Preview and RC versions of Ruby might be available too on Ubuntu and macOS (not on Windows).
3539
However, it is recommended to test against `ruby-head` rather than previews,
3640
as it provides more useful feedback for the Ruby core team and for upcoming changes.
3741

38-
Only release versions published by [RubyInstaller](https://rubyinstaller.org/downloads/archives/)
42+
Apart from `mswin`, only release versions published by [RubyInstaller](https://rubyinstaller.org/downloads/archives/)
3943
are available on Windows. Due to that, Ruby 2.2 resolves to 2.2.6 on Windows and 2.2.10
4044
on other platforms. Ruby 2.3 on Windows only has builds for 2.3.0, 2.3.1 and 2.3.3.
4145

@@ -54,7 +58,7 @@ The action works on these [GitHub-hosted runners](https://docs.github.com/en/act
5458

5559
Not all combinations of runner images and versions are supported.
5660
The full list of available Ruby versions can be seen in [here for Ubuntu and macOS](https://github.com/ruby/ruby-builder/releases)
57-
and in [windows-versions.json](windows-versions.json) for Windows.
61+
and in [windows-versions.json](windows-versions.json) and [windows-mswin-versions.json](windows-mswin-versions.json) for Windows.
5862
Newer runner images only have builds of the latest patch release of each series,
5963
so prefer a short version like `'3.4'` over an exact one like `'3.4.2'`, or pin to a specific runner version (e.g. `ubuntu-24.04`).
6064
For example, `ubuntu-26.04` (which `ubuntu-latest` now points to, see [this announcement](https://github.com/actions/runner-images/issues/14748))
@@ -63,7 +67,7 @@ only has builds of CRuby 2.3 and newer, as older CRuby versions do not compile o
6367
The prebuilt releases are generated by [ruby-builder](https://github.com/ruby/ruby-builder)
6468
and on Windows by [RubyInstaller2](https://github.com/oneclick/rubyinstaller2).
6569
The `mingw` and `ucrt` builds are generated by [ruby-loco](https://github.com/MSP-Greg/ruby-loco).
66-
The `mswin` build is the daily master build published at [cache.ruby-lang.org](https://cache.ruby-lang.org/pub/ruby/binaries/mswin64/).
70+
The `mswin` builds are generated by [ruby/actions](https://github.com/ruby/actions) and published at [cache.ruby-lang.org](https://cache.ruby-lang.org/pub/ruby/binaries/mswin64/).
6771
`ruby-head` is generated by [ruby-dev-builder](https://github.com/ruby/ruby-dev-builder),
6872
`jruby-head` is generated by [jruby-dev-builder](https://github.com/ruby/jruby-dev-builder),
6973
`truffleruby-head` and `truffleruby+graalvm-head` are generated by [truffleruby-dev-builder](https://github.com/ruby/truffleruby-dev-builder).

‎bundler.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,9 @@ async function computeBaseKey(engine, version, lockFile, cacheVersion) {
254254
const bundleWith = process.env['BUNDLE_WITH'] || ''
255255
const bundleWithout = process.env['BUNDLE_WITHOUT'] || ''
256256
const bundleOnly = process.env['BUNDLE_ONLY'] || ''
257-
let key = `setup-ruby-bundler-cache-v6-${common.getOSNameVersionArch()}-${engine}-${version}-wd-${cwd}-with-${bundleWith}-without-${bundleWithout}-only-${bundleOnly}`
257+
// Gems built for mswin cannot load in the RubyInstaller build of the same version
258+
const ruby = common.inputs.mswin ? `${engine}-${version}-mswin` : `${engine}-${version}`
259+
let key = `setup-ruby-bundler-cache-v6-${common.getOSNameVersionArch()}-${ruby}-wd-${cwd}-with-${bundleWith}-without-${bundleWithout}-only-${bundleOnly}`
258260

259261
if (cacheVersion !== DEFAULT_CACHE_VERSION) {
260262
key += `-v-${cacheVersion}`

‎common.js‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ const PATH_ENV_VAR = windows ? 'Path' : 'PATH'
1717

1818
export const inputs = {
1919
selfHosted: undefined,
20-
token: undefined
20+
token: undefined,
21+
mswin: undefined
2122
}
2223

2324
export function partition(string, separator) {
@@ -70,7 +71,7 @@ export async function time(name, block) {
7071

7172
export function isHeadVersion(rubyVersion) {
7273
// asan-release counts as "head" because the version cannot be selected -- you can only get whatever's latest
73-
return ['head', 'debug', 'mingw', 'mswin', 'ucrt', 'asan', 'asan-release'].includes(rubyVersion)
74+
return ['head', 'debug', 'mingw', 'ucrt', 'asan', 'asan-release'].includes(rubyVersion)
7475
}
7576

7677
export function isStableVersion(engine, rubyVersion) {
@@ -292,7 +293,8 @@ function findWindowsVersion() {
292293
}
293294

294295
export function shouldUseToolCache(engine, version) {
295-
return (engine === 'ruby' && !isHeadVersion(version)) || isSelfHostedRunner()
296+
// The tool cache of runners holds RubyInstaller builds under the same Ruby/<version> names as mswin
297+
return (engine === 'ruby' && !isHeadVersion(version) && !inputs.mswin) || isSelfHostedRunner()
296298
}
297299

298300
export function getToolCachePath() {

‎dist/index.js‎

Lines changed: 52 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎generate-test-matrix.rb‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def unique_versions(versions, segment_count, *symbolic)
4545
# Versions
4646
ruby_builder_versions = JSON.load(File.read('ruby-builder-versions.json'))
4747
windows_versions = JSON.load(File.read('windows-versions.json'))
48+
windows_mswin_versions = JSON.load(File.read('windows-mswin-versions.json'))
4849

4950
# ruby: each minor release + head
5051
ruby_versions = unique_versions(ruby_builder_versions['ruby'], 2, 'head')
@@ -63,8 +64,11 @@ def unique_versions(versions, segment_count, *symbolic)
6364
ruby_loco_versions = %w[mingw ucrt]
6465
matrix += windows_x64_runners.product(ruby_loco_versions)
6566

66-
# mswin: head
67-
matrix += windows_runners.product(%w[mswin])
67+
# mswin: each minor release + head, on the runners of each arch that has a build of it
68+
{ 'x64' => windows_x64_runners, 'arm64' => windows_arm64_runners }.each do |arch, arch_runners|
69+
mswin_versions = windows_mswin_versions.select { |_, builds| builds.key?(arch) }.keys
70+
matrix += arch_runners.product(unique_versions(mswin_versions, 2, 'head').map { |version| "mswin-#{version}" })
71+
end
6872

6973
# asan: latest release + head
7074
asan_versions = %w[asan-release asan]

‎generate-windows-versions.rb‎

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
WINDOWS_VERSIONS_URLS_REGEXPS = [
1010
%r{\A#{Regexp.escape 'https://github.com/oneclick/rubyinstaller/releases/download'}/\w[\w.-]*/\w[\w.-]*\z},
1111
%r{\A#{Regexp.escape 'https://github.com/oneclick/rubyinstaller2/releases/download'}/\w[\w.-]*/\w[\w.-]*\z},
12-
%r{\A#{Regexp.escape 'https://github.com/MSP-Greg/ruby-loco/releases/download'}/\w[\w.-]*/\w[\w.-]*\z},
12+
%r{\A#{Regexp.escape 'https://github.com/MSP-Greg/ruby-loco/releases/download'}/\w[\w.-]*/\w[\w.-]*\z}
13+
].freeze
14+
15+
MSWIN_VERSIONS_URLS_REGEXPS = [
16+
%r{\A#{Regexp.escape 'https://cache.ruby-lang.org/pub/ruby/binaries/mswin64'}/\w[\w.-]*\z},
1317
%r{\A#{Regexp.escape 'https://cache.ruby-lang.org/pub/ruby/binaries/mswin64/dev'}/\w[\w.-]*\z}
1418
].freeze
1519

@@ -67,10 +71,6 @@ def validate(versions, allowed_urls_regexps)
6771
versions['mingw'] = {
6872
'x64' => 'https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-mingw.7z'
6973
}
70-
versions['mswin'] = {
71-
'arm64' => 'https://cache.ruby-lang.org/pub/ruby/binaries/mswin64/dev/ruby-head-arm64-mswin64_140.zip',
72-
'x64' => 'https://cache.ruby-lang.org/pub/ruby/binaries/mswin64/dev/ruby-head-x64-mswin64_140.zip'
73-
}
7474
versions['ucrt'] = {
7575
'x64' => 'https://github.com/MSP-Greg/ruby-loco/releases/download/ruby-master/ruby-ucrt.7z'
7676
}
@@ -107,8 +107,6 @@ def validate(versions, allowed_urls_regexps)
107107
"#{arch}-mingw-ucrt"
108108
when 'mingw'
109109
"#{arch}-mingw32"
110-
when 'mswin'
111-
"#{raw_arch}-mswin64"
112110
else
113111
if version >= Gem::Version.new('3.1.0.dev')
114112
"#{arch}-mingw-ucrt"
@@ -125,3 +123,42 @@ def validate(versions, allowed_urls_regexps)
125123

126124
validate(versions, WINDOWS_TOOLCHAIN_VERSIONS_URLS_REGEXPS)
127125
File.binwrite 'windows-toolchain-versions.json', "#{JSON.pretty_generate(versions)}\n"
126+
127+
mswin_index = JSON.parse(URI.open('https://cache.ruby-lang.org/pub/ruby/binaries/index.json', &:read), symbolize_names: true)
128+
129+
# mkmf of Ruby 3.3 and older ignores ENV['PKG_CONFIG'], so it would not use the vcpkg pkgconf that installVCPKG sets up
130+
mswin_versions = mswin_index[:builds].select { |build|
131+
build[:channel] == 'release' && build[:platform].end_with?('-mswin64_140') && Gem::Version.new(build[:version]) >= Gem::Version.new('3.4')
132+
}.group_by { |build|
133+
build[:version]
134+
}.sort_by { |version, _|
135+
Gem::Version.new(version)
136+
}.to_h { |version, builds_by_version|
137+
builds = builds_by_version.group_by { |build|
138+
build[:platform].delete_suffix('-mswin64_140')
139+
}.sort.to_h { |arch, builds_by_arch|
140+
# A release is repackaged with a higher revision when a bundled library needs an update
141+
[arch, builds_by_arch.max_by { |build| build[:revision] }[:url]]
142+
}
143+
[version, builds]
144+
}
145+
146+
mswin_versions['head'] = {
147+
'arm64' => 'https://cache.ruby-lang.org/pub/ruby/binaries/mswin64/dev/ruby-head-arm64-mswin64_140.zip',
148+
'x64' => 'https://cache.ruby-lang.org/pub/ruby/binaries/mswin64/dev/ruby-head-x64-mswin64_140.zip'
149+
}
150+
151+
validate(mswin_versions, MSWIN_VERSIONS_URLS_REGEXPS)
152+
File.binwrite 'windows-mswin-versions.json', "#{JSON.pretty_generate(mswin_versions)}\n"
153+
154+
mswin_toolchain_versions = mswin_versions.to_h do |raw_version, archs|
155+
version = raw_version == 'head' ? head_version : Gem::Version.new(raw_version)
156+
157+
toolchains = archs.to_h do |arch, _|
158+
[arch, URI.join(base_url, find_toolchain.("#{arch}-mswin64", version)[:href]).to_s]
159+
end
160+
[raw_version, toolchains]
161+
end
162+
163+
validate(mswin_toolchain_versions, WINDOWS_TOOLCHAIN_VERSIONS_URLS_REGEXPS)
164+
File.binwrite 'windows-mswin-toolchain-versions.json', "#{JSON.pretty_generate(mswin_toolchain_versions)}\n"

‎index.js‎

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,14 @@ export async function setupRuby(options = {}) {
5151
process.chdir(inputs['working-directory'])
5252

5353
const platform = common.getOSNameVersion()
54-
const [engine, parsedVersion] = parseRubyEngineAndVersion(inputs['ruby-version'])
54+
const [engine, parsedVersion, mswin] = parseRubyEngineAndVersion(inputs['ruby-version'])
55+
common.inputs.mswin = mswin
5556

5657
let installer
5758
if (platform.startsWith('windows-') && engine === 'ruby' && !common.isSelfHostedRunner()) {
5859
installer = require('./windows')
60+
} else if (mswin) {
61+
throw new Error('mswin is only available on GitHub-hosted Windows runners')
5962
} else {
6063
installer = require('./ruby-builder')
6164
}
@@ -147,13 +150,24 @@ function parseRubyEngineAndVersion(rubyVersion) {
147150
[engine, version] = common.partition(rubyVersion, '-')
148151
}
149152

150-
return [engine, version]
153+
// mswin is CRuby built with MSVC, so it stays the ruby engine and only selects other builds
154+
const mswin = engine === 'mswin' || rubyVersion === 'ruby-mswin'
155+
if (mswin) {
156+
engine = 'ruby'
157+
// mswin and ruby-mswin keep installing the master build until their known users move to mswin-head
158+
if (version === '' || version === 'mswin') {
159+
version = 'head'
160+
}
161+
}
162+
163+
return [engine, version, mswin]
151164
}
152165

153166
function validateRubyEngineAndVersion(platform, engineVersions, engine, parsedVersion) {
154167
if (!engineVersions) {
155168
throw new Error(`Unknown engine ${engine} on ${platform}`)
156169
}
170+
const name = common.inputs.mswin ? 'mswin' : engine
157171

158172
let version = parsedVersion
159173
if (!engineVersions.includes(parsedVersion)) {
@@ -168,8 +182,8 @@ function validateRubyEngineAndVersion(platform, engineVersions, engine, parsedVe
168182
if (found) {
169183
version = found
170184
} else {
171-
throw new Error(`Unknown version ${parsedVersion} for ${engine} on ${platform}
172-
Available versions for ${engine} on ${platform}: ${engineVersions.join(', ')}
185+
throw new Error(`Unknown version ${parsedVersion} for ${name} on ${platform}
186+
Available versions for ${name} on ${platform}: ${engineVersions.join(', ')}
173187
Make sure you use the latest version of the action with - uses: ruby/setup-ruby@v1`)
174188
}
175189
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"3.4.11": {
3+
"x64": "https://github.com/ruby/setup-msys2-gcc/releases/latest/download/vcpkg-x64-windows.7z"
4+
},
5+
"3.4.12": {
6+
"arm64": "https://github.com/ruby/setup-msys2-gcc/releases/latest/download/vcpkg-arm64-windows.7z",
7+
"x64": "https://github.com/ruby/setup-msys2-gcc/releases/latest/download/vcpkg-x64-windows.7z"
8+
},
9+
"4.0.7": {
10+
"x64": "https://github.com/ruby/setup-msys2-gcc/releases/latest/download/vcpkg-x64-windows.7z"
11+
},
12+
"4.0.8": {
13+
"x64": "https://github.com/ruby/setup-msys2-gcc/releases/latest/download/vcpkg-x64-windows.7z"
14+
},
15+
"4.0.9": {
16+
"arm64": "https://github.com/ruby/setup-msys2-gcc/releases/latest/download/vcpkg-arm64-windows.7z",
17+
"x64": "https://github.com/ruby/setup-msys2-gcc/releases/latest/download/vcpkg-x64-windows.7z"
18+
},
19+
"head": {
20+
"arm64": "https://github.com/ruby/setup-msys2-gcc/releases/latest/download/vcpkg-arm64-windows.7z",
21+
"x64": "https://github.com/ruby/setup-msys2-gcc/releases/latest/download/vcpkg-x64-windows.7z"
22+
}
23+
}

‎windows-mswin-versions.json‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"3.4.11": {
3+
"x64": "https://cache.ruby-lang.org/pub/ruby/binaries/mswin64/ruby-3.4.11-x64-mswin64_140.zip"
4+
},
5+
"3.4.12": {
6+
"arm64": "https://cache.ruby-lang.org/pub/ruby/binaries/mswin64/ruby-3.4.12-arm64-mswin64_140.zip",
7+
"x64": "https://cache.ruby-lang.org/pub/ruby/binaries/mswin64/ruby-3.4.12-x64-mswin64_140.zip"
8+
},
9+
"4.0.7": {
10+
"x64": "https://cache.ruby-lang.org/pub/ruby/binaries/mswin64/ruby-4.0.7-x64-mswin64_140.zip"
11+
},
12+
"4.0.8": {
13+
"x64": "https://cache.ruby-lang.org/pub/ruby/binaries/mswin64/ruby-4.0.8-x64-mswin64_140.zip"
14+
},
15+
"4.0.9": {
16+
"arm64": "https://cache.ruby-lang.org/pub/ruby/binaries/mswin64/ruby-4.0.9-arm64-mswin64_140.zip",
17+
"x64": "https://cache.ruby-lang.org/pub/ruby/binaries/mswin64/ruby-4.0.9-x64-mswin64_140.zip"
18+
},
19+
"head": {
20+
"arm64": "https://cache.ruby-lang.org/pub/ruby/binaries/mswin64/dev/ruby-head-arm64-mswin64_140.zip",
21+
"x64": "https://cache.ruby-lang.org/pub/ruby/binaries/mswin64/dev/ruby-head-x64-mswin64_140.zip"
22+
}
23+
}

0 commit comments

Comments
 (0)