2022-05-29 19:15:01 +02:00
|
|
|
---
|
|
|
|
slug: /taskfile-versions/
|
2023-09-02 22:48:05 +02:00
|
|
|
sidebar_position: 5
|
2022-05-29 19:15:01 +02:00
|
|
|
---
|
|
|
|
|
2018-09-22 23:44:24 +02:00
|
|
|
# Taskfile Versions
|
2018-03-08 03:54:37 +02:00
|
|
|
|
|
|
|
The Taskfile syntax and features changed with time. This document explains what
|
|
|
|
changed on each version and how to upgrade your Taskfile.
|
|
|
|
|
2018-09-22 23:44:24 +02:00
|
|
|
## What the Taskfile version mean
|
2018-03-08 03:54:37 +02:00
|
|
|
|
|
|
|
The Taskfile version follows the Task version. E.g. the change to Taskfile
|
|
|
|
version `2` means that Task `v2.0.0` should be release to support it.
|
|
|
|
|
|
|
|
The `version:` key on Taskfile accepts a semver string, so either `2`, `2.0` or
|
2020-07-07 08:58:12 +02:00
|
|
|
`2.0.0` is accepted. If you choose to use `2.0` Task will not enable future
|
|
|
|
`2.1` features, but if you choose to use `2`, then any `2.x.x` features will be
|
2018-03-08 03:54:37 +02:00
|
|
|
available, but not `3.0.0+`.
|
|
|
|
|
2023-05-31 17:34:46 +02:00
|
|
|
## Version 3 ![latest](https://img.shields.io/badge/latest-brightgreen)
|
2018-03-08 03:54:37 +02:00
|
|
|
|
2023-05-31 17:34:46 +02:00
|
|
|
These are some major changes done on `v3`:
|
2019-08-19 20:59:02 +02:00
|
|
|
|
2023-05-31 17:34:46 +02:00
|
|
|
- Task's output will now be colored
|
|
|
|
- Added support for `.env` like files
|
|
|
|
- Added `label:` setting to task so one can override how the task name appear in
|
|
|
|
the logs
|
|
|
|
- A global `method:` was added to allow setting the default method, and Task's
|
|
|
|
default changed to `checksum`
|
|
|
|
- Two magic variables were added when using `status:`: `CHECKSUM` and
|
2023-09-14 02:26:48 +02:00
|
|
|
`TIMESTAMP` which contains, respectively, the XXH3 checksum and greatest
|
2023-05-31 17:34:46 +02:00
|
|
|
modification timestamp of the files listed on `sources:`
|
|
|
|
- Also, the `TASK` variable is always available with the current task name
|
|
|
|
- CLI variables are always treated as global variables
|
|
|
|
- Added `dir:` option to `includes` to allow choosing on which directory an
|
|
|
|
included Taskfile will run:
|
2018-03-08 03:54:37 +02:00
|
|
|
|
2018-09-22 23:44:24 +02:00
|
|
|
```yaml
|
2023-05-31 17:34:46 +02:00
|
|
|
includes:
|
|
|
|
docs:
|
|
|
|
taskfile: ./docs
|
|
|
|
dir: ./docs
|
2018-03-08 03:54:37 +02:00
|
|
|
```
|
|
|
|
|
2023-05-31 17:34:46 +02:00
|
|
|
- Implemented short task syntax. All below syntaxes are equivalent:
|
2018-03-08 03:54:37 +02:00
|
|
|
|
2023-05-31 17:34:46 +02:00
|
|
|
```yaml
|
|
|
|
version: '3'
|
2018-03-08 03:54:37 +02:00
|
|
|
|
2023-05-31 17:34:46 +02:00
|
|
|
tasks:
|
|
|
|
print:
|
|
|
|
cmds:
|
|
|
|
- echo "Hello, World!"
|
|
|
|
```
|
2018-03-08 03:54:37 +02:00
|
|
|
|
2023-05-31 17:34:46 +02:00
|
|
|
```yaml
|
|
|
|
version: '3'
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
print:
|
|
|
|
- echo "Hello, World!"
|
|
|
|
```
|
2018-03-08 03:54:37 +02:00
|
|
|
|
2018-09-22 23:44:24 +02:00
|
|
|
```yaml
|
2023-05-31 17:34:46 +02:00
|
|
|
version: '3'
|
2018-03-08 03:54:37 +02:00
|
|
|
|
|
|
|
tasks:
|
2023-05-31 17:34:46 +02:00
|
|
|
print: echo "Hello, World!"
|
2018-03-08 03:54:37 +02:00
|
|
|
```
|
|
|
|
|
2023-05-31 17:34:46 +02:00
|
|
|
- There was a major refactor on how variables are handled. They're now easier to
|
|
|
|
understand. The `expansions:` setting was removed as it became unnecessary.
|
|
|
|
This is the order in which Task will process variables, each level can see the
|
|
|
|
variables set by the previous one and override those.
|
|
|
|
- Environment variables
|
|
|
|
- Global + CLI variables
|
|
|
|
- Call variables
|
|
|
|
- Task variables
|
|
|
|
|
|
|
|
## Version 2.6
|
|
|
|
|
|
|
|
:::caution
|
|
|
|
|
2023-12-29 22:26:02 +02:00
|
|
|
v2 schemas are [no longer supported by the latest version of
|
|
|
|
Task][deprecate-version-2-schema].
|
2023-05-31 17:34:46 +02:00
|
|
|
|
|
|
|
:::
|
|
|
|
|
|
|
|
Version 2.6 comes with `preconditions` stanza in tasks.
|
2018-03-08 03:54:37 +02:00
|
|
|
|
2018-09-22 23:44:24 +02:00
|
|
|
```yaml
|
2018-03-08 03:54:37 +02:00
|
|
|
version: '2'
|
|
|
|
|
|
|
|
tasks:
|
2023-05-31 17:34:46 +02:00
|
|
|
upload_environment:
|
|
|
|
preconditions:
|
|
|
|
- test -f .env
|
2018-03-08 03:54:37 +02:00
|
|
|
cmds:
|
2023-05-31 17:34:46 +02:00
|
|
|
- aws s3 cp .env s3://myenvironment
|
2018-03-08 03:54:37 +02:00
|
|
|
```
|
|
|
|
|
2023-05-31 17:34:46 +02:00
|
|
|
Please check the [documentation][includes]
|
2018-03-08 03:54:37 +02:00
|
|
|
|
2023-05-31 17:34:46 +02:00
|
|
|
## Version 2.2
|
2018-03-08 03:54:37 +02:00
|
|
|
|
2023-05-31 17:34:46 +02:00
|
|
|
:::caution
|
2018-03-08 03:54:37 +02:00
|
|
|
|
2023-12-29 22:26:02 +02:00
|
|
|
v2 schemas are [no longer supported by the latest version of
|
|
|
|
Task][deprecate-version-2-schema].
|
2018-03-08 03:54:37 +02:00
|
|
|
|
2023-05-31 17:34:46 +02:00
|
|
|
:::
|
2018-03-08 03:54:37 +02:00
|
|
|
|
2023-05-31 17:34:46 +02:00
|
|
|
Version 2.2 comes with a global `includes` options to include other Taskfiles:
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
version: '2'
|
|
|
|
|
|
|
|
includes:
|
|
|
|
docs: ./documentation # will look for ./documentation/Taskfile.yml
|
|
|
|
docker: ./DockerTasks.yml
|
2018-03-08 03:54:37 +02:00
|
|
|
```
|
2018-08-19 20:47:21 +02:00
|
|
|
|
|
|
|
## Version 2.1
|
|
|
|
|
2023-05-31 17:34:46 +02:00
|
|
|
:::caution
|
|
|
|
|
2023-12-29 22:26:02 +02:00
|
|
|
v2 schemas are [no longer supported by the latest version of
|
|
|
|
Task][deprecate-version-2-schema].
|
2023-05-31 17:34:46 +02:00
|
|
|
|
|
|
|
:::
|
|
|
|
|
2023-04-15 21:13:29 +02:00
|
|
|
Version 2.1 includes a global `output` option, to allow having more control over
|
|
|
|
how commands output are printed to the console (see [documentation][output] for
|
|
|
|
more info):
|
2018-08-19 20:47:21 +02:00
|
|
|
|
2018-09-22 23:44:24 +02:00
|
|
|
```yaml
|
2018-08-19 20:47:21 +02:00
|
|
|
version: '2'
|
|
|
|
|
|
|
|
output: prefixed
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
server:
|
|
|
|
cmds:
|
|
|
|
- go run main.go
|
|
|
|
prefix: server
|
|
|
|
```
|
|
|
|
|
2020-07-07 08:58:12 +02:00
|
|
|
From this version it's also possible to ignore errors of a command or task
|
2018-09-22 23:44:24 +02:00
|
|
|
(check documentation [here][ignore_errors]):
|
2018-08-19 20:47:21 +02:00
|
|
|
|
2018-09-22 23:44:24 +02:00
|
|
|
```yaml
|
2018-08-19 20:47:21 +02:00
|
|
|
version: '2'
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
example-1:
|
|
|
|
cmds:
|
|
|
|
- cmd: exit 1
|
|
|
|
ignore_error: true
|
|
|
|
- echo "This will be print"
|
|
|
|
|
|
|
|
example-2:
|
|
|
|
cmds:
|
|
|
|
- exit 1
|
|
|
|
- echo "This will be print"
|
|
|
|
ignore_error: true
|
|
|
|
```
|
|
|
|
|
2023-05-31 17:34:46 +02:00
|
|
|
## Version 2.0
|
2018-10-13 23:25:40 +02:00
|
|
|
|
2023-05-31 17:34:46 +02:00
|
|
|
:::caution
|
|
|
|
|
2023-12-29 22:26:02 +02:00
|
|
|
v2 schemas are [no longer supported by the latest version of
|
|
|
|
Task][deprecate-version-2-schema].
|
2023-05-31 17:34:46 +02:00
|
|
|
|
|
|
|
:::
|
|
|
|
|
|
|
|
At version 2, we introduced the `version:` key, to allow us to evolve Task with
|
|
|
|
new features without breaking existing Taskfiles. The new syntax is as follows:
|
2018-10-13 23:25:40 +02:00
|
|
|
|
|
|
|
```yaml
|
|
|
|
version: '2'
|
|
|
|
|
2023-05-31 17:34:46 +02:00
|
|
|
tasks:
|
|
|
|
echo:
|
|
|
|
cmds:
|
|
|
|
- echo "Hello, World!"
|
2018-10-13 23:25:40 +02:00
|
|
|
```
|
|
|
|
|
2023-05-31 17:34:46 +02:00
|
|
|
Version 2 allows you to write global variables directly in the Taskfile, if you
|
|
|
|
don't want to create a `Taskvars.yml`:
|
2019-05-17 22:13:47 +02:00
|
|
|
|
|
|
|
```yaml
|
|
|
|
version: '2'
|
|
|
|
|
2023-05-31 17:34:46 +02:00
|
|
|
vars:
|
|
|
|
GREETING: Hello, World!
|
|
|
|
|
2019-05-17 22:13:47 +02:00
|
|
|
tasks:
|
2023-05-31 17:34:46 +02:00
|
|
|
greet:
|
2019-05-17 22:13:47 +02:00
|
|
|
cmds:
|
2023-05-31 17:34:46 +02:00
|
|
|
- echo "{{.GREETING}}"
|
2019-05-17 22:13:47 +02:00
|
|
|
```
|
|
|
|
|
2023-05-31 17:34:46 +02:00
|
|
|
The variable priority order changed to the following:
|
2020-08-17 02:56:21 +02:00
|
|
|
|
2023-05-31 17:34:46 +02:00
|
|
|
1. Task variables
|
|
|
|
2. Call variables
|
|
|
|
3. Taskfile variables
|
|
|
|
4. Taskvars file variables
|
|
|
|
5. Environment variables
|
2020-08-17 02:56:21 +02:00
|
|
|
|
2023-05-31 17:34:46 +02:00
|
|
|
A new global option was added to configure the number of variables expansions
|
|
|
|
(which default to 2):
|
2020-08-17 02:56:21 +02:00
|
|
|
|
|
|
|
```yaml
|
2023-05-31 17:34:46 +02:00
|
|
|
version: '2'
|
2020-08-17 02:56:21 +02:00
|
|
|
|
2023-05-31 17:34:46 +02:00
|
|
|
expansions: 3
|
2020-08-17 02:56:21 +02:00
|
|
|
|
2023-05-31 17:34:46 +02:00
|
|
|
vars:
|
|
|
|
FOO: foo
|
|
|
|
BAR: bar
|
|
|
|
BAZ: baz
|
|
|
|
FOOBAR: '{{.FOO}}{{.BAR}}'
|
|
|
|
FOOBARBAZ: '{{.FOOBAR}}{{.BAZ}}'
|
2020-08-17 02:56:21 +02:00
|
|
|
|
|
|
|
tasks:
|
2023-05-31 17:34:46 +02:00
|
|
|
default:
|
2020-08-17 02:56:21 +02:00
|
|
|
cmds:
|
2023-05-31 17:34:46 +02:00
|
|
|
- echo "{{.FOOBARBAZ}}"
|
2020-08-17 02:56:21 +02:00
|
|
|
```
|
|
|
|
|
2023-05-31 17:34:46 +02:00
|
|
|
## Version 1
|
2020-08-17 02:56:21 +02:00
|
|
|
|
2023-05-31 17:34:46 +02:00
|
|
|
:::caution
|
|
|
|
|
|
|
|
v1 schema support was removed in Task >= v3.0.0.
|
|
|
|
|
|
|
|
:::
|
|
|
|
|
|
|
|
In the first version of the `Taskfile`, the `version:` key was not available,
|
|
|
|
because the tasks was in the root of the YAML document. Like this:
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
echo:
|
|
|
|
cmds:
|
2020-08-17 02:56:21 +02:00
|
|
|
- echo "Hello, World!"
|
|
|
|
```
|
|
|
|
|
2023-05-31 17:34:46 +02:00
|
|
|
The variable priority order was also different:
|
2020-08-17 02:56:21 +02:00
|
|
|
|
2023-05-31 17:34:46 +02:00
|
|
|
1. Call variables
|
|
|
|
2. Environment
|
|
|
|
3. Task variables
|
|
|
|
4. `Taskvars.yml` variables
|
2020-08-17 02:56:21 +02:00
|
|
|
|
2024-04-09 03:12:11 +02:00
|
|
|
{/* prettier-ignore-start */}
|
2024-05-09 02:32:16 +02:00
|
|
|
[deprecate-version-2-schema]: ./deprecations/version_2_schema.mdx
|
|
|
|
[output]: ./usage.mdx#output-syntax
|
|
|
|
[ignore_errors]: ./usage.mdx#ignore-errors
|
|
|
|
[includes]: ./usage.mdx#including-other-taskfiles
|
2024-04-09 03:12:11 +02:00
|
|
|
{/* prettier-ignore-end */}
|