Task
Syntax Commands
Write Taskfile.yml files with tasks, commands, dependencies, variables, and conditions.
12 commands
Pro Tips
Use deps for task dependencies and preconditions for checks
Commands
Basic task
$ tasks:
build:
cmds:
- go build -o app .
Basic task definition.
Task with dependencies
$ tasks:
deploy:
deps: [build, test]
cmds:
- ./deploy.sh
Task with dependencies.
Task with preconditions
$ tasks:
deploy:
preconditions:
- test -f config.yaml
cmds:
- kubectl apply -f .
Task with preconditions.
Init taskfile
$ task --init
Create initial Taskfile.yml.
Internal task
$ tasks:
_compile:
internal: true
cmds:
- gcc -o out main.c
Hidden task not shown in list.
Task aliases
$ tasks:
generate:
aliases: [gen, g]
cmds:
- go generate ./...
Run task with shorter alias names.
Platform-specific
$ tasks:
setup:
platforms: [linux, darwin]
cmds:
- chmod +x ./run.sh
Run task only on specific OS.
Include taskfiles
$ includes:
docker: ./docker/Taskfile.yml
ci: ./ci/Taskfile.yml
Include tasks from other files.
Deferred cleanup
$ tasks:
build:
cmds:
- defer: rm -f tmp.log
- go build -o app . > tmp.log
Deferred command runs on exit.
Task description
$ tasks:
build:
desc: Build the application binary
cmds:
- go build -o app
Add description shown by task -l.
Task summary block
$ tasks:
deploy:
summary: |
Deploys the app to production.
Requires kubectl access.
cmds:
- kubectl apply -f k8s/
Longer summary shown by --summary.
Ignore errors
$ tasks:
clean:
cmds:
- cmd: rm -rf dist/
ignore_error: true
Continue even if command fails.