- PowerShell 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| .forgejo/workflows | ||
| action.yml | ||
| README.md | ||
| setup.ps1 | ||
wtc-action
Sets up the WTC environment on a Windows runner, as
msys2/setup-msys2 does for MSYS2: the
shell (bash and the basic tools), a winlibs GCC toolchain, and whatever
packages you list - then wtc (bash) and wtc-pwsh (PowerShell) shells for
the steps after it. Made for Forgejo Actions; it works on GitHub Actions too.
jobs:
build:
runs-on: windows-11
defaults:
run:
shell: wtc {0}
steps:
- uses: actions/checkout@v4
- uses: https://code.wisesourcery.com/actions/wtc-action@dev
with:
msystem: ucrt64 ucrt32
install: zlib curl wxwidgets usr/meson usr/openssh
- run: | # bash in ucrt64
cmake -B build
cmake --build build
- shell: wtc-ucrt32 {0} # bash in ucrt32
run: meson setup build32 && ninja -C build32
- shell: wtc-pwsh {0} # pwsh, ucrt64\bin and usr\bin first
run: |
cmake -B build-ps
cmake --build build-ps
The runner is a forgejo-runner on Windows 11 in host mode, labelled
windows-11 (e.g. --labels windows-11:host), with PowerShell 7 (pwsh),
Node.js 20+ and git on PATH - the same runner the toolchain repository's
build uses. On GitHub, reference it by that URL or a GitHub copy; GitHub has
no hosted windows-11 image, so there runs-on names a self-hosted runner
with that label (or use windows-2025).
The packages come from the latest release of repository - the toolchain
repository, which publishes them; by default
wiseglobalsolutions/toolchain.
The action asks that server's API for it
(/api/v1/repos/<owner>/<name>/releases/latest) and installs from
<server>/<owner>/<name>/releases/download/<tag> (on GitHub,
releases/latest/download). An owner/name without a server means the server
the workflow runs on. The lookup goes without credentials first, then with
token - only ever to the workflow's own server - for a private repository;
wtc-setup.exe downloads without credentials, so the packages' repository
must be public - or set source to a folder on the runner.
Inputs
| Input | Default | |
|---|---|---|
msystem |
ucrt64 |
The environments to set up: ucrt64 (64-bit gcc), ucrt32 (32-bit gcc), both (ucrt64 ucrt32), or msys (usr/ only, no compiler). The first is the one wtc and wtc-pwsh start in. |
toolchain |
toolchain |
The toolchain package installed for each msystem (<msystem>/<toolchain>), or none to install none and bring your own through install. A library that needs the toolchain still pulls it in. |
install |
Packages, separated by spaces or newlines; their dependencies come too. A bare name is each msystem's package if it has one, else the usr one (zlib → ucrt64/zlib and ucrt32/zlib, meson → usr/meson); env/name picks exactly (ucrt32/zlib, usr/cmake). usr/base is always installed. |
|
repository |
https://code.wisesourcery.com/wiseglobalsolutions/toolchain |
The repository whose latest release holds the packages: its URL, or owner/name on the workflow's server. |
source |
that repository's latest release | A URL or folder holding wtc-index.txt, the packages and wtc-setup.exe; overrides repository. |
token |
github.token |
Used for the latest-release lookup when it fails without (private repositories); only sent to the workflow's own server. |
location |
cache |
The root to install into: cache - <tool cache>\wtc\<id>, one folder per package set (<id> hashes the package list) under the runner's tool cache (RUNNER_TOOL_CACHE, else the temp folder); temp - the same under the runner's temp folder; or a path. |
path-type |
minimal |
MSYS2_PATH_TYPE: how much of the Windows PATH the bash shell keeps after /usr/bin - minimal, inherit or strict. |
link |
shared |
WTC_LINK: which kind of library CMake links in the shells - shared or static. A step's own WTC_LINK wins. |
path |
false |
Also put the first msystem's bin and usr\bin first on PATH, and its CMake and pkg-config variables in the environment, for every later step in any shell (pwsh, cmd, ...). |
cache |
true |
Keep the downloaded packages between runs (actions/cache), keyed on the index and the package list. Skipped when the root holds the packages already. |
Outputs
| Output | |
|---|---|
root |
The root the environment is in (a Windows path). |
shell |
The wtc.cmd wrapper, for shell: ${{ steps.<id>.outputs.shell }} {0} when you would rather not rely on PATH. |
pwsh-shell |
The wtc-pwsh.cmd wrapper, likewise. |
installed |
true when the root held these packages already and nothing was installed. |
Shells
| Shell | |
|---|---|
wtc {0} |
bash --login -eo pipefail in the first msystem, in the step's working directory (CHERE_INVOKING=1): a failing command fails the step. |
wtc-ucrt64 {0}, wtc-ucrt32 {0} |
The same in that msystem. |
wtc-pwsh {0} |
pwsh with <root>\<msystem>\bin and <root>\usr\bin first on PATH and WTC_*, CC/CXX, PKG_CONFIG_PATH, CMAKE_TOOLCHAIN_FILE and CMAKE_GENERATOR set, for the first msystem. It runs the script as shell: pwsh does: $ErrorActionPreference = 'Stop', and the step fails on the last native command's exit code. |
wtc-pwsh-ucrt64 {0}, wtc-pwsh-ucrt32 {0} |
The same for that msystem. |
There is one of each per msystem set up (msys has no compiler variables,
only usr\bin). With path: true, plain shell: pwsh or cmd steps get
the first msystem's PATH and variables too, without a wrapper.
How it works
- Reads the source's
wtc-index.txt, resolves the package list and picks the root. If the root's stamp (var\lib\wtc-action\installed.txt) names the same index and packages, nothing is downloaded or installed. - Restores the package cache (
<root>\var\cache\wtc). - Downloads
wtc-setup.exeto<runner temp>\wtc-download- checked against the release'sSHA256SUMS.txtwhen it has one - and runs it unattended (-q -u -R <root> -s <source> -P <packages>): every package is checked against the index's SHA-256 before it is unpacked, and a root reused from an earlier release is upgraded to this one. - Writes the shells to
<root>\var\lib\wtc-actionand adds that folder toPATH.
Inside the bash shells it is the same as ucrt64.exe gives on a workstation:
/ucrt64/bin first on PATH, CMAKE_TOOLCHAIN_FILE, CMAKE_GENERATOR=Ninja
and PKG_CONFIG_PATH set, so cmake -B build and meson setup build need no
flags.
With location: cache each package set gets its own root, and a self-hosted
runner keeps its tool cache between jobs, so a custom toolchain - another
toolchain, extra packages, one msystem or both - is installed once and
reused by every later job asking for the same set; a new release upgrades it
in place. Use location: temp for a root that goes with the runner's temp
folder, or a path to choose it yourself (then a different package set in the
same path is added to that root). Two jobs installing the same new package set
on one runner at the same time share a root; give them different locations
if that can happen. Keep the root under about 140 characters: gcc looks for
its headers through <root>\ucrt64\lib\gcc\...\..\..\..\..\x86_64-w64-mingw32\include,
and past Windows' 260-character limit it finds no stdio.h.