MSYS2 is available by default in windows-latest virtual environment for GitHub Actions. However, the default installation is updated every ~10 days, and it includes some pre-installed packages. As a result, startup time can be up to 10 min. Moreover, MSYS2/MINGW are neither added to the PATH nor available as a custom shell
option.
setup-msys2 is a JavaScript GitHub Action (GHA) to optionally setup an up-to-date and stable MSYS2 environment in a temporal location, using the GHA toolkit. Moreover, it provides a custom entrypoint.
If option release
is false
, the default installation is used. Otherwise (by default), the latest tarball available at repo.msys2.org/distrib/x86_64 is downloaded and extracted.
- uses: msys2/setup-msys2@v1
Then, for multi-line scripts:
- shell: msys2 {0}
run: |
uname -a
Or, for single line commands:
- run: msys2 uname -a
It is also possible to set msys2
as the default shell. For example:
defaults:
run:
shell: msys2 {0}
steps:
- uses: msys2/setup-msys2@v1
with:
update: true
install: base-devel git
#- run: git config --global core.autocrlf input
# shell: bash
- uses: actions/checkout@v2
- run: git describe --dirty
Note that setting autocrlf
is required in specific use cases only. See actions/checkout#250.
By default, MSYSTEM
is set to MINGW64
. However, an optional parameter named msystem
is supported, which expects MSYS
, MINGW64
or MING32
. For example:
- uses: msys2/setup-msys2@v1
with:
msystem: MSYS
Furthermore, the environment variable can be overridden. 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@v1
with:
msystem: MSYS
- shell: msys2 {0}
run: |
makepkg-mingw -sCLfc --noconfirm --noprogressbar
pacman --noconfirm -U mingw-w64-*-any.pkg.tar.xz
- run: |
set MSYSTEM=MINGW64
msys2 <command to test the package>
By default, MSYS2_PATH_TYPE
is set to strict
by msys2
. It is possible to override it either using an option or setting the environment variable explicitly:
- uses: msys2/setup-msys2@v1
with:
path-type: inherit
- run: msys2 <command>
- uses: msys2/setup-msys2@v1
- run: msys2 <command>
env:
MSYS2_PATH_TYPE: inherit
By default (true
), retrieve and extract base installation from upstream GitHub Releases. If set to false
, the installation available in the virtual environment is used:
- uses: msys2/setup-msys2@v1
with:
release: 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 try to update the runtime and packages cleanly:
- uses: msys2/setup-msys2@v1
with:
update: true
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
.
- uses: msys2/setup-msys2@v1
with:
update: true
install: 'git base-devel'
If set to true
, directory /var/cache/pacman/pkg
is restored/cached in order to speed up future updates:
- uses: msys2/setup-msys2@v1
with:
cache: true
If set to save
, the same directory is cached, but it is not restored. This can be used to force a save of a clean state.
- uses: msys2/setup-msys2@v1
with:
cache: save
The steps to publish a new release are the following:
# Remove/clean dir 'dist'
rm -rf dist
# Package the action with ncc
yarn pkg
# - Copy release artifacts to subdir dir
# - Create a new orphan branch in a new empty repo
# - Push the branch
./release.sh v1.x.x
# Fetch the new branch and checkout it
git fetch --all
git checkout -b tmp origin/v1.x.x
# Reset the 'rolling' tag to the just released branch
git tag -d v1
git tag v1
git push origin +v1
# Remove the temporal branch
git checkout master
git branch -D tmp
NOTE: although it feels unidiomatic having 'rolling' tags and/or storing release assets in specific branches, it is the recommended solution. Retrieving assets from GitHub Releases is not supported by GitHub Actions (yet). See actions/javascript-action: Create a release branch, actions/toolkit: docs/action-versioning.md and actions/toolkit#214.
NOTE: tag
tag-for-git-describe
is used for testinggit describe --dirty --tags
in CI. See actions/checkout#250.