Skip to content

Commit 2607866

Browse files
committed
readme: document new syntax for synamic variables
1 parent e8e914b commit 2607866

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

README.md

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ Example of `Taskvars.yml` file:
303303
```yml
304304
PROJECT_NAME: My Project
305305
DEV_MODE: production
306-
GIT_COMMIT: $git log -n 1 --format=%h
306+
GIT_COMMIT: {sh: git log -n 1 --format=%h}
307307
```
308308

309309
> NOTE: It's also possible setting a variable globally using `set` attribute
@@ -323,20 +323,34 @@ set-message:
323323

324324
#### Dynamic variables
325325

326-
If you prefix a variable with `$`, then the variable is considered a dynamic
327-
variable. The value after the $-symbol will be treated as a command and the
328-
output assigned.
326+
The below syntax (`sh:` prop in a variable) is considered a dynamic
327+
variable. The value will be treated as a command and the output assigned.
329328

330329
```yml
331330
build:
332331
cmds:
333-
- go build -ldflags="-X main.Version={{.LAST_GIT_COMMIT}}" main.go
332+
- go build -ldflags="-X main.Version={{.GIT_COMMIT}}" main.go
334333
vars:
335-
LAST_GIT_COMMIT: $git log -n 1 --format=%h
334+
GIT_COMMIT:
335+
sh: git log -n 1 --format=%h
336336
```
337337

338338
This works for all types of variables.
339339

340+
> It's also possible to prefix the variable with `$` to have a dynamic
341+
variable, but this is now considered deprecated:
342+
343+
```yml
344+
# Taskvars.yml
345+
346+
# recommended
347+
GIT_COMMIT:
348+
sh: git log -n 1 --format=%h
349+
350+
# deprecated
351+
GIT_COMMIT: $git log -n 1 --format=%h
352+
```
353+
340354
### Go's template engine
341355

342356
Task parse commands as [Go's template engine][gotemplate] before executing

0 commit comments

Comments
 (0)