@@ -5,259 +5,68 @@ sidebar_position: 5
55
66# Taskfile Versions
77
8- The Taskfile syntax and features changed with time. This document explains what
9- changed on each version and how to upgrade your Taskfile.
8+ The Taskfile schema slowly changes as new features are added and old ones are
9+ removed. This document explains how to use a Taskfile's schema version to ensure
10+ that the users of your Taskfile are using the correct versions of Task.
1011
11- ## What the Taskfile version mean
12+ ## What the Taskfile version means
1213
13- The Taskfile version follows the Task version. E.g. the change to Taskfile
14- version ` 2 ` means that Task ` v2.0.0 ` should be release to support it.
15-
16- The ` version: ` key on Taskfile accepts a semver string, so either ` 2 ` , ` 2.0 ` or
17- ` 2.0.0 ` is accepted. If you choose to use ` 2.0 ` Task will not enable future
18- ` 2.1 ` features, but if you choose to use ` 2 ` , then any ` 2.x.x ` features will be
19- available, but not ` 3.0.0+ ` .
20-
21- ## Version 3 ![ latest] ( https://img.shields.io/badge/latest-brightgreen )
22-
23- These are some major changes done on ` v3 ` :
24-
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 XXH3 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:
14+ The schema version at the top of every Taskfile corresponds to a version of the
15+ Task CLI, and by extension, the features that are provided by that version. When
16+ creating a Taskfile, you should specify the _ minimum_ version of Task that
17+ supports the features you require. If you try to run a Taskfile with a version
18+ of Task that does not meet this minimum required version, it will exit with an
19+ error. For example, given a Taskfile that starts with:
3820
3921``` yaml
40- includes :
41- docs :
42- taskfile : ./docs
43- dir : ./docs
22+ version : ' 3.2.1'
4423` ` `
4524
46- - Implemented short task syntax. All below syntaxes are equivalent:
47-
48- ` ` ` yaml
49- version : ' 3'
50-
51- tasks :
52- print :
53- cmds :
54- - echo "Hello, World!"
55- ` ` `
25+ When executed with Task ` v3.2.0`, it will exit with an error. Running with
26+ version `v3.2.1` or higher will work as expected.
5627
57- ` ` ` yaml
58- version : ' 3'
28+ Task accepts any [SemVer][semver] compatible string including versions which
29+ omit the minor or patch numbers. For example, `3`, `3.0`, and `3.0.0` all mean
30+ the same thing and are all valid. Most Taskfiles only specify the major version
31+ number. However it can be useful to be more specific when you intend to share a
32+ Taskfile with others.
5933
60- tasks :
61- print :
62- - echo "Hello, World!"
63- ` ` `
34+ For example, the Taskfile below makes use of aliases :
6435
6536` ` ` yaml
6637version: '3'
6738
6839tasks:
69- print : echo "Hello, World!"
70- ` ` `
71-
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 schemas are [no longer supported by the latest version of
86- Task][deprecate-version-2-schema].
87-
88- :: :
89-
90- Version 2.6 comes with `preconditions` stanza in tasks.
91-
92- ` ` ` yaml
93- version: '2'
94-
95- tasks:
96- upload_environment:
97- preconditions:
98- - test -f .env
99- cmds:
100- - aws s3 cp .env s3://myenvironment
101- ` ` `
102-
103- Please check the [documentation][includes]
104-
105- # # Version 2.2
106-
107- :::caution
108-
109- v2 schemas are [no longer supported by the latest version of
110- Task][deprecate-version-2-schema].
111-
112- :: :
113-
114- Version 2.2 comes with a global `includes` options to include other Taskfiles :
115-
116- ` ` ` yaml
117- version: '2'
118-
119- includes:
120- docs: ./documentation # will look for ./documentation/Taskfile.yml
121- docker: ./DockerTasks.yml
122- ` ` `
123-
124- # # Version 2.1
125-
126- :::caution
127-
128- v2 schemas are [no longer supported by the latest version of
129- Task][deprecate-version-2-schema].
130-
131- :: :
132-
133- Version 2.1 includes a global `output` option, to allow having more control over
134- how commands output are printed to the console (see [documentation][output] for
135- more info) :
136-
137- ` ` ` yaml
138- version: '2'
139-
140- output: prefixed
141-
142- tasks:
143- server:
144- cmds:
145- - go run main.go
146- prefix: server
147- ` ` `
148-
149- From this version it's also possible to ignore errors of a command or task
150- (check documentation [here][ignore_errors]) :
151-
152- ` ` ` yaml
153- version: '2'
154-
155- tasks:
156- example-1:
157- cmds:
158- - cmd: exit 1
159- ignore_error: true
160- - echo "This will be print"
161-
162- example-2:
163- cmds:
164- - exit 1
165- - echo "This will be print"
166- ignore_error: true
167- ` ` `
168-
169- # # Version 2.0
170-
171- :::caution
172-
173- v2 schemas are [no longer supported by the latest version of
174- Task][deprecate-version-2-schema].
175-
176- :: :
177-
178- At version 2, we introduced the `version:` key, to allow us to evolve Task with
179- new features without breaking existing Taskfiles. The new syntax is as follows :
180-
181- ` ` ` yaml
182- version: '2'
183-
184- tasks:
185- echo:
40+ hello:
41+ aliases:
42+ - hi
43+ - hey
18644 cmds:
187- - echo "Hello, World !"
45+ - echo "Hello, world !"
18846` ` `
18947
190- Version 2 allows you to write global variables directly in the Taskfile, if you
191- don't want to create a `Taskvars.yml` :
192-
193- ` ` ` yaml
194- version: '2'
195-
196- vars:
197- GREETING: Hello, World!
198-
199- tasks:
200- greet:
201- cmds:
202- - echo "{{.GREETING}}"
203- ` ` `
204-
205- The variable priority order changed to the following :
206-
207- 1. Task variables
208- 2. Call variables
209- 3. Taskfile variables
210- 4. Taskvars file variables
211- 5. Environment variables
48+ Aliases were introduced in Task `v3.17.0`, but the Taskfile only specifies `3`
49+ as the version. This means that a user who has `v3.16.0` or lower installed will
50+ get a potentially confusing error message when trying to run the Task as the
51+ Taskfile specifies that any version greater or equal to `v3.0.0` is fine.
21252
213- A new global option was added to configure the number of variables expansions
214- (which default to 2) :
53+ Instead, we should start the file like this :
21554
21655` ` ` yaml
217- version: '2'
218-
219- expansions: 3
220-
221- vars:
222- FOO: foo
223- BAR: bar
224- BAZ: baz
225- FOOBAR: '{{.FOO}}{{.BAR}}'
226- FOOBARBAZ: '{{.FOOBAR}}{{.BAZ}}'
227-
228- tasks:
229- default:
230- cmds:
231- - echo "{{.FOOBARBAZ}}"
56+ version: '3.17'
23257` ` `
23358
234- # # Version 1
235-
236- :::caution
59+ Now when someone tries to run the Taskfile with an older version of Task, they
60+ will receive an error prompting them to upgrade their version of Task to
61+ ` v3.17.0 ` or greater.
23762
238- v1 schema support was removed in Task >= v3.0.0.
239-
240- :: :
241-
242- In the first version of the `Taskfile`, the `version:` key was not available,
243- because the tasks was in the root of the YAML document. Like this :
244-
245- ` ` ` yaml
246- echo:
247- cmds:
248- - echo "Hello, World!"
249- ` ` `
63+ # # Versions 1 & 2
25064
251- The variable priority order was also different :
65+ Version 1 and 2 of Task are no longer officially supported and anyone still
66+ using them is strongly encouraged to upgrade to the latest version of Task.
25267
253- 1. Call variables
254- 2. Environment
255- 3. Task variables
256- 4. `Taskvars.yml` variables
68+ While `version : 2` of Task did support schema versions, the behavior did not
69+ work in quite the same way and cannot be relied upon for the purposes discussed
70+ above.
25771
258- {/* prettier-ignore-start */}
259- [deprecate-version-2-schema] : ./deprecations/version_2_schema.mdx
260- [output] : ./usage.mdx#output-syntax
261- [ignore_errors] : ./usage.mdx#ignore-errors
262- [includes] : ./usage.mdx#including-other-taskfiles
263- {/* prettier-ignore-end */}
72+ [semver] : https://semver.org/
0 commit comments