github.com/goreleaser/goreleaser@v1.25.1/www/docs/customization/publishers.md (about) 1 # Custom Publishers 2 3 GoReleaser supports publishing artifacts by executing a custom publisher. 4 5 ## How it works 6 7 You can declare multiple `publishers` instances. Each publisher will be 8 executed for each (filtered) artifact. For example, there will be a total of 9 6 executions for 2 publishers with 3 artifacts. 10 11 Publishers run sequentially in the order they're defined 12 and executions are parallelized between all artifacts. 13 In other words the publisher is expected to be safe to run 14 in multiple instances in parallel. 15 16 If you have only one `publishers` instance, the configuration is as easy as adding 17 the command to your `.goreleaser.yaml` file: 18 19 ```yaml 20 publishers: 21 - name: my-publisher 22 cmd: custom-publisher -version={{ .Version }} {{ abs .ArtifactPath }} 23 ``` 24 25 ### Environment 26 27 Commands, which are executed as custom publishers only inherit a subset of 28 the system environment variables (unlike existing hooks) as a precaution to 29 avoid leaking sensitive data accidentally and provide better control of the 30 environment for each individual process where variable names may overlap 31 unintentionally. 32 33 Environment variables that are kept: 34 35 - `HOME` 36 - `USER` 37 - `USERPROFILE` 38 - `TMPDIR` 39 - `TMP` 40 - `TEMP` 41 - `PATH` 42 43 You can however use `.Env.NAME` templating syntax, which enables 44 more explicit inheritance. 45 46 ```yaml 47 - cmd: custom-publisher 48 env: 49 - SECRET_TOKEN={{ .Env.SECRET_TOKEN }} 50 ``` 51 52 The publisher explicit environment variables take precedence over the 53 inherited set of variables as well. 54 55 ### Variables 56 57 Command (`cmd`), workdir (`dir`) and environment variables (`env`) support templating 58 59 ```yaml 60 publishers: 61 - name: production 62 cmd: | 63 custom-publisher \ 64 -product={{ .ProjectName }} \ 65 -version={{ .Version }} \ 66 {{ .ArtifactName }} 67 dir: "{{ dir .ArtifactPath }}" 68 env: 69 - TOKEN={{ .Env.CUSTOM_PUBLISHER_TOKEN }} 70 ``` 71 72 So the above example will execute: 73 74 ```bash 75 custom-publisher -product=goreleaser -version=1.0.0 goreleaser_1.0.0_linux_amd64.zip 76 ``` 77 78 In `/path/to/dist` with `TOKEN=token`, assuming that GoReleaser is executed 79 with `CUSTOM_PUBLISHER_TOKEN=token`. 80 81 Supported variables: 82 83 - `Version` 84 - `Tag` 85 - `ProjectName` 86 - `ArtifactName` 87 - `ArtifactPath` 88 - `Os` 89 - `Arch` 90 - `Arm` 91 92 ## Customization 93 94 Of course, you can customize a lot of things: 95 96 ```yaml 97 # .goreleaser.yaml 98 publishers: 99 - # 100 # Unique name of your publisher. Used for identification 101 name: "custom" 102 103 # IDs of the artifacts you want to publish 104 ids: 105 - foo 106 - bar 107 108 # Publish checksums. 109 checksum: true 110 111 # Upload metadata.json and artifacts.json. 112 # 113 # Since: v1.25 114 meta: true 115 116 # Publish signatures. 117 signature: true 118 119 # Working directory in which to execute the command 120 dir: "/utils" 121 122 # Command to be executed 123 cmd: custom-publisher -product={{ .ProjectName }} -version={{ .Version }} {{ .ArtifactPath }} 124 125 # Environment variables 126 env: 127 - API_TOKEN=secret-token 128 129 # Whether to disable this particular upload configuration. 130 # 131 # Since: v1.20 132 # Templates: allowed 133 disable: "{{ if .IsNightly }}true{{ end }}" 134 135 # You can publish extra pre-existing files. 136 # The filename published will be the last part of the path (base). 137 # If another file with the same name exists, the last one found will be used. 138 # 139 # Templates: allowed 140 extra_files: 141 - glob: ./path/to/file.txt 142 - glob: ./glob/**/to/**/file/**/* 143 - glob: ./glob/foo/to/bar/file/foobar/override_from_previous 144 - glob: ./single_file.txt 145 name_template: file.txt # note that this only works if glob matches 1 file only 146 147 # Additional templated extra files to published. 148 # Those files will have their contents pass through the template engine, 149 # and its results will be published. 150 # 151 # This feature is only available in GoReleaser Pro. 152 # Since: v1.17 (pro) 153 # Templates: allowed 154 templated_extra_files: 155 - src: LICENSE.tpl 156 dst: LICENSE.txt 157 ``` 158 159 These settings should allow you to push your artifacts to any number of 160 endpoints, which may require non-trivial authentication or has otherwise complex 161 requirements. 162 163 !!! tip 164 165 Learn more about the [name template engine](/customization/templates/).