github.com/joselitofilho/goreleaser@v0.155.1-0.20210123221854-e4891856c593/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 do not inherit any environment variables 30 (unlike existing hooks) as a precaution to avoid leaking sensitive data accidentally 31 and provide better control of the environment for each individual process 32 where variable names may overlap unintentionally. 33 34 You can however use `.Env.NAME` templating syntax which enables 35 more explicit inheritance. 36 37 ```yaml 38 - cmd: custom-publisher 39 env: 40 - SECRET_TOKEN={{ .Env.SECRET_TOKEN }} 41 ``` 42 43 ### Variables 44 45 Command (`cmd`), workdir (`dir`) and environment variables (`env`) support templating 46 47 ```yaml 48 publishers: 49 - name: production 50 cmd: | 51 custom-publisher \ 52 -product={{ .ProjectName }} \ 53 -version={{ .Version }} \ 54 {{ .ArtifactName }} 55 dir: "{{ dir .ArtifactPath }}" 56 env: 57 - TOKEN={{ .Env.CUSTOM_PUBLISHER_TOKEN }} 58 ``` 59 60 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`. 61 62 Supported variables: 63 64 - `Version` 65 - `Tag` 66 - `ProjectName` 67 - `ArtifactName` 68 - `ArtifactPath` 69 - `Os` 70 - `Arch` 71 - `Arm` 72 73 ## Customization 74 75 Of course, you can customize a lot of things: 76 77 ```yaml 78 # .goreleaser.yml 79 publishers: 80 - 81 # Unique name of your publisher. Used for identification 82 name: "custom" 83 84 # IDs of the artifacts you want to publish 85 ids: 86 - foo 87 - bar 88 89 # Publish checksums (defaults to false) 90 checksum: true 91 92 # Publish signatures (defaults to false) 93 signature: true 94 95 # Working directory in which to execute the command 96 dir: "/utils" 97 98 # Command to be executed 99 cmd: custom-publisher -product={{ .ProjectName }} -version={{ .Version }} {{ .ArtifactPath }} 100 101 # Environment variables 102 env: 103 - API_TOKEN=secret-token 104 ``` 105 106 These settings should allow you to push your artifacts to any number of endpoints 107 which may require non-trivial authentication or has otherwise complex requirements. 108 109 !!! tip 110 Learn more about the [name template engine](/customization/templates/).