diff --git a/CHANGELOG.md b/CHANGELOG.md index c5a97de5..dca0dc40 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ experiments (similar to `.env`) (#1982 by @vmaerten). - Added new [Getting Started docs](https://taskfile.dev/getting-started) (#2086 by @pd93). +- Allow `matrix` to use references to other variables (#2065, #2069 by @pd93). #### Package API diff --git a/website/docs/usage.mdx b/website/docs/usage.mdx index 4c48f5d7..ad351ab1 100644 --- a/website/docs/usage.mdx +++ b/website/docs/usage.mdx @@ -1412,6 +1412,27 @@ darwin/amd64 darwin/arm64 ``` +You can also use references to other variables as long as they are also lists: + +```yaml +version: "3" + +vars: + OS_VAR: ["windows", "linux", "darwin"] + ARCH_VAR: ["amd64", "arm64"] + +tasks: + default: + cmds: + - for: + matrix: + OS: + ref: .OS_VAR + ARCH: + ref: .ARCH_VAR + cmd: echo "{{.ITEM.OS}}/{{.ITEM.ARCH}}" +``` + ### Looping over your task's sources You are also able to loop over the sources of your task: