Skip to content

Commit d2a032e

Browse files
committed
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 d2a032e

File tree

2 files changed

+40
-30
lines changed

2 files changed

+40
-30
lines changed

dist/index.js

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

windows.js

Lines changed: 20 additions & 15 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,6 +51,7 @@ export async function install(platform, ruby) {
4851
return [rubyPrefix, newPathEntries]
4952
}
5053

54+
// Remove when Actions Windows image contains MSYS2 install
5155
function latestHostedRuby() {
5256
const toolCacheVersions = tc.findAllVersions('Ruby')
5357
toolCacheVersions.sort()
@@ -58,36 +62,37 @@ function latestHostedRuby() {
5862
return tc.find('Ruby', latestVersion)
5963
}
6064

61-
async function setupMingw(hostedRuby, version) {
65+
async function setupMingw(version) {
6266
if (version.startsWith('2.2') || version.startsWith('2.3')) {
63-
core.exportVariable('SSL_CERT_FILE', `${hostedRuby}\\ssl\\cert.pem`)
67+
core.exportVariable('SSL_CERT_FILE', certFile)
6468
}
6569

66-
// Link to embedded MSYS2 in hostedRuby
67-
const msys2 = 'C:\\msys64'
70+
// Remove when Actions Windows image contains MSYS2 install
6871
if (!fs.existsSync(msys2)) {
69-
const hostedMSYS2 = `${hostedRuby}\\msys64`
72+
const hostedMSYS2 = `${latestHostedRuby()}\\msys64`
7073
await exec.exec(`cmd /c mklink /D ${msys2} ${hostedMSYS2}`)
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)
8890
}
89-
90-
return addVCVARSEnv()
91+
let pathAry = addVCVARSEnv()
92+
// add MSYS2 paths for misc gnu utilities like bison and ragel
93+
pathAry.push(`${msys2}\\mingw64\\bin`)
94+
pathAry.push(`${msys2}\\usr\\bin`)
95+
return pathAry
9196
}
9297

9398
/* Sets MSVC environment for use in Actions

0 commit comments

Comments
 (0)