Skip to content

Commit 8cefd68

Browse files
committed
Update for Actions MSYS2 installation, mswin
1 parent 82061a3 commit 8cefd68

File tree

6 files changed

+83
-58
lines changed

6 files changed

+83
-58
lines changed

.github/workflows/ruby.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ jobs:
2222
with:
2323
ruby-version: ${{ matrix.ruby }}
2424
mingw: _upgrade_ openssl ragel
25+
mswin: bison mingw-w64-x86_64-ragel
26+
vcpkg: readline
2527

2628
- name: Info
2729
run: |

action.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,25 @@ inputs:
66
description: 'Ruby version'
77
default: ''
88
apt-get:
9-
description: 'Install Ubuntu packages'
9+
description: 'Ubuntu - install packages'
1010
default: ''
1111
brew:
12-
description: 'Install macOS packages'
12+
description: 'macOS - install packages'
1313
default: ''
1414
mingw:
15-
description: 'Install MSYS2 mingw64 packages'
15+
description: 'MinGW - install MSYS2 mingw64 packages'
1616
default: ''
1717
msys2:
18-
description: 'Install MSYS2 msys2 packages'
18+
description: 'MinGW - install MSYS2 msys2 packages'
19+
default: ''
20+
mswin:
21+
description: 'mswin - install MSYS2 packages (mingw64 packages need prefix)'
22+
default: ''
23+
choco:
24+
description: 'mswin - install Chocolatey packages'
1925
default: ''
2026
vcpkg:
21-
description: 'Install vcpkg packages'
27+
description: 'mswin - install vcpkg packages'
2228
default: ''
2329
runs:
2430
using: 'node12'

dist/index.js

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,8 @@ const { download, execSync, getInput } = __webpack_require__(498)
464464
* release contains all Ruby building dependencies,
465465
* used when MSYS2 has server issues
466466
*/
467-
const RELEASE_ASSET = 'msys2-2020-03-20'
467+
const RELEASE_ASSET = fs.lstatSync('C:\\msys64').isSymbolicLink() ?
468+
'msys2-2020-03-20' : null
468469

469470
// SSD drive, used for most downloads
470471
const drive = (process.env['GITHUB_WORKSPACE'] || 'C')[0]
@@ -473,7 +474,7 @@ const tar = 'C:\\msys64\\usr\\bin\\tar.exe'
473474

474475
// below are for setup of old Ruby DevKit
475476
const dirDK = `${drive}:\\DevKit64`
476-
const oldDKTar = `/${drive}/DevKit64/mingw/x86_64-w64-mingw32`
477+
const dirDKTar = `/${drive}/DevKit64/mingw/x86_64-w64-mingw32`
477478

478479
const dlPath = `${process.env.RUNNER_TEMP}\\srp`
479480
if (!fs.existsSync(dlPath)) {
@@ -535,6 +536,7 @@ const openssl = async () => {
535536
const uri = `https://dl.bintray.com/larskanis/rubyinstaller2-packages/${pre.trim()}openssl-1.0.2.t-1-any.pkg.tar.xz`
536537
const fn = `${dlPath}\\ri2.tar.xz`
537538
await download(uri, fn)
539+
execSync(`pacman.exe -R --noconfirm --noprogressbar ${pre.trim()}openssl`)
538540
execSync(`pacman.exe -Udd --noconfirm --noprogressbar ${fn}`)
539541
mingw = mingw.replace(/openssl/gi, '').trim()
540542
}
@@ -587,13 +589,11 @@ const installDevKit = async () => {
587589
const setPathDevKit = () => {
588590
let aryPath = process.env.PATH.split(path.delimiter)
589591
const rubyPath = aryPath.shift()
590-
// two msys2 paths
591-
aryPath.shift()
592-
aryPath.shift()
593-
aryPath.unshift(`${dirDK}\\mingw\\x86_64-w64-mingw32\\bin`)
594-
aryPath.unshift(`${dirDK}\\mingw\\bin`)
595-
aryPath.unshift(`${dirDK}\\bin`)
596-
aryPath.unshift(rubyPath)
592+
// remove two msys2 paths, add devkit paths
593+
aryPath.splice(0, 2,
594+
rubyPath, `${dirDK}\\mingw\\x86_64-w64-mingw32\\bin`,
595+
`${dirDK}\\mingw\\bin`, `${dirDK}\\bin`
596+
)
597597
core.exportVariable('Path', aryPath.join(path.delimiter))
598598
}
599599

@@ -637,7 +637,7 @@ const runMingw = async () => {
637637
let fn = `${dlPath}\\${item.pkg}.tar.lzma`
638638
await download(item.uri, fn)
639639
fn = fn.replace(/:/, '').replace(/\\/g, '/')
640-
let cmd = `${tar} --lzma -C ${oldDKTar} -xf /${fn}`
640+
let cmd = `${tar} --lzma -C ${dirDKTar} -xf /${fn}`
641641
execSync(cmd)
642642
}
643643
}
@@ -1627,13 +1627,11 @@ module.exports = require("fs");
16271627
else if ( platform === 'darwin') { runner = __webpack_require__(924 ) }
16281628
else if (platform === 'win32' ) {
16291629
const ruby = common.ruby()
1630-
1630+
16311631
if ( ruby.platform.includes('mingw') ) { runner = __webpack_require__(505) }
16321632
else if ( ruby.platform.includes('mswin') ) { runner = __webpack_require__(894) }
1633-
// pass Ruby props to runner
1634-
if (runner) { runner.setRuby(ruby) }
1635-
1636-
// choco, vcpkg, etc
1633+
1634+
if (runner) { runner.setRuby(ruby) } // pass Ruby info to runner
16371635
}
16381636

16391637
if (runner) { await runner.run() }
@@ -1733,7 +1731,6 @@ module.exports = __webpack_require__(525);
17331731
"use strict";
17341732
__webpack_require__.r(__webpack_exports__);
17351733
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setRuby", function() { return setRuby; });
1736-
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "openssl", function() { return openssl; });
17371734
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "run", function() { return run; });
17381735

