Closed nikaro closed 1 week ago
Hey @nikaro,
We already have for:
so you can loop though variables. That would sove your use case.
Hello @andreynering,
You mean something like this?
build:all:
desc: Build for all targets
vars:
matrix:
- os: linux
arch: arm64
- os: linux
arch: amd64
- os: darwin
arch: arm64
- os: darwin
arch: darwin
- os: windows
arch: arm64
- os: windows
arch: amd64
cmds:
- for:
var: matrix
cmd: go build -o build/${APP}-{{.ITEM.os}}-{{.ITEM.arch}} .
This is a bit cleaner (as it avoids the | cut -d
hack), but still a proper matrix support would be better in terms of readability :-)
@andreynering I'm inclined to agree that there is a valid use-case here even if it is only to reduce a bit of repetition. Can I propose the following syntax:
build:all:
desc: Build for all targets
cmds:
- for:
matrix:
ARCH: [amd64, arm64]
OS: [linux, darwin, windows]
cmd: go build -o build/${APP}-{{.ITEM.OS}}-{{.ITEM.ARCH}} .
This way it is any extension to the existing for
functionality rather than another looping keyword. This should be relatively simple to plug into the existing code.
Edit: Also related: https://github.com/go-task/task/issues/675
Yeah, thinking in it as an extension to for:
makes more sense 👍
I totally agree. I would add this is implemented like that in Github action and it works well
Hello,
It would be nice to be able to do something like this:
Previous issue on the subject: https://github.com/go-task/task/issues/675
Current workaround: