Skip to content

Commit cbb8578

Browse files
committed
chore: update and re-order taskfile versions doc
1 parent caac99f commit cbb8578

File tree

1 file changed

+143
-107
lines changed

1 file changed

+143
-107
lines changed

docs/docs/taskfile_versions.md

+143-107
Original file line numberDiff line numberDiff line change
@@ -18,86 +18,122 @@ The `version:` key on Taskfile accepts a semver string, so either `2`, `2.0` or
1818
`2.1` features, but if you choose to use `2`, then any `2.x.x` features will be
1919
available, but not `3.0.0+`.
2020

21-
## Version 1
21+
## Version 3 ![latest](https://img.shields.io/badge/latest-brightgreen)
2222

23-
> NOTE: Taskfiles in version 1 are not supported on Task >= v3.0.0 anymore.
23+
These are some major changes done on `v3`:
2424

25-
In the first version of the `Taskfile`, the `version:` key was not available,
26-
because the tasks was in the root of the YAML document. Like this:
25+
- Task's output will now be colored
26+
- Added support for `.env` like files
27+
- Added `label:` setting to task so one can override how the task name appear in
28+
the logs
29+
- A global `method:` was added to allow setting the default method, and Task's
30+
default changed to `checksum`
31+
- Two magic variables were added when using `status:`: `CHECKSUM` and
32+
`TIMESTAMP` which contains, respectively, the md5 checksum and greatest
33+
modification timestamp of the files listed on `sources:`
34+
- Also, the `TASK` variable is always available with the current task name
35+
- CLI variables are always treated as global variables
36+
- Added `dir:` option to `includes` to allow choosing on which directory an
37+
included Taskfile will run:
2738

2839
```yaml
29-
echo:
30-
cmds:
31-
- echo "Hello, World!"
40+
includes:
41+
docs:
42+
taskfile: ./docs
43+
dir: ./docs
3244
```
3345
34-
The variable priority order was also different:
46+
- Implemented short task syntax. All below syntaxes are equivalent:
3547
36-
1. Call variables
37-
2. Environment
38-
3. Task variables
39-
4. `Taskvars.yml` variables
48+
```yaml
49+
version: '3'
4050

41-
## Version 2.0
51+
tasks:
52+
print:
53+
cmds:
54+
- echo "Hello, World!"
55+
```
4256
43-
At version 2, we introduced the `version:` key, to allow us to evolve Task with
44-
new features without breaking existing Taskfiles. The new syntax is as follows:
57+
```yaml
58+
version: '3'
59+
60+
tasks:
61+
print:
62+
- echo "Hello, World!"
63+
```
4564
4665
```yaml
47-
version: '2'
66+
version: '3'
4867

4968
tasks:
50-
echo:
51-
cmds:
52-
- echo "Hello, World!"
69+
print: echo "Hello, World!"
5370
```
5471
55-
Version 2 allows you to write global variables directly in the Taskfile, if you
56-
don't want to create a `Taskvars.yml`:
72+
- There was a major refactor on how variables are handled. They're now easier to
73+
understand. The `expansions:` setting was removed as it became unnecessary.
74+
This is the order in which Task will process variables, each level can see the
75+
variables set by the previous one and override those.
76+
- Environment variables
77+
- Global + CLI variables
78+
- Call variables
79+
- Task variables
80+
81+
## Version 2.6
82+
83+
:::caution
84+
85+
v2 schema support is [deprecated][deprecate-version-2-schema] and will be
86+
removed in a future release.
87+
88+
:::
89+
90+
Version 2.6 comes with `preconditions` stanza in tasks.
5791

5892
```yaml
5993
version: '2'
6094
61-
vars:
62-
GREETING: Hello, World!
63-
6495
tasks:
65-
greet:
96+
upload_environment:
97+
preconditions:
98+
- test -f .env
6699
cmds:
67-
- echo "{{.GREETING}}"
100+
- aws s3 cp .env s3://myenvironment
68101
```
69102

70-
The variable priority order changed to the following:
103+
Please check the [documentation][includes]
71104

72-
1. Task variables
73-
2. Call variables
74-
3. Taskfile variables
75-
4. Taskvars file variables
76-
5. Environment variables
105+
[output]: usage.md#output-syntax
106+
[ignore_errors]: usage.md#ignore-errors
107+
[includes]: usage.md#including-other-taskfiles
77108

78-
A new global option was added to configure the number of variables expansions
79-
(which default to 2):
109+
## Version 2.2
80110

81-
```yaml
82-
version: '2'
111+
:::caution
83112

84-
expansions: 3
113+
v2 schema support is [deprecated][deprecate-version-2-schema] and will be
114+
removed in a future release.
85115

86-
vars:
87-
FOO: foo
88-
BAR: bar
89-
BAZ: baz
90-
FOOBAR: '{{.FOO}}{{.BAR}}'
91-
FOOBARBAZ: '{{.FOOBAR}}{{.BAZ}}'
116+
:::
92117

93-
tasks:
94-
default:
95-
cmds:
96-
- echo "{{.FOOBARBAZ}}"
118+
Version 2.2 comes with a global `includes` options to include other Taskfiles:
119+
120+
```yaml
121+
version: '2'
122+
123+
includes:
124+
docs: ./documentation # will look for ./documentation/Taskfile.yml
125+
docker: ./DockerTasks.yml
97126
```
98127

99128
## Version 2.1
100129

130+
:::caution
131+
132+
v2 schema support is [deprecated][deprecate-version-2-schema] and will be
133+
removed in a future release.
134+
135+
:::
136+
101137
Version 2.1 includes a global `output` option, to allow having more control over
102138
how commands output are printed to the console (see [documentation][output] for
103139
more info):
@@ -134,95 +170,95 @@ tasks:
134170
ignore_error: true
135171
```
136172

137-
## Version 2.2
173+
## Version 2.0
138174

139-
Version 2.2 comes with a global `includes` options to include other Taskfiles:
175+
:::caution
176+
177+
v2 schema support is [deprecated][deprecate-version-2-schema] and will be
178+
removed in a future release.
179+
180+
:::
181+
182+
At version 2, we introduced the `version:` key, to allow us to evolve Task with
183+
new features without breaking existing Taskfiles. The new syntax is as follows:
140184

141185
```yaml
142186
version: '2'
143187
144-
includes:
145-
docs: ./documentation # will look for ./documentation/Taskfile.yml
146-
docker: ./DockerTasks.yml
188+
tasks:
189+
echo:
190+
cmds:
191+
- echo "Hello, World!"
147192
```
148193

149-
## Version 2.6
150-
151-
Version 2.6 comes with `preconditions` stanza in tasks.
194+
Version 2 allows you to write global variables directly in the Taskfile, if you
195+
don't want to create a `Taskvars.yml`:
152196

153197
```yaml
154198
version: '2'
155199
200+
vars:
201+
GREETING: Hello, World!
202+
156203
tasks:
157-
upload_environment:
158-
preconditions:
159-
- test -f .env
204+
greet:
160205
cmds:
161-
- aws s3 cp .env s3://myenvironment
206+
- echo "{{.GREETING}}"
162207
```
163208

164-
Please check the [documentation][includes]
165-
166-
[output]: usage.md#output-syntax
167-
[ignore_errors]: usage.md#ignore-errors
168-
[includes]: usage.md#including-other-taskfiles
169-
170-
## Version 3
209+
The variable priority order changed to the following:
171210

172-
These are some major changes done on `v3`:
211+
1. Task variables
212+
2. Call variables
213+
3. Taskfile variables
214+
4. Taskvars file variables
215+
5. Environment variables
173216

174-
- Task's output will now be colored
175-
- Added support for `.env` like files
176-
- Added `label:` setting to task so one can override how the task name appear in
177-
the logs
178-
- A global `method:` was added to allow setting the default method, and Task's
179-
default changed to `checksum`
180-
- Two magic variables were added when using `status:`: `CHECKSUM` and
181-
`TIMESTAMP` which contains, respectively, the md5 checksum and greatest
182-
modification timestamp of the files listed on `sources:`
183-
- Also, the `TASK` variable is always available with the current task name
184-
- CLI variables are always treated as global variables
185-
- Added `dir:` option to `includes` to allow choosing on which directory an
186-
included Taskfile will run:
217+
A new global option was added to configure the number of variables expansions
218+
(which default to 2):
187219

188220
```yaml
189-
includes:
190-
docs:
191-
taskfile: ./docs
192-
dir: ./docs
193-
```
221+
version: '2'
194222
195-
- Implemented short task syntax. All below syntaxes are equivalent:
223+
expansions: 3
196224
197-
```yaml
198-
version: '3'
225+
vars:
226+
FOO: foo
227+
BAR: bar
228+
BAZ: baz
229+
FOOBAR: '{{.FOO}}{{.BAR}}'
230+
FOOBARBAZ: '{{.FOOBAR}}{{.BAZ}}'
199231
200232
tasks:
201-
print:
233+
default:
202234
cmds:
203-
- echo "Hello, World!"
235+
- echo "{{.FOOBARBAZ}}"
204236
```
205237

206-
```yaml
207-
version: '3'
238+
## Version 1
208239

209-
tasks:
210-
print:
240+
:::caution
241+
242+
v1 schema support was removed in Task >= v3.0.0.
243+
244+
:::
245+
246+
In the first version of the `Taskfile`, the `version:` key was not available,
247+
because the tasks was in the root of the YAML document. Like this:
248+
249+
```yaml
250+
echo:
251+
cmds:
211252
- echo "Hello, World!"
212253
```
213254

214-
```yaml
215-
version: '3'
255+
The variable priority order was also different:
216256

217-
tasks:
218-
print: echo "Hello, World!"
219-
```
257+
1. Call variables
258+
2. Environment
259+
3. Task variables
260+
4. `Taskvars.yml` variables
220261

221-
- There was a major refactor on how variables are handled. They're now easier to
222-
understand. The `expansions:` setting was removed as it became unnecessary.
223-
This is the order in which Task will process variables, each level can see the
224-
variables set by the previous one and override those.
225-
- Environment variables
226-
- Global + CLI variables
227-
- Call variables
228-
- Task variables
262+
<!-- prettier-ignore-start -->
263+
[deprecate-version-2-schema]: https://github.com/go-task/task/issues/1197
264+
<!-- prettier-ignore-end -->

0 commit comments

Comments
 (0)