github.com/ahmet2mir/goreleaser@v0.180.3-0.20210927151101-8e5ee5a9b8c5/www/docs/customization/archive.md (about) 1 --- 2 title: Archive 3 --- 4 5 The binaries built will be archived together with the `README` and `LICENSE` files into a 6 `tar.gz` file. In the `archives` section you can customize the archive name, 7 additional files, and format. 8 9 Here is a commented `archives` section with all fields specified: 10 11 ```yaml 12 # .goreleaser.yml 13 archives: 14 - 15 # ID of this archive. 16 # Defaults to `default`. 17 id: my-archive 18 19 # Builds reference which build instances should be archived in this archive. 20 builds: 21 - default 22 23 # Archive format. Valid options are `tar.gz`, `tar.xz`, `tar`, `gz`, `zip` and `binary`. 24 # If format is `binary`, no archives are created and the binaries are instead 25 # uploaded directly. 26 # Default is `tar.gz`. 27 format: zip 28 29 # Archive name template. 30 # Defaults: 31 # - if format is `tar.gz`, `tar.xz`, `gz` or `zip`: 32 # - `{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}` 33 # - if format is `binary`: 34 # - `{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}` 35 name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}" 36 37 # Replacements for GOOS and GOARCH in the archive name. 38 # Keys should be valid GOOSs or GOARCHs. 39 # Values are the respective replacements. 40 # Default is empty. 41 replacements: 42 amd64: 64-bit 43 386: 32-bit 44 darwin: macOS 45 linux: Tux 46 47 # Set to true, if you want all files in the archive to be in a single directory. 48 # If set to true and you extract the archive 'goreleaser_Linux_arm64.tar.gz', 49 # you get a folder 'goreleaser_Linux_arm64'. 50 # If set to false, all files are extracted separately. 51 # You can also set it to a custom folder name (templating is supported). 52 # Default is false. 53 wrap_in_directory: true 54 55 # Can be used to change the archive formats for specific GOOSs. 56 # Most common use case is to archive as zip on Windows. 57 # Default is empty. 58 format_overrides: 59 - goos: windows 60 format: zip 61 62 # Additional files/template/globs you want to add to the archive. 63 # Defaults are any files matching `LICENSE*`, `README*`, `CHANGELOG*`, 64 # `license*`, `readme*` and `changelog*`. 65 files: 66 - LICENSE.txt 67 - README_{{.Os}}.md 68 - CHANGELOG.md 69 - docs/* 70 - design/*.png 71 - templates/**/* 72 # a more complete example, check the globbing deep dive below 73 - src: '*.md' 74 dst: docs 75 # Strip parent folders when adding files to the archive. 76 # Default: false 77 strip_parent: true 78 # File info. 79 # Not all fields are supported by all formats available formats. 80 # Defaults to the file info of the actual file if not provided. 81 info: 82 owner: root 83 group: root 84 mode: 0644 85 # format is `time.RFC3339Nano` 86 mtime: 2008-01-02T15:04:05Z 87 88 # Disables the binary count check. 89 # Default: false 90 allow_different_binary_count: true 91 ``` 92 93 !!! tip 94 Learn more about the [name template engine](/customization/templates/). 95 96 !!! tip 97 You can add entire folders, its subfolders and files by using the glob notation, 98 for example: `myfolder/**/*`. 99 100 !!! warning 101 The `files` and `wrap_in_directory` options are ignored if `format` is `binary`. 102 103 !!! warning 104 The `name_template` option will not reflect the filenames under the `dist` folder if `format` is `binary`. 105 The template will be applied only where the binaries are uploaded (e.g. GitHub releases). 106 107 ## Deep diving into the globbing options 108 109 We'll walk through what happens in each case using some examples. 110 111 ```yaml 112 # ... 113 files: 114 115 # Adds `README.md` at the root of the archive: 116 - README.md 117 118 # Adds all `md` files to the root of the archive: 119 - '*.md' 120 121 # Adds all `md` files to the root of the archive: 122 - src: '*.md' 123 124 # Adds all `md` files in the current folder to a `docs` folder in the archive: 125 - src: '*.md' 126 dst: docs 127 128 # Recursively adds all `go` files to a `source` folder in the archive. 129 # in this case, `cmd/myapp/main.go` will be added as `source/cmd/myapp/main.go` 130 - src: '**/*.go' 131 dst: source 132 133 # Recursively adds all `go` files to a `source` folder in the archive, stripping their parent folder. 134 # In this case, `cmd/myapp/main.go` will be added as `source/main.go`: 135 - src: '**/*.go' 136 dst: source 137 strip_parent: true 138 # ... 139 ``` 140 141 !!! warning 142 `strip_parent` is only effective if `dst` is not empty. 143 144 ## Packaging only the binaries 145 146 Since GoReleaser will always add the `README` and `LICENSE` files to the 147 archive if the file list is empty, you'll need to provide a filled `files` 148 on the archive section. 149 150 A working hack is to use something like this: 151 152 ```yaml 153 # .goreleaser.yml 154 archives: 155 - files: 156 - none* 157 ``` 158 159 This would add all files matching the glob `none*`, provide that you don't 160 have any files matching that glob, only the binary will be added to the 161 archive. 162 163 For more information, check [#602](https://github.com/goreleaser/goreleaser/issues/602) 164 165 ## A note about Gzip 166 167 Gzip is a compression-only format, therefore, it couldn't have more than one 168 file inside. 169 170 Presumably, you'll want that file to be the binary, so, your archive section 171 will probably look like this: 172 173 ```yaml 174 # .goreleaser.yml 175 archives: 176 - format: gz 177 files: 178 - none* 179 ``` 180 181 This should create `.gz` files with the binaries only, which should be 182 extracted with something like `gzip -d file.gz`. 183 184 !!! warning 185 You won't be able to package multiple builds in a single archive either. 186 The alternative is to declare multiple archives filtering by build ID. 187 188 ## Disable archiving 189 190 You can do that by setting `format` to `binary`: 191 192 ```yaml 193 # .goreleaser.yml 194 archives: 195 - format: binary 196 ``` 197 198 Make sure to check the rest of the documentation above, as doing this has some 199 implications.