github.com/ahmet2mir/goreleaser@v0.180.3-0.20210927151101-8e5ee5a9b8c5/www/docs/customization/publishers.md (about) 1 --- 2 title: Custom Publishers 3 --- 4 5 GoReleaser supports publishing artifacts by executing a custom publisher. 6 7 ## How it works 8 9 You can declare multiple `publishers` instances. Each publisher will be 10 executed for each (filtered) artifact. For example, there will be a total of 11 6 executions for 2 publishers with 3 artifacts. 12 13 Publishers run sequentially in the order they're defined 14 and executions are parallelized between all artifacts. 15 In other words the publisher is expected to be safe to run 16 in multiple instances in parallel. 17 18 If you have only one `publishers` instance, the configuration is as easy as adding 19 the command to your `.goreleaser.yml` file: 20 21 ```yaml 22 publishers: 23 - name: my-publisher 24 cmd: custom-publisher -version={{ .Version }} {{ abs .ArtifactPath }} 25 ``` 26 27 ### Environment 28 29 Commands which are executed as custom publishers only inherit a subset of 30 the system environment variables (unlike existing hooks) as a precaution to 31 avoid leaking sensitive data accidentally and provide better control of the 32 environment for each individual process where variable names may overlap 33 unintentionally. 34 35 Environment variables that are kept: 36 37 - `HOME` 38 - `USER` 39 - `USERPROFILE` 40 - `TMPDIR` 41 - `TMP` 42 - `TEMP` 43 - `PATH` 44 45 46 You can however use `.Env.NAME` templating syntax which enables 47 more explicit inheritance. 48 49 ```yaml 50 - cmd: custom-publisher 51 env: 52 - SECRET_TOKEN={{ .Env.SECRET_TOKEN }} 53 ``` 54 55 The publisher explicit environment variables take precedence over the 56 inherited set of variables as well. 57 58 ### Variables 59 60 Command (`cmd`), workdir (`dir`) and environment variables (`env`) support templating 61 62 ```yaml 63 publishers: 64 - name: production 65 cmd: | 66 custom-publisher \ 67 -product={{ .ProjectName }} \ 68 -version={{ .Version }} \ 69 {{ .ArtifactName }} 70 dir: "{{ dir .ArtifactPath }}" 71 env: 72 - TOKEN={{ .Env.CUSTOM_PUBLISHER_TOKEN }} 73 ``` 74 75 so the above example will execute `custom-publisher -product=goreleaser -version=1.0.0 goreleaser_1.0.0_linux_amd64.zip` in `/path/to/dist` with `TOKEN=token`, assuming that GoReleaser is executed with `CUSTOM_PUBLISHER_TOKEN=token`. 76 77 Supported variables: 78 79 - `Version` 80 - `Tag` 81 - `ProjectName` 82 - `ArtifactName` 83 - `ArtifactPath` 84 - `Os` 85 - `Arch` 86 - `Arm` 87 88 ## Customization 89 90 Of course, you can customize a lot of things: 91 92 ```yaml 93 # .goreleaser.yml 94 publishers: 95 - 96 # Unique name of your publisher. Used for identification 97 name: "custom" 98 99 # IDs of the artifacts you want to publish 100 ids: 101 - foo 102 - bar 103 104 # Publish checksums (defaults to false) 105 checksum: true 106 107 # Publish signatures (defaults to false) 108 signature: true 109 110 # Working directory in which to execute the command 111 dir: "/utils" 112 113 # Command to be executed 114 cmd: custom-publisher -product={{ .ProjectName }} -version={{ .Version }} {{ .ArtifactPath }} 115 116 # Environment variables 117 env: 118 - API_TOKEN=secret-token 119 ``` 120 121 These settings should allow you to push your artifacts to any number of endpoints 122 which may require non-trivial authentication or has otherwise complex requirements. 123 124 !!! tip 125 Learn more about the [name template engine](/customization/templates/).