Skip to content

Commit 5cb94de

Browse files
committed
use default MSYS2 installation if update
1 parent 49d914b commit 5cb94de

File tree

2 files changed

+33
-18
lines changed

2 files changed

+33
-18
lines changed

README.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,29 @@
66
<a title="'action' workflow Status" href="https://github.com/eine/setup-msys2/actions"><img alt="'action' workflow Status" src="https://github.com/eine/setup-msys2/workflows/action/badge.svg"></a>
77
</p>
88

9-
**setup-msys2** is a JavaScript GitHub Action (GHA) to setup a full-featured [MSYS2](https://www.msys2.org/) environment, using the GHA [toolkit](https://github.com/actions/toolkit).
9+
[MSYS2](https://www.msys2.org/) is available by default in [windows-latest](https://github.com/actions/virtual-environments/blob/master/images/win/Windows2019-Readme.md#msys2) virtual environment for GitHub Actions. However, the default installation is updated and it includes some pre-installed packages. Moreover, it is neither added to the PATH nor available as a custom `shell` option.
1010

11-
The latest tarball available at [repo.msys2.org/distrib/x86_64](http://repo.msys2.org/distrib/x86_64/) is cached. Using the action extracts it and provides two entrypoints named `msys2` and `msys2do`.
11+
**setup-msys2** is a JavaScript GitHub Action (GHA) to optionally setup a stable [MSYS2](https://www.msys2.org/) environment in a temporal location, using the GHA [toolkit](https://github.com/actions/toolkit); and to provide two custom entrypoints.
12+
13+
If option `update` is `true`, the default installation is used, in order to reduce startup latency. Otherwise, the latest tarball available at [repo.msys2.org/distrib/x86_64](http://repo.msys2.org/distrib/x86_64/) is downloaded and extracted.
1214

1315
## Usage
1416

1517
```yaml
1618
- uses: eine/setup-msys2@v0
19+
```
20+
21+
Then, for multi-line scripts:
22+
23+
```yaml
1724
- shell: msys2 {0}
1825
run: |
1926
uname -a
2027
```
2128
29+
Or, for single line commands:
30+
2231
```yaml
23-
- uses: eine/setup-msys2@v0
2432
- run: msys2do uname -a
2533
```
2634

main.js

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,22 @@ async function run() {
2121

2222
await io.mkdirP(dest);
2323

24-
const distrib = await tc.downloadTool('https://github.com/msys2/msys2-installer/releases/download/2020-05-17/msys2-base-x86_64-20200517.tar.xz');
24+
const update = core.getInput('update') == 'true';
2525

26-
await exec.exec('bash', ['-c', `7z x ${distrib.replace(/\\/g, '/')} -so | 7z x -aoa -si -ttar`], {cwd: dest} );
26+
let drive = 'C:';
27+
28+
if (!update) {
29+
drive = '%~dp0';
30+
const distrib = await tc.downloadTool('https://github.com/msys2/msys2-installer/releases/download/2020-05-17/msys2-base-x86_64-20200517.tar.xz');
31+
await exec.exec('bash', ['-c', `7z x ${distrib.replace(/\\/g, '/')} -so | 7z x -aoa -si -ttar`], {cwd: dest} );
32+
}
2733

2834
let cmd = path.join(dest, 'msys2do.cmd');
2935
fs.writeFileSync(cmd, [
3036
`setlocal`,
3137
`@echo off`,
3238
`IF NOT DEFINED MSYS2_PATH_TYPE set MSYS2_PATH_TYPE=` + core.getInput('path-type'),
33-
`%~dp0\\msys64\\usr\\bin\\bash.exe --norc -ilceo pipefail "cd $OLDPWD && %*"`
39+
drive + `\\msys64\\usr\\bin\\bash.exe --norc -ilceo pipefail "cd $OLDPWD && %*"`
3440
].join('\r\n'));
3541

3642
fs.writeFileSync(path.join(dest, 'msys2.cmd'), [
@@ -54,18 +60,19 @@ async function run() {
5460
core.startGroup(str);
5561
}
5662

57-
core.startGroup('Starting MSYS2 for the first time...');
58-
if (core.getInput('update') == 'true') {
59-
changeGroup('Updating packages...');
60-
await pacman(['-Syuu']);
61-
changeGroup('Killing remaining tasks...');
62-
await exec.exec('taskkill', ['/F', '/FI', 'MODULES eq msys-2.0.dll']);
63-
changeGroup('Final system upgrade...');
64-
await pacman(['-Suu']);
65-
} else {
66-
await exec.exec('cmd', ['/D', '/S', '/C', cmd].concat(['uname', '-a']));
67-
}
68-
core.endGroup();
63+
if (update) {
64+
core.startGroup('Updating packages...');
65+
await pacman(['-Syuu']);
66+
changeGroup('Killing remaining tasks...');
67+
await exec.exec('taskkill', ['/F', '/FI', 'MODULES eq msys-2.0.dll']);
68+
changeGroup('Final system upgrade...');
69+
await pacman(['-Suu']);
70+
core.endGroup();
71+
} else {
72+
core.startGroup('Starting MSYS2 for the first time...');
73+
await exec.exec('cmd', ['/D', '/S', '/C', cmd].concat(['uname', '-a']));
74+
core.endGroup();
75+
}
6976

7077
let install = core.getInput('install');
7178
if (install != '' && install != 'false') {

0 commit comments

Comments
 (0)