• Stars
    star
    298
  • Rank 139,663 (Top 3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 5 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

GitHub Action to setup MSYS2

'Test' workflow Status 'Example PKGBUILD' workflow Status

Setup MSYS2

setup-msys2 is a GitHub Action (GHA) to setup an MSYS2 environment (i.e. MSYS, MINGW32, MINGW64, UCRT64, CLANG32, CLANG64 and/or CLANGARM64 shells)

It provides:

  • Easy installation and updates
  • Easy package installation including caching for faster re-runs
  • A shell helper for running your commands or your whole job in an MSYS2 environment

Usage

  - uses: msys2/setup-msys2@v2

Then, for scripts:

  - shell: msys2 {0}
    run: |
      uname -a

It is also possible to execute specific commands from cmd/powershell scripts/snippets. In order to do so, -c is required:

  - shell: powershell
    run: msys2 -c 'uname -a'
  - shell: cmd
    run: msys2 -c 'uname -a'

Default shell

In order to reduce verbosity, it is possible to set msys2 as the default shell. For example:

  defaults:
    run:
      shell: msys2 {0}
  steps:
  - uses: msys2/setup-msys2@v2
    with:
      update: true
      install: >-
        curl
        git
  - uses: actions/checkout@v3

Build matrix

It is common to test some package/tool on multiple environments, which typically requires installing different sets of packages through option install. GitHub Actions' strategy and matrix fields allow to do so, as explained in docs.github.com: Configuring a build matrix and docs.github.com: jobs.<job_id>.strategy.matrix. See, for instance:

  strategy:
    matrix:
      include:
        - { sys: mingw64, env: x86_64 }
        - { sys: mingw32, env: i686 }
        - { sys: ucrt64,  env: ucrt-x86_64 }
        - { sys: clang64, env: clang-x86_64 }
  steps:
    - uses: msys2/setup-msys2@v2
      with:
        msystem: ${{matrix.sys}}
        install: mingw-w64-${{matrix.env}}-openssl

Alternatively, option pacboy allows using a single matrix variable:

  strategy:
    matrix:
      sys:
        - mingw64
        - mingw32
        - ucrt64
        - clang64
  steps:
    - uses: msys2/setup-msys2@v2
      with:
        msystem: ${{matrix.sys}}
        pacboy: openssl:p

Furthermore, .github/workflows/PKGBUILD.yml is a Reusable Workflow to build and test a package in GitHub Actions using a PKGBUILD recipe. It can be used along with matrix (a Composite Action), as shown in .github/workflows/Tool.yml.

Note: By default, GitHub Actions terminates any running jobs if any job in matrix fails. This default behavior can be disabled by setting fail-fast: false in strategy section. See docs.github.com: jobs.<job_id>.strategy.fail-fast for more details.

Find similar patterns in the following workflows:

Find further details at #171 and #102.

Options

msystem

  • Type: string
  • Allowed values: MSYS | MINGW64 | MINGW32 | UCRT64 | CLANG32 | CLANG64 | CLANGARM64
  • Default: MINGW64

The default environment that is used in the msys2 command/shell provided by this action.

MSYS2 recommends UCRT64 nowadays as the default instead of MINGW64.

For example:

  - uses: msys2/setup-msys2@v2
    with:
      msystem: UCRT64

The environment can be later overridden using the MSYSTEM environment variable if needed. This is useful when multiple commands need to be executed in different contexts. For example, in order to build a PKGBUILD file and then test the installed artifact:

  - uses: msys2/setup-msys2@v2
    with:
      msystem: MSYS
  - shell: msys2 {0}
    run: |
      makepkg-mingw -sCLfc --noconfirm --noprogressbar
      pacman --noconfirm -U mingw-w64-*-any.pkg.tar.xz
  - run: |
      set MSYSTEM=UCRT64
      msys2 -c '<command to test the package>'

update

  • Type: boolean
  • Default: false

By default, the installation is not updated; hence package versions are those of the installation tarball. By setting option update to true, the action will update the package database and all already installed packages.

  - uses: msys2/setup-msys2@v2
    with:
      update: true

install

  • Type: string
  • Allowed values: a whitespace separated list of packages
  • Default: -

Installing additional packages after updating the system is supported through option install. The package or list of packages are installed through pacman --noconfirm -S --needed --overwrite *.

  - uses: msys2/setup-msys2@v2
    with:
      update: true
      install: >-
        git
        curl

pacboy

  • Type: string
  • Allowed values: s whitespace separated list of packages
  • Default: -

Installing additional packages with pacboy after updating the system is supported through option pacboy. The package or list of packages are installed through pacboy --noconfirm -S --needed.

  strategy:
    fail-fast: false
    matrix:
      sys: [ MINGW64, MINGW32, UCRT64, CLANG64 ]
  steps:
  - uses: msys2/setup-msys2@v2
    with:
      msystem: ${{matrix.sys}}
      install: >-
        git
        curl
      pacboy: >-
        openssl:p

platform-check-severity

  • Type: string
  • Allowed values: warn | fatal
  • Default: warn

By default (fatal), throw an error if the runner OS is not Windows. If set to warn, simply log a message and skip the rest:

  - uses: msys2/setup-msys2@v2
    with:
      platform-check-severity: warn

Advanced Options

These options are rarely needed and shouldn't be used unless there is a good reason.

path-type

  • Type: string
  • Allowed values: minimal | strict | inherit
  • Default: minimal

Defines which parts of the Windows $env:PATH environment variable leak into the MSYS2 environment. Allowed values:

  • strict: do not inherit anything from $env:PATH.
  • minimal (default): only inherit the default Windows paths from $env:PATH (so that cmd.exe and powershell.exe are available for example).
  • inherit: inherit everything; warning: this can lead to interference with other tools installed on the system.
  - uses: msys2/setup-msys2@v2
    with:
      path-type: minimal

This option corresponds to the MSYS2_PATH_TYPE setting in MSYS2; hence it can be overridden per step through env. See msys2/MSYS2-packages: filesystem/profile for further details about the configuration of each option.

cache

  • Type: boolean
  • Default: true

By default (true), caches various things between runs to make repeated runs faster.

  - uses: msys2/setup-msys2@v2
    with:
      cache: false

location

  • Type: string
  • Default: -

Specify an alternate location where to install MSYS2 to.

  - uses: msys2/setup-msys2@v2
    with:
      location: D:\

release

  • Type: boolean
  • Default: true

If true (the default) it makes a fresh install of the latest MSYS2 installer release. If false it will try to re-use the existing MSYS2 installation which is part of the official GitHub Actions Runner Images.

  - uses: msys2/setup-msys2@v2
    with:
      release: false

Known Problems

actions/checkout and line endings

In case you use the actions/checkout action in your workflow and haven't configured git attributes for line endings, then git might auto convert your text files in the git repo to Windows line endings, which might lead to problems with tools provided by MSYS2.

To work around this issue disable the auto conversion before running actions/checkout:

  steps:
  - run: git config --global core.autocrlf input
  - uses: actions/checkout@v3

More Repositories

1

msys2.github.io

The MSYS2 homepage
CSS
2,260
star
2

MINGW-packages

Package scripts for MinGW-w64 targets to build under MSYS2.
Shell
2,242
star
3

msys2

A software distro and building platform for Windows
1,817
star
4

MSYS2-packages

Package scripts for MSYS2.
Shell
1,283
star
5

msys2-installer

The one-click installer for MSYS2
Shell
553
star
6

msys2-runtime

Our friendly fork of Cygwin πŸ’– https://cygwin.org πŸ’– see the wiki for details
C
184
star
7

msys2-web

Online Repo Browser
Python
97
star
8

msys2-launcher

Helper for launching MSYS2 shells
C
67
star
9

msys2-autobuild

🏭🏭🏭🏭🏭🏭🏭🏭
Python
35
star
10

MSYS2-keyring

Master and packager keys for MSYS2 official Pacman repositories
Shell
24
star
11

msys2-pacman

A friendly fork of https://gitlab.archlinux.org/pacman/pacman
C
21
star
12

path_convert

MSYS2 new path convert procedure
C++
20
star
13

MINGW-packages-dev

Supplemental mingw recipes for package maintainers
Shell
9
star
14

msys2-docker

MSYS2 Docker Images
Dockerfile
9
star
15

msys2-devtools

Tools for MSYS2 package maintainers
Python
7
star
16

msys2-main-server

traefik + nginx + rsync + letsencrypt + mirrorbits
Python
7
star
17

pacdb

Pure-python module to parse and read pacman sync dbs
Python
6
star
18

MSYS2-packages-dev

Supplemental recipes for package maintainers
Shell
4
star
19

msys2-texlive

MSYS2 Tex Live source generator
Python
4
star
20

msys2-tests

MSYS2 Integration Tests
C++
4
star
21

CLANG-packages

Bootstrapping packages for clang/clangarm, see branches and releases. We should probably remove this repo.
3
star
22

adbwinapi

CMake
3
star
23

msys2-archive

2
star
24

finances

TODO
1
star