github.com/joselitofilho/goreleaser@v0.155.1-0.20210123221854-e4891856c593/www/docs/customization/upload.md (about) 1 --- 2 title: HTTP Upload 3 --- 4 5 GoReleaser supports building and pushing artifacts to HTTP servers using simple 6 HTTP requests. 7 8 ## How it works 9 10 You can declare multiple `uploads` instances. All binaries generated by your 11 `builds` section will be pushed to each configured upload. 12 13 If you have only one `uploads` instance, the configuration is as easy as adding 14 the upload target and a username to your `.goreleaser.yml` file: 15 16 ```yaml 17 uploads: 18 - name: production 19 target: http://some.server/some/path/example-repo-local/{{ .ProjectName }}/{{ .Version }}/ 20 username: goreleaser 21 ``` 22 23 Prerequisites: 24 25 - An HTTP server accepting HTTP requests 26 - A user + password with grants to upload an artifact using HTTP requests (if the server requires it) 27 28 ### Target 29 30 The `target` is the template of the URL to upload the artifacts to (_without_ the name of the artifact). 31 32 An example configuration for `goreleaser` in upload mode `binary` with the target can look like: 33 34 ```yaml 35 - name: production 36 mode: binary 37 target: 'http://some.server/some/path/example-repo-local/{{ .ProjectName }}/{{ .Version }}/{{ .Os }}/{{ .Arch }}{{ if .Arm }}{{ .Arm }}{{ end }}' 38 ``` 39 40 and will result in an HTTP PUT request sent to `http://some.server/some/path/example-repo-local/goreleaser/1.0.0/Darwin/x86_64/goreleaser`. 41 42 Supported variables: 43 44 - Version 45 - Tag 46 - ProjectName 47 - ArtifactName 48 - Os 49 - Arch 50 - Arm 51 52 !!! warning 53 Variables `Os`, `Arch` and `Arm` are only supported in upload mode `binary`. 54 55 For `archive` mode, it will also included the `LinuxPackage` type which is 56 generated by `nfpm` and the like. 57 58 ### Username 59 60 Your configured username needs to be valid against your HTTP server. 61 62 You can have the username set in the configuration file as shown above 63 or you can have it read from and environment variable. 64 The configured name of your HTTP server will be used to build the environment 65 variable name. 66 This way we support auth for multiple instances. 67 This also means that the `name` per configured instance needs to be unique 68 per GoReleaser configuration. 69 70 The name of the environment variable will be `UPLOAD_NAME_USERNAME`. 71 If your instance is named `production`, you can store the username in the 72 environment variable `UPLOAD_PRODUCTION_USERNAME`. 73 The name will be transformed to uppercase. 74 75 If a configured username is found in the configuration file, then the 76 environment variable is not used at all. 77 78 ### Password 79 80 The password will be stored in a environment variable. 81 The configured name of your HTTP server will be used. 82 This way we support auth for multiple instances. 83 This also means that the `name` per configured instance needs to be unique 84 per GoReleaser configuration. 85 86 The name of the environment variable will be `UPLOAD_NAME_SECRET`. 87 If your instance is named `production`, you need to store the secret in the 88 environment variable `UPLOAD_PRODUCTION_SECRET`. 89 The name will be transformed to uppercase. 90 91 ### Server authentication 92 93 You can authenticate your TLS server adding a trusted X.509 certificate chain 94 in your upload configuration. 95 96 The trusted certificate chain will be used to validate the server certificates. 97 98 You can set the trusted certificate chain using the `trusted_certificates` 99 setting the upload section with PEM encoded certificates on a YAML literal block 100 like this: 101 102 ```yaml 103 uploads: 104 - name: "some HTTP/TLS server" 105 #...(other settings)... 106 trusted_certificates: | 107 -----BEGIN CERTIFICATE----- 108 MIIDrjCCApagAwIBAgIIShr2zchZo+8wDQYJKoZIhvcNAQENBQAwNTEXMBUGA1UE 109 ...(edited content)... 110 TyzMJasj5BPZrmKjJb6O/tOtEIJ66xPSBTxPShkEYHnB7A== 111 -----END CERTIFICATE----- 112 -----BEGIN CERTIFICATE----- 113 MIIDrjCCApagAwIBAgIIShr2zchZo+8wDQYJKoZIhvcNAQENBQAwNTEXMBUGA1UE 114 ...(edited content)... 115 TyzMJasj5BPZrmKjJb6O/tOtEIJ66xPSBTxPShkEYHnB7A== 116 -----END CERTIFICATE----- 117 ``` 118 119 ## Customization 120 121 Of course, you can customize a lot of things: 122 123 ```yaml 124 # .goreleaser.yml 125 uploads: 126 # You can have multiple upload instances. 127 - 128 # Unique name of your upload instance. Used to identify the instance. 129 name: production 130 131 # HTTP method to use. 132 # Default: PUT 133 method: POST 134 135 # IDs of the artifacts you want to upload. 136 ids: 137 - foo 138 - bar 139 140 # Upload mode. Valid options are `binary` and `archive`. 141 # If mode is `archive`, variables _Os_, _Arch_ and _Arm_ for target name are not supported. 142 # In that case these variables are empty. 143 # Default is `archive`. 144 mode: archive 145 146 # Template of the URL to be used as target of the HTTP request 147 target: https://some.server/some/path/example-repo-local/{{ .ProjectName }}/{{ .Version }}/ 148 149 # Custom artifact name (defaults to false) 150 # If enable, you must supply the name of the Artifact as part of the Target 151 # URL as it will not be automatically append to the end of the URL, its 152 # pre-computed name is available as _ArtifactName_ for example 153 # target: https://some.server/some/path/example-repo-local/{{ .ArtifactName }};deb.distribution=xenial 154 custom_artifact_name: true 155 156 # User that will be used for the deployment 157 username: deployuser 158 159 # An optional header you can use to tell GoReleaser to pass the artifact's 160 # SHA256 checksum within the upload request. 161 # Default is empty. 162 checksum_header: -X-SHA256-Sum 163 164 # A map of custom headers e.g. to support required content types or auth schemes. 165 # Default is empty. 166 custom_headers: 167 JOB-TOKEN: "{{ .Env.CI_JOB_TOKEN }}" 168 169 # Upload checksums (defaults to false) 170 checksum: true 171 172 # Upload signatures (defaults to false) 173 signature: true 174 175 # Certificate chain used to validate server certificates 176 trusted_certificates: | 177 -----BEGIN CERTIFICATE----- 178 MIIDrjCCApagAwIBAgIIShr2zchZo+8wDQYJKoZIhvcNAQENBQAwNTEXMBUGA1UE 179 ...(edited content)... 180 TyzMJasj5BPZrmKjJb6O/tOtEIJ66xPSBTxPShkEYHnB7A== 181 -----END CERTIFICATE----- 182 ``` 183 184 These settings should allow you to push your artifacts into multiple HTTP servers. 185 186 !!! tip 187 Learn more about the [name template engine](/customization/templates/).