github.com/fitzix/goreleaser@v0.92.0/www/content/templates.md (about)

     1  ---
     2  title: Name Templates
     3  series: customization
     4  hideFromIndex: true
     5  weight: 25
     6  ---
     7  
     8  Several fields in GoReleaser's config file support templating.
     9  
    10  Those fields are often suffixed with `_template`, but sometimes they may not
    11  be. The documentation of each section should explicit in which fields
    12  templating is available.
    13  
    14  On fields that support templating, this fields are always available:
    15  
    16  |      Key       |                   Description                    |
    17  | :------------: | :----------------------------------------------: |
    18  | `.ProjectName` |                 the project name                 |
    19  |   `.Version`   | the version being released (`v` prefix stripped) |
    20  |     `.Tag`     |               the current git tag                |
    21  | `.ShortCommit` |            the git commit short hash             |
    22  | `.FullCommit`  |            the git commit full hash              |
    23  |   `.Commit`    |       the git commit hash (deprecated)           |
    24  |   `.GitURL`    |               the git remote url                 |
    25  |    `.Major`    |          the major part of the version           |
    26  |    `.Minor`    |          the minor part of the version           |
    27  |    `.Patch`    |          the patch part of the version           |
    28  |     `.Env`     |    a map with system's environment variables     |
    29  |    `.Date`     |        current UTC date in RFC3339 format        |
    30  |  `.Timestamp`  |         current UTC time in Unix format          |
    31  
    32  On fields that are related to a single artifact (e.g., the binary name), you
    33  may have some extra fields:
    34  
    35  |       Key       |              Description              |
    36  | :-------------: | :-----------------------------------: |
    37  |      `.Os`      |  `GOOS` (usually allow replacements)  |
    38  |     `.Arch`     | `GOARCH` (usually allow replacements) |
    39  |     `.Arm`      | `GOARM` (usually allow replacements)  |
    40  |    `.Binary`    |              Binary name              |
    41  | `.ArtifactName` |             Archive name              |
    42  
    43  On all fields, you have these available functions:
    44  
    45  |        Usage        |               Description                |
    46  | :-----------------: | :--------------------------------------: |
    47  | `time "01/02/2006"` | current UTC time in the specified format |
    48  
    49  With all those fields, you may be able to compose the name of your artifacts
    50  pretty much the way you want:
    51  
    52  ```yaml
    53  example_template: '{{ .ProjectName }}_{{ .Env.USER }}_{{ time "2006" }}'
    54  ```
    55  
    56  For example, if you want to add the go version to some artifact:
    57  
    58  ```yaml
    59  foo_template: 'foo_{{ .Env.GOVERSION }}'
    60  ```
    61  
    62  And then you can run:
    63  
    64  ```console
    65  GOVERSION_NR=$(go version | awk '{print $3;}') goreleaser
    66  ```
    67  
    68  > Note that those are hypothetical examples and the fields `foo_template` and
    69  > `example_template` are not valid GoReleaser configurations.