github.com/droot/goreleaser@v0.66.2-0.20180420030140-c2db5fb17157/docs/060-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 `archive` section you can customize the archive name, 7 additional files, and format. 8 9 Here is a commented `archive` section with all fields specified: 10 11 ```yml 12 # .goreleaser.yml 13 archive: 14 # You can change the name of the archive. 15 # This is parsed with the Go template engine and the following variables 16 # are available: 17 # - ProjectName 18 # - Binary (Name of the binary if the packaging format is binary) 19 # - Tag 20 # - Version (Git tag without `v` prefix) 21 # - Os 22 # - Arch 23 # - Arm (ARM version) 24 # - Env (environment variables) 25 # Defaults: 26 # - if format is `tar.gz` or `zip`: 27 # - `{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}` 28 # - if format is `binary`: 29 # - `{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}` 30 name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}" 31 32 # Replacements for GOOS and GOARCH in the archive name. 33 # Keys should be valid GOOSs or GOARCHs. 34 # Values are the respective replacements. 35 # Default is empty. 36 replacements: 37 amd64: 64-bit 38 386: 32-bit 39 darwin: macOS 40 linux: Tux 41 42 # Set to true, if you want all files in the archive to be in a single directory. 43 # If set to true and you extract the archive 'goreleaser_Linux_arm64.tar.gz', 44 # you get a folder 'goreleaser_Linux_arm64'. 45 # If set to false, all files are extracted separately. 46 # Default is false. 47 wrap_in_directory: true 48 49 # Archive format. Valid options are `tar.gz`, `zip` and `binary`. 50 # If format is `binary`, no archives are created and the binaries are instead uploaded directly. 51 # In that case name_template and the below specified files are ignored. 52 # Default is `tar.gz`. 53 format: zip 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/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.md 68 - CHANGELOG.md 69 - docs/* 70 - design/*.png 71 ``` 72 73 ## Passing environment variables to name_template 74 75 You can do that by using `{{ .Env.VARIABLE_NAME }}` in the template, for 76 example: 77 78 ```yaml 79 archive: 80 name_template: '{{.ProjectName}}-{{.Version}}-{{.Env.GOVERSION_NR}}' 81 ``` 82 83 Then you can run: 84 85 ```console 86 GOVERSION_NR=$(go version | awk '{print $3;}') goreleaser 87 ``` 88 89 ## Packaging only the binaries 90 91 Since GoReleaser will always add the `README` and `LICENSE` files to the 92 archive if the file list is empty, you'll need to provide a filled `files` 93 on the archive section. 94 95 A working hack is to use something like this: 96 97 ```yaml 98 # goreleaser.yml 99 archive: 100 files: 101 - none* 102 ``` 103 104 This would add all files matching the glob `none*`, provide that you don't 105 have any files matching that glob, only the binary will be added to the 106 archive. 107 108 For more information, check [#602](https://github.com/goreleaser/goreleaser/issues/602)