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