17391736

@@ -1743,27 +1740,38 @@ const core = __webpack_require__(276)
17431740
const { execSync, getInput } = __webpack_require__(498)
17441741

17451742
let mingw = getInput('mingw')
1743+
let mswin = getInput('mswin')
1744+
let choco = getInput('choco')
17461745
let vcpkg = getInput('vcpkg')
17471746

17481747
let ruby // eslint-disable-line no-unused-vars
17491748

17501749
const setRuby = (_ruby) => { ruby = _ruby }
17511750

1752-
// installs 1.1.1d
1753-
const openssl = async () => {
1754-
execSync('C:\\ProgramData\\Chocolatey\\bin\\choco install --no-progress openssl')
1755-
fs.renameSync('C:\\Program Files\\OpenSSL-Win64', 'C:\\openssl-win')
1756-
core.exportVariable('SSL_DIR', '--with-openssl-dir=C:/openssl-win')
1757-
mingw = mingw.replace(/openssl/gi, '').trim()
1758-
}
1759-
17601751
const run = async () => {
17611752
try {
1762-
if (mingw.includes('openssl')) { openssl() }
1763-
1753+
if (mswin !== '') {
1754+
execSync(`pacman.exe -S --noconfirm --noprogressbar --needed ${mswin}`)
1755+
}
1756+
1757+
if (mingw.includes('openssl')) {
1758+
execSync(`choco install --no-progress openssl`)
1759+
fs.renameSync('C:\\Program Files\\OpenSSL-Win64', 'C:\\openssl-win')
1760+
core.exportVariable('SSL_DIR', '--with-openssl-dir=C:/openssl-win')
1761+
choco = choco.replace(/openssl/gi, '').trim()
1762+
}
1763+
1764+
if (choco !== '') {
1765+
execSync(`choco install --no-progress ${choco}`)
1766+
if (choco.includes('openssl')) {
1767+
fs.renameSync('C:\\Program Files\\OpenSSL-Win64', 'C:\\openssl-win')
1768+
core.exportVariable('SSL_DIR', '--with-openssl-dir=C:/openssl-win')
1769+
}
1770+
}
1771+
17641772
if (vcpkg !== '') {
17651773
execSync(`vcpkg --triplet x64-windows install ${vcpkg}`)
1766-
core.addPath(`${process.env.VCPKG_INSTALLATION_ROOT}\\installed\\x64-windows\\tools`)
1774+
core.exportVariable('OPT_DIR', `--with-opt-dir=${process.env.VCPKG_INSTALLATION_ROOT}/installed/x64-windows`)
17671775
}
17681776

17691777
} catch (error) {

index.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,11 @@
2525
else if ( platform === 'darwin') { runner = require('./brew' ) }
2626
else if (platform === 'win32' ) {
2727
const ruby = common.ruby()
28-
28+
2929
if ( ruby.platform.includes('mingw') ) { runner = require('./mingw') }
3030
else if ( ruby.platform.includes('mswin') ) { runner = require('./mswin') }
31-
// pass Ruby props to runner
32-
if (runner) { runner.setRuby(ruby) }
33-
34-
// choco, vcpkg, etc
31+
32+
if (runner) { runner.setRuby(ruby) } // pass Ruby info to runner
3533
}
3634

3735
if (runner) { await runner.run() }

mingw.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ const { download, execSync, getInput } = require('./common')
1010
* release contains all Ruby building dependencies,
1111
* used when MSYS2 has server issues
1212
*/
13-
const RELEASE_ASSET = 'msys2-2020-03-20'
13+
const RELEASE_ASSET = fs.lstatSync('C:\\msys64').isSymbolicLink() ?
14+
'msys2-2020-03-20' : null
1415

1516
// SSD drive, used for most downloads
1617
const drive = (process.env['GITHUB_WORKSPACE'] || 'C')[0]
@@ -19,7 +20,7 @@ const tar = 'C:\\msys64\\usr\\bin\\tar.exe'
1920

2021
// below are for setup of old Ruby DevKit
2122
const dirDK = `${drive}:\\DevKit64`
22-
const oldDKTar = `/${drive}/DevKit64/mingw/x86_64-w64-mingw32`
23+
const dirDKTar = `/${drive}/DevKit64/mingw/x86_64-w64-mingw32`
2324

2425
const dlPath = `${process.env.RUNNER_TEMP}\\srp`
2526
if (!fs.existsSync(dlPath)) {
@@ -81,6 +82,7 @@ const openssl = async () => {
8182
const uri = `https://dl.bintray.com/larskanis/rubyinstaller2-packages/${pre.trim()}openssl-1.0.2.t-1-any.pkg.tar.xz`
8283
const fn = `${dlPath}\\ri2.tar.xz`
8384
await download(uri, fn)
85+
execSync(`pacman.exe -R --noconfirm --noprogressbar ${pre.trim()}openssl`)
8486
execSync(`pacman.exe -Udd --noconfirm --noprogressbar ${fn}`)
8587
mingw = mingw.replace(/openssl/gi, '').trim()
8688
}
@@ -133,13 +135,11 @@ const installDevKit = async () => {
133135
const setPathDevKit = () => {
134136
let aryPath = process.env.PATH.split(path.delimiter)
135137
const rubyPath = aryPath.shift()
136-
// two msys2 paths
137-
aryPath.shift()
138-
aryPath.shift()
139-
aryPath.unshift(`${dirDK}\\mingw\\x86_64-w64-mingw32\\bin`)
140-
aryPath.unshift(`${dirDK}\\mingw\\bin`)
141-
aryPath.unshift(`${dirDK}\\bin`)
142-
aryPath.unshift(rubyPath)
138+
// remove two msys2 paths, add devkit paths
139+
aryPath.splice(0, 2,
140+
rubyPath, `${dirDK}\\mingw\\x86_64-w64-mingw32\\bin`,
141+
`${dirDK}\\mingw\\bin`, `${dirDK}\\bin`
142+
)
143143
core.exportVariable('Path', aryPath.join(path.delimiter))
144144
}
145145

@@ -183,7 +183,7 @@ const runMingw = async () => {
183183
let fn = `${dlPath}\\${item.pkg}.tar.lzma`
184184
await download(item.uri, fn)
185185
fn = fn.replace(/:/, '').replace(/\\/g, '/')
186-
let cmd = `${tar} --lzma -C ${oldDKTar} -xf /${fn}`
186+
let cmd = `${tar} --lzma -C ${dirDKTar} -xf /${fn}`
187187
execSync(cmd)
188188
}
189189
}

mswin.js

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,38 @@ const core = require('@actions/core')
66
const { execSync, getInput } = require('./common')
77

88
let mingw = getInput('mingw')
9+
let mswin = getInput('mswin')
10+
let choco = getInput('choco')
911
let vcpkg = getInput('vcpkg')
1012

1113
let ruby // eslint-disable-line no-unused-vars
1214

1315
export const setRuby = (_ruby) => { ruby = _ruby }
1416

15-
// installs 1.1.1d
16-
export const openssl = async () => {
17-
execSync('C:\\ProgramData\\Chocolatey\\bin\\choco install --no-progress openssl')
18-
fs.renameSync('C:\\Program Files\\OpenSSL-Win64', 'C:\\openssl-win')
19-
core.exportVariable('SSL_DIR', '--with-openssl-dir=C:/openssl-win')
20-
mingw = mingw.replace(/openssl/gi, '').trim()
21-
}
22-
2317
export const run = async () => {
2418
try {
25-
if (mingw.includes('openssl')) { openssl() }
26-
19+
if (mswin !== '') {
20+
execSync(`pacman.exe -S --noconfirm --noprogressbar --needed ${mswin}`)
21+
}
22+
23+
if (mingw.includes('openssl')) {
24+
execSync(`choco install --no-progress openssl`)
25+
fs.renameSync('C:\\Program Files\\OpenSSL-Win64', 'C:\\openssl-win')
26+
core.exportVariable('SSL_DIR', '--with-openssl-dir=C:/openssl-win')
27+
choco = choco.replace(/openssl/gi, '').trim()
28+
}
29+
30+
if (choco !== '') {
31+
execSync(`choco install --no-progress ${choco}`)
32+
if (choco.includes('openssl')) {
33+
fs.renameSync('C:\\Program Files\\OpenSSL-Win64', 'C:\\openssl-win')
34+
core.exportVariable('SSL_DIR', '--with-openssl-dir=C:/openssl-win')
35+
}
36+
}
37+
2738
if (vcpkg !== '') {
2839
execSync(`vcpkg --triplet x64-windows install ${vcpkg}`)
29-
core.addPath(`${process.env.VCPKG_INSTALLATION_ROOT}\\installed\\x64-windows\\tools`)
40+
core.exportVariable('OPT_DIR', `--with-opt-dir=${process.env.VCPKG_INSTALLATION_ROOT}/installed/x64-windows`)
3041
}
3142

3243
} catch (error) {

0 commit comments

Comments
 (0)