github.com/szyn/goreleaser@v0.76.1-0.20180517112710-333da09a1297/www/content/archive.md (about) 1 --- 2 title: Archive 3 series: customization 4 hideFromIndex: true 5 weight: 40 6 --- 7 8 The binaries built will be archived together with the `README` and `LICENSE` files into a 9 `tar.gz` file. In the `archive` section you can customize the archive name, 10 additional files, and format. 11 12 Here is a commented `archive` section with all fields specified: 13 14 ```yml 15 # .goreleaser.yml 16 archive: 17 # You can change the name of the archive. 18 # This is parsed with the Go template engine and the following variables 19 # are available: 20 # - ProjectName 21 # - Binary (Name of the binary if the packaging format is binary) 22 # - Tag 23 # - Version (Git tag without `v` prefix) 24 # - Os 25 # - Arch 26 # - Arm (ARM version) 27 # - Env (environment variables) 28 # Defaults: 29 # - if format is `tar.gz` or `zip`: 30 # - `{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}` 31 # - if format is `binary`: 32 # - `{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}` 33 name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}" 34 35 # Replacements for GOOS and GOARCH in the archive name. 36 # Keys should be valid GOOSs or GOARCHs. 37 # Values are the respective replacements. 38 # Default is empty. 39 replacements: 40 amd64: 64-bit 41 386: 32-bit 42 darwin: macOS 43 linux: Tux 44 45 # Set to true, if you want all files in the archive to be in a single directory. 46 # If set to true and you extract the archive 'goreleaser_Linux_arm64.tar.gz', 47 # you get a folder 'goreleaser_Linux_arm64'. 48 # If set to false, all files are extracted separately. 49 # Default is false. 50 wrap_in_directory: true 51 52 # Archive format. Valid options are `tar.gz`, `zip` and `binary`. 53 # If format is `binary`, no archives are created and the binaries are instead uploaded directly. 54 # In that case name_template and the below specified files are ignored. 55 # Default is `tar.gz`. 56 format: zip 57 58 # Can be used to change the archive formats for specific GOOSs. 59 # Most common use case is to archive as zip on Windows. 60 # Default is empty. 61 format_overrides: 62 - goos: windows 63 format: zip 64 65 # Additional files/globs you want to add to the archive. 66 # Defaults are any files matching `LICENCE*`, `LICENSE*`, 67 # `README*` and `CHANGELOG*` (case-insensitive). 68 files: 69 - LICENSE.txt 70 - README.md 71 - CHANGELOG.md 72 - docs/* 73 - design/*.png 74 ``` 75 76 ## Passing environment variables to name_template 77 78 You can do that by using `{{ .Env.VARIABLE_NAME }}` in the template, for 79 example: 80 81 ```yaml 82 archive: 83 name_template: '{{.ProjectName}}-{{.Version}}-{{.Env.GOVERSION_NR}}' 84 ``` 85 86 Then you can run: 87 88 ```console 89 GOVERSION_NR=$(go version | awk '{print $3;}') goreleaser 90 ``` 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 archive: 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)