Skip to content

Commit ef383ae

Browse files
committed
Updates for setup-ruby & Actions MSYS2 install
1 parent 4f6a230 commit ef383ae

File tree

6 files changed

+41
-52
lines changed

6 files changed

+41
-52
lines changed

apt.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ export const run = async () => {
1212
if (apt !== '') {
1313
if (apt.includes('_update_')) {
1414
execSync('sudo apt-get -qy update')
15-
apt = apt.replace(/_update_/gi, '').trim()
15+
apt = apt.replace(/\b_update_\b/gi, '').trim()
1616
}
1717

1818
if (apt.includes('_upgrade_')) {
1919
execSync('sudo apt-get -qy update')
2020
execSync('sudo apt-get -qy dist-upgrade')
21-
apt = apt.replace(/_upgrade_/gi, '').trim()
21+
apt = apt.replace(/\b_upgrade_\b/gi, '').trim()
2222
}
2323

2424
if (apt !== '') {

brew.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ export const run = async () => {
1212
if (brew !== '') {
1313
if (brew.includes('_update_')) {
1414
execSync('brew update')
15-
brew = brew.replace(/_update_/gi, '').trim()
15+
brew = brew.replace(/\b_update_\b/gi, '').trim()
1616
}
1717

1818
if (brew.includes('_upgrade_')) {
1919
execSync('brew update')
2020
execSync('brew upgrade')
21-
brew = brew.replace(/_upgrade_/gi, '').trim()
21+
brew = brew.replace(/\b_upgrade_\b/gi, '').trim()
2222
}
2323

2424
if (brew !== '') {

common.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,10 @@ export const execSync = (cmd) => {
6969
cp.execSync(cmd, {stdio: ['ignore', 'inherit', 'inherit']})
7070
}
7171

72+
export const execSyncQ = (cmd) => {
73+
console.log(`[command]${cmd}`)
74+
cp.execSync(cmd, {stdio: ['ignore', 'ignore', 'inherit']})
75+
console.log(' Done')
76+
}
77+
7278
export const getInput = (name) => core.getInput(name).replace(/[^a-z_ \d.-]+/gi, '').trim().toLowerCase()

dist/index.js

Lines changed: 21 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ const run = async () => {
7272
if (apt !== '') {
7373
if (apt.includes('_update_')) {
7474
execSync('sudo apt-get -qy update')
75-
apt = apt.replace(/_update_/gi, '').trim()
75+
apt = apt.replace(/\b_update_\b/gi, '').trim()
7676
}
7777

7878
if (apt.includes('_upgrade_')) {
7979
execSync('sudo apt-get -qy update')
8080
execSync('sudo apt-get -qy dist-upgrade')
81-
apt = apt.replace(/_upgrade_/gi, '').trim()
81+
apt = apt.replace(/\b_upgrade_\b/gi, '').trim()
8282
}
8383

8484
if (apt !== '') {
@@ -368,6 +368,7 @@ __webpack_require__.r(__webpack_exports__);
368368
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "download", function() { return download; });
369369
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ruby", function() { return ruby; });
370370
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "execSync", function() { return execSync; });
371+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "execSyncQ", function() { return execSyncQ; });
371372
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getInput", function() { return getInput; });
372373

373374

@@ -440,6 +441,12 @@ const execSync = (cmd) => {
440441
cp.execSync(cmd, {stdio: ['ignore', 'inherit', 'inherit']})
441442
}
442443

444+
const execSyncQ = (cmd) => {
445+
console.log(`[command]${cmd}`)
446+
cp.execSync(cmd, {stdio: ['ignore', 'ignore', 'inherit']})
447+
console.log(' Done')
448+
}
449+
443450
const getInput = (name) => core.getInput(name).replace(/[^a-z_ \d.-]+/gi, '').trim().toLowerCase()
444451

445452

@@ -455,22 +462,15 @@ __webpack_require__.r(__webpack_exports__);
455462

456463

457464
const fs = __webpack_require__(747)
458-
const path = __webpack_require__(622)
459465
const core = __webpack_require__(276)
460466

461-
const { download, execSync, getInput } = __webpack_require__(498)
467+
const { download, execSync, execSyncQ, getInput } = __webpack_require__(498)
462468

463-
// SSD drive, used for most downloads
469+
// SSD drive, used for most downloads and MSYS
464470
const drive = (process.env['GITHUB_WORKSPACE'] || 'C')[0]
465471

466-
const tar = 'C:\\msys64\\usr\\bin\\tar.exe'
467-
const msys2UsrBin = 'C:\\msys64\\usr\\bin'
468-
469-
// below are for setup of old Ruby DevKit
470-
const dirDK = `C:\\DevKit64`
471-
const dirDKTar = `/c/DevKit64/mingw/x86_64-w64-mingw32`
472-
473-
const dirDK7z = `C:\\DevKit64\\mingw\\x86_64-w64-mingw32`
472+
// location to extract old MSYS packages
473+
const dirDK7z = `${drive}:\\DevKit64\\mingw\\x86_64-w64-mingw32`
474474

475475
const dlPath = `${process.env.RUNNER_TEMP}\\srp`
476476
if (!fs.existsSync(dlPath)) {
@@ -486,6 +486,7 @@ let mingw = getInput('mingw')
486486
let msys2 = getInput('msys2')
487487

488488
let pre // set in setRuby, ' mingw-w64-x86_64-' or ' mingw-w64-i686-'
489+
// standard pacman args
489490
const args = '--noconfirm --noprogressbar --needed'
490491

491492
// Not used. Installs packages stored in GitHub release.
@@ -535,7 +536,7 @@ const openssl = async () => {
535536
await download(uri, fn)
536537
execSync(`pacman.exe -R --noconfirm --noprogressbar ${pre.trim()}openssl`)
537538
execSync(`pacman.exe -Udd --noconfirm --noprogressbar ${fn}`)
538-
mingw = mingw.replace(/openssl/gi, '').trim()
539+
mingw = mingw.replace(/\bopenssl\b/gi, '').trim()
539540
}
540541
}
541542

@@ -559,15 +560,15 @@ const installMSYS2 = async () => {
559560
const cmd = `7z x ${fn} -oC:\\`
560561
await download(`https://github.com/MSP-Greg/ruby-msys2-package-archive/releases/download/${RELEASE_ASSET}/msys64.7z`, fn)
561562
fs.rmdirSync('C:\\msys64', { recursive: true })
562-
execSync(cmd)
563+
execSyncQ(cmd)
563564
core.info('Installed MSYS2 for Ruby 2.4 and later')
564565
}
565566

566567
// install MinGW packages from mingw input
567568
const runMingw = async () => {
568569
if (mingw.includes('_upgrade_')) {
569570
await updateGCC()
570-
mingw = mingw.replace(/_upgrade_/g, '').trim()
571+
mingw = mingw.replace(/\b_upgrade_\b/g, '').trim()
571572
}
572573

573574
/* _msvc_ can be used when building mswin Rubies
@@ -600,18 +601,12 @@ const runMingw = async () => {
600601
}
601602
})
602603
if (toInstall.length !== 0) {
603-
// add to Path to make sure MSYS2 tar is in Path for extraction
604-
const curPath = process.env.Path
605-
process.env.Path = `${msys2UsrBin}${path.delimiter}${curPath}`
606604
for (const item of toInstall) {
607605
let fn = `${dlPath}\\${item.pkg}.tar.lzma`
608606
await download(item.uri, fn)
609-
//fn = fn.replace(/:/, '').replace(/\\/g, '/')
610-
//let cmd = `${tar} --lzma -C ${dirDKTar} -xf /${fn}`
611607
let cmd = `7z x -tlzma ${fn} -so | 7z x -aoa -si -ttar -o${dirDK7z}`
612-
execSync(cmd)
608+
execSyncQ(cmd)
613609
}
614-
process.env.Path = curPath
615610
}
616611
}
617612
}
@@ -1733,7 +1728,7 @@ const run = async () => {
17331728
if (!choco.includes('openssl')) { choco += ' openssl' }
17341729
}
17351730

1736-
if (mingw.includes('ragel')) {
1731+
if (mingw.includes('ragel') && !mswin.includes('ragel')) {
17371732
execSync('pacman.exe -S --noconfirm --noprogressbar --needed mingw-w64-x86_64-ragel')
17381733
}
17391734

@@ -1783,13 +1778,13 @@ const run = async () => {
17831778
if (brew !== '') {
17841779
if (brew.includes('_update_')) {
17851780
execSync('brew update')
1786-
brew = brew.replace(/_update_/gi, '').trim()
1781+
brew = brew.replace(/\b_update_\b/gi, '').trim()
17871782
}
17881783

17891784
if (brew.includes('_upgrade_')) {
17901785
execSync('brew update')
17911786
execSync('brew upgrade')
1792-
brew = brew.replace(/_upgrade_/gi, '').trim()
1787+
brew = brew.replace(/\b_upgrade_\b/gi, '').trim()
17931788
}
17941789

17951790
if (brew !== '') {

mingw.js

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
11
'use strict';
22

33
const fs = require('fs')
4-
const path = require('path')
54
const core = require('@actions/core')
65

7-
const { download, execSync, getInput } = require('./common')
6+
const { download, execSync, execSyncQ, getInput } = require('./common')
87

9-
// SSD drive, used for most downloads
8+
// SSD drive, used for most downloads and MSYS
109
const drive = (process.env['GITHUB_WORKSPACE'] || 'C')[0]
1110

12-
const tar = 'C:\\msys64\\usr\\bin\\tar.exe'
13-
const msys2UsrBin = 'C:\\msys64\\usr\\bin'
14-
15-
// below are for setup of old Ruby DevKit
16-
const dirDK = `C:\\DevKit64`
17-
const dirDKTar = `/c/DevKit64/mingw/x86_64-w64-mingw32`
18-
19-
const dirDK7z = `C:\\DevKit64\\mingw\\x86_64-w64-mingw32`
11+
// location to extract old MSYS packages
12+
const dirDK7z = `${drive}:\\DevKit64\\mingw\\x86_64-w64-mingw32`
2013

2114
const dlPath = `${process.env.RUNNER_TEMP}\\srp`
2215
if (!fs.existsSync(dlPath)) {
@@ -32,6 +25,7 @@ let mingw = getInput('mingw')
3225
let msys2 = getInput('msys2')
3326

3427
let pre // set in setRuby, ' mingw-w64-x86_64-' or ' mingw-w64-i686-'
28+
// standard pacman args
3529
const args = '--noconfirm --noprogressbar --needed'
3630

3731
// Not used. Installs packages stored in GitHub release.
@@ -81,7 +75,7 @@ const openssl = async () => {
8175
await download(uri, fn)
8276
execSync(`pacman.exe -R --noconfirm --noprogressbar ${pre.trim()}openssl`)
8377
execSync(`pacman.exe -Udd --noconfirm --noprogressbar ${fn}`)
84-
mingw = mingw.replace(/openssl/gi, '').trim()
78+
mingw = mingw.replace(/\bopenssl\b/gi, '').trim()
8579
}
8680
}
8781

@@ -105,15 +99,15 @@ const installMSYS2 = async () => {
10599
const cmd = `7z x ${fn} -oC:\\`
106100
await download(`https://github.com/MSP-Greg/ruby-msys2-package-archive/releases/download/${RELEASE_ASSET}/msys64.7z`, fn)
107101
fs.rmdirSync('C:\\msys64', { recursive: true })
108-
execSync(cmd)
102+
execSyncQ(cmd)
109103
core.info('Installed MSYS2 for Ruby 2.4 and later')
110104
}
111105

112106
// install MinGW packages from mingw input
113107
const runMingw = async () => {
114108
if (mingw.includes('_upgrade_')) {
115109
await updateGCC()
116-
mingw = mingw.replace(/_upgrade_/g, '').trim()
110+
mingw = mingw.replace(/\b_upgrade_\b/g, '').trim()
117111
}
118112

119113
/* _msvc_ can be used when building mswin Rubies
@@ -146,18 +140,12 @@ const runMingw = async () => {
146140
}
147141
})
148142
if (toInstall.length !== 0) {
149-
// add to Path to make sure MSYS2 tar is in Path for extraction
150-
const curPath = process.env.Path
151-
process.env.Path = `${msys2UsrBin}${path.delimiter}${curPath}`
152143
for (const item of toInstall) {
153144
let fn = `${dlPath}\\${item.pkg}.tar.lzma`
154145
await download(item.uri, fn)
155-
//fn = fn.replace(/:/, '').replace(/\\/g, '/')
156-
//let cmd = `${tar} --lzma -C ${dirDKTar} -xf /${fn}`
157146
let cmd = `7z x -tlzma ${fn} -so | 7z x -aoa -si -ttar -o${dirDK7z}`
158-
execSync(cmd)
147+
execSyncQ(cmd)
159148
}
160-
process.env.Path = curPath
161149
}
162150
}
163151
}

mswin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const run = async () => {
2424
if (!choco.includes('openssl')) { choco += ' openssl' }
2525
}
2626

27-
if (mingw.includes('ragel')) {
27+
if (mingw.includes('ragel') && !mswin.includes('ragel')) {
2828
execSync('pacman.exe -S --noconfirm --noprogressbar --needed mingw-w64-x86_64-ragel')
2929
}
3030

0 commit comments

Comments
 (0)