-
-
Notifications
You must be signed in to change notification settings - Fork 365
Update for Actions Windows MSYS2 install #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,12 @@ const exec = require('@actions/exec') | |
| const tc = require('@actions/tool-cache') | ||
| const rubyInstallerVersions = require('./windows-versions').versions | ||
|
|
||
| // needed for 2.2, 2.3, and mswin, cert file used by Git for Windows | ||
| const certFile = 'C:\\Program Files\\Git\\mingw64\\ssl\\cert.pem' | ||
|
|
||
| // standard MSYS2 location, found by 'devkit' | ||
| const msys2 = 'C:\\msys64' | ||
|
|
||
| export function getAvailableVersions(platform, engine) { | ||
| if (engine === 'ruby') { | ||
| return Object.keys(rubyInstallerVersions) | ||
|
|
@@ -33,11 +39,8 @@ export async function install(platform, ruby) { | |
| await exec.exec('7z', ['x', downloadPath, `-xr!${base}\\share\\doc`, `-o${drive}:\\`], { silent: true }) | ||
| const rubyPrefix = `${drive}:\\${base}` | ||
|
|
||
| // we use certs and embedded MSYS2 from hostedRuby | ||
| const hostedRuby = latestHostedRuby() | ||
|
|
||
| let toolchainPaths = (version === 'mswin') ? | ||
| await setupMSWin(hostedRuby) : await setupMingw(hostedRuby, version) | ||
| await setupMSWin() : await setupMingw(version) | ||
| const newPathEntries = [`${rubyPrefix}\\bin`, ...toolchainPaths] | ||
|
|
||
| // Install Bundler if needed | ||
|
|
@@ -48,46 +51,53 @@ export async function install(platform, ruby) { | |
| return [rubyPrefix, newPathEntries] | ||
| } | ||
|
|
||
| function latestHostedRuby() { | ||
| // Remove when Actions Windows image contains MSYS2 install | ||
| async function symLinkToEmbeddedMSYS2() { | ||
| const toolCacheVersions = tc.findAllVersions('Ruby') | ||
| toolCacheVersions.sort() | ||
| if (toolCacheVersions.length === 0) { | ||
| throw new Error('Could not find MSYS2 in the toolcache') | ||
| } | ||
| const latestVersion = toolCacheVersions.slice(-1)[0] | ||
| return tc.find('Ruby', latestVersion) | ||
| const hostedRuby = tc.find('Ruby', latestVersion) | ||
| await exec.exec(`cmd /c mklink /D ${msys2} ${hostedRuby}\\msys64`) | ||
| } | ||
|
|
||
| async function setupMingw(hostedRuby, version) { | ||
| async function setupMingw(version) { | ||
| if (version.startsWith('2.2') || version.startsWith('2.3')) { | ||
| core.exportVariable('SSL_CERT_FILE', `${hostedRuby}\\ssl\\cert.pem`) | ||
| core.exportVariable('SSL_CERT_FILE', certFile) | ||
| } | ||
|
|
||
| // Link to embedded MSYS2 in hostedRuby | ||
| const msys2 = 'C:\\msys64' | ||
| // Remove when Actions Windows image contains MSYS2 install | ||
| if (!fs.existsSync(msys2)) { | ||
| const hostedMSYS2 = `${hostedRuby}\\msys64` | ||
| await exec.exec(`cmd /c mklink /D ${msys2} ${hostedMSYS2}`) | ||
| await symLinkToEmbeddedMSYS2() | ||
| } | ||
|
|
||
| return [`${msys2}\\mingw64\\bin`, `${msys2}\\usr\\bin`] | ||
| } | ||
|
|
||
| async function setupMSWin(hostedRuby) { | ||
| async function setupMSWin() { | ||
| // All standard MSVC OpenSSL builds use C:\Program Files\Common Files\SSL | ||
| const certsDir = 'C:\\Program Files\\Common Files\\SSL\\certs' | ||
| if (!fs.existsSync(certsDir)) { | ||
| fs.mkdirSync(certsDir) | ||
| } | ||
|
|
||
| // Copy cert.pem from hosted Ruby | ||
| // cert.pem location is hard-coded by OpenSSL msvc builds | ||
| const cert = 'C:\\Program Files\\Common Files\\SSL\\cert.pem' | ||
| if (!fs.existsSync(cert)) { | ||
| const hostedCert = `${hostedRuby}\\ssl\\cert.pem` | ||
| fs.copyFileSync(hostedCert, cert) | ||
| fs.copyFileSync(certFile, cert) | ||
| } | ||
|
|
||
| // Remove when Actions Windows image contains MSYS2 install | ||
| if (!fs.existsSync(msys2)) { | ||
| await symLinkToEmbeddedMSYS2() | ||
| } | ||
|
|
||
| return addVCVARSEnv() | ||
| let pathAry = addVCVARSEnv() | ||
| // add MSYS2 paths for misc gnu utilities like bison and ragel | ||
| pathAry.push(`${msys2}\\mingw64\\bin`, `${msys2}\\usr\\bin`) | ||
| return pathAry | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you use an array literal with
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I noticed that push allows multiple arguments, so I changed to that? VCVARSEnv is defined by the bat file, so we have to 'add' two arrays, but this is just adding two items...
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I meant ae39a8d actually |
||
| } | ||
|
|
||
| /* Sets MSVC environment for use in Actions | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope this location will remain available, it sounds likely enough for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Git for Windows has always been there. It's the git that's used by all the actions and any Windows devs using git. There are also GitHub/MSFT staff involved with it. IOW, its location is probably more locked down than the locations of the toolcache Rubies...