Skip to content

Commit f70e6bf

Browse files
MSP-Gregeregon
authored andcommitted
Update for Actions MSYS2 install
1. Use 'Git for Windows' cert.pem file 2. Add MSYS2 to path for mswin (after msvc additions) 3. Rearrange code for cleanup when MSYS2 is added to Window image
1 parent d96d389 commit f70e6bf

File tree

2 files changed

+54
-34
lines changed

2 files changed

+54
-34
lines changed

dist/index.js

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

windows.js

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ const exec = require('@actions/exec')
88
const tc = require('@actions/tool-cache')
99
const rubyInstallerVersions = require('./windows-versions').versions
1010

11+
// needed for 2.2, 2.3, and mswin, cert file used by Git for Windows
12+
const certFile = 'C:\\Program Files\\Git\\mingw64\\ssl\\cert.pem'
13+
14+
// standard MSYS2 location, found by 'devkit'
15+
const msys2 = 'C:\\msys64'
16+
1117
export function getAvailableVersions(platform, engine) {
1218
if (engine === 'ruby') {
1319
return Object.keys(rubyInstallerVersions)
@@ -33,11 +39,8 @@ export async function install(platform, ruby) {
3339
await exec.exec('7z', ['x', downloadPath, `-xr!${base}\\share\\doc`, `-o${drive}:\\`], { silent: true })
3440
const rubyPrefix = `${drive}:\\${base}`
3541

36-
// we use certs and embedded MSYS2 from hostedRuby
37-
const hostedRuby = latestHostedRuby()
38-
3942
let toolchainPaths = (version === 'mswin') ?
40-
await setupMSWin(hostedRuby) : await setupMingw(hostedRuby, version)
43+
await setupMSWin() : await setupMingw(version)
4144
const newPathEntries = [`${rubyPrefix}\\bin`, ...toolchainPaths]
4245

4346
// Install Bundler if needed
@@ -48,46 +51,53 @@ export async function install(platform, ruby) {
4851
return [rubyPrefix, newPathEntries]
4952
}
5053

51-
function latestHostedRuby() {
54+
// Remove when Actions Windows image contains MSYS2 install
55+
async function symLinkToEmbeddedMSYS2() {
5256
const toolCacheVersions = tc.findAllVersions('Ruby')
5357
toolCacheVersions.sort()
5458
if (toolCacheVersions.length === 0) {
5559
throw new Error('Could not find MSYS2 in the toolcache')
5660
}
5761
const latestVersion = toolCacheVersions.slice(-1)[0]
58-
return tc.find('Ruby', latestVersion)
62+
const hostedRuby = tc.find('Ruby', latestVersion)
63+
await exec.exec(`cmd /c mklink /D ${msys2} ${hostedRuby}\\msys64`)
5964
}
6065

61-
async function setupMingw(hostedRuby, version) {
66+
async function setupMingw(version) {
6267
if (version.startsWith('2.2') || version.startsWith('2.3')) {
63-
core.exportVariable('SSL_CERT_FILE', `${hostedRuby}\\ssl\\cert.pem`)
68+
core.exportVariable('SSL_CERT_FILE', certFile)
6469
}
6570

66-
// Link to embedded MSYS2 in hostedRuby
67-
const msys2 = 'C:\\msys64'
71+
// Remove when Actions Windows image contains MSYS2 install
6872
if (!fs.existsSync(msys2)) {
69-
const hostedMSYS2 = `${hostedRuby}\\msys64`
70-
await exec.exec(`cmd /c mklink /D ${msys2} ${hostedMSYS2}`)
73+
await symLinkToEmbeddedMSYS2()
7174
}
7275

7376
return [`${msys2}\\mingw64\\bin`, `${msys2}\\usr\\bin`]
7477
}
7578

76-
async function setupMSWin(hostedRuby) {
79+
async function setupMSWin() {
7780
// All standard MSVC OpenSSL builds use C:\Program Files\Common Files\SSL
7881
const certsDir = 'C:\\Program Files\\Common Files\\SSL\\certs'
7982
if (!fs.existsSync(certsDir)) {
8083
fs.mkdirSync(certsDir)
8184
}
8285

83-
// Copy cert.pem from hosted Ruby
86+
// cert.pem location is hard-coded by OpenSSL msvc builds
8487
const cert = 'C:\\Program Files\\Common Files\\SSL\\cert.pem'
8588
if (!fs.existsSync(cert)) {
86-
const hostedCert = `${hostedRuby}\\ssl\\cert.pem`
87-
fs.copyFileSync(hostedCert, cert)
89+
fs.copyFileSync(certFile, cert)
90+
}
91+
92+
// Remove when Actions Windows image contains MSYS2 install
93+
if (!fs.existsSync(msys2)) {
94+
await symLinkToEmbeddedMSYS2()
8895
}
8996

90-
return addVCVARSEnv()
97+
let pathAry = addVCVARSEnv()
98+
// add MSYS2 paths for misc gnu utilities like bison and ragel
99+
pathAry.push(`${msys2}\\mingw64\\bin`, `${msys2}\\usr\\bin`)
100+
return pathAry
91101
}
92102

93103
/* Sets MSVC environment for use in Actions

0 commit comments

Comments
 (0)