github.com/joselitofilho/goreleaser@v0.155.1-0.20210123221854-e4891856c593/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`, `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 `LICENCE*`, `LICENSE*`, 64 # `README*` and `CHANGELOG*` (case-insensitive). 65 files: 66 - LICENSE.txt 67 - README_{{.Os}}.md 68 - CHANGELOG.md 69 - docs/* 70 - design/*.png 71 - templates/**/* 72 73 # Disables the binary count check. 74 # Default: false 75 allow_different_binary_count: true 76 ``` 77 78 !!! tip 79 Learn more about the [name template engine](/customization/templates/). 80 81 !!! tip 82 You can add entire folders, its subfolders and files by using the glob notation, 83 for example: `myfolder/**/*`. 84 85 !!! warning 86 The `files` and `wrap_in_directory` options are ignored if `format` is `binary`. 87 88 !!! warning 89 The `name_template` option will not reflect the filenames under the `dist` folder if `format` is `binary`. 90 The template will be applied only where the binaries are uploaded (e.g. GitHub releases). 91 92 ## Packaging only the binaries 93 94 Since GoReleaser will always add the `README` and `LICENSE` files to the 95 archive if the file list is empty, you'll need to provide a filled `files` 96 on the archive section. 97 98 A working hack is to use something like this: 99 100 ```yaml 101 # .goreleaser.yml 102 archives: 103 - files: 104 - none* 105 ``` 106 107 This would add all files matching the glob `none*`, provide that you don't 108 have any files matching that glob, only the binary will be added to the 109 archive. 110 111 For more information, check [#602](https://github.com/goreleaser/goreleaser/issues/602) 112 113 ## A note about Gzip 114 115 Gzip is a compression-only format, therefore, it couldn't have more than one 116 file inside. 117 118 Presumably, you'll want that file to be the binary, so, your archive section 119 will probably look like this: 120 121 ```yaml 122 # .goreleaser.yml 123 archives: 124 - format: gz 125 files: 126 - none* 127 ``` 128 129 This should create `.gz` files with the binaries only, which should be 130 extracted with something like `gzip -d file.gz`. 131 132 !!! warning 133 You won't be able to package multiple builds in a single archive either. 134 The alternative is to declare multiple archives filtering by build ID. 135 136 ## Disable archiving 137 138 You can do that by setting `format` to `binary`: 139 140 ```yaml 141 # .goreleaser.yml 142 archives: 143 - format: binary 144 ``` 145 146 Make sure to check the rest of the documentation above, as doing this has some 147 implications.