github.com/szyn/goreleaser@v0.76.1-0.20180517112710-333da09a1297/www/content/quick-start.md (about) 1 --- 2 title: Quick Start 3 weight: 10 4 menu: true 5 --- 6 7 In this example we will build, archive and release a Go project. 8 9 Create a GitHub repository and add a single main package: 10 11 ```go 12 // main.go 13 package main 14 15 func main() { 16 println("Ba dum, tss!") 17 } 18 ``` 19 20 By default GoReleaser will build the current directory, but you can change 21 the package path in the GoReleaser configuration file: 22 23 ```yml 24 # .goreleaser.yml 25 # Build customization 26 builds: 27 - binary: drum-roll 28 goos: 29 - windows 30 - darwin 31 - linux 32 goarch: 33 - amd64 34 ``` 35 36 GoReleaser skips invalid GOOS/GOARCH combinations. 37 38 With the above configuration the name of all created binaries will be `drum-roll` 39 and GoReleaser will build one binary in 64bit architecture for each of the operating systems Windows, Linux and MacOS. 40 41 GoReleaser will then archive the resulting binaries of each OS/Arch pair into a 42 separate file. The default format is `{{.ProjectName}}_{{.Os}}_{{.Arch}}`. 43 You can change the archive's name and format. You can also replace the OS 44 and the Architecture with your own. 45 46 Another useful feature is to add additional files to the created archives: 47 48 ```yml 49 # .goreleaser.yml 50 # Build customization 51 builds: 52 - main: main.go 53 binary: drum-roll 54 goos: 55 - windows 56 - darwin 57 - linux 58 goarch: 59 - amd64 60 # Archive customization 61 archive: 62 format: tar.gz 63 replacements: 64 amd64: 64-bit 65 darwin: macOS 66 linux: Tux 67 files: 68 - drum-roll.licence.txt 69 ``` 70 71 This configuration will generate `tar` archives, each containing an additional 72 file called `drum-roll.licence.txt`. 73 The archives will be located in the `dist` folder: 74 75 * `./dist/drum-roll_windows_64-bit.tar.gz` 76 * `./dist/drum-roll_macOS_64-bit.tar.gz` 77 * `./dist/drum-roll_Tux_64-bit.tar.gz` 78 79 Next, you need to export a `GITHUB_TOKEN` environment variable, which should contain a 80 GitHub token with the `repo` scope selected. 81 It will be used to deploy releases to your GitHub repository. 82 Create a token [here](https://github.com/settings/tokens/new). 83 84 ```console 85 $ export GITHUB_TOKEN=`YOUR_TOKEN` 86 ``` 87 88 GoReleaser uses the latest 89 [Git tag](https://git-scm.com/book/en/v2/Git-Basics-Tagging) of your repository. 90 Create a tag and push it to GitHub: 91 92 ```console 93 $ git tag -a v0.1.0 -m "First release" 94 $ git push origin v0.1.0 95 ``` 96 97 **Note**: We recommend the use of [semantic versioning](http://semver.org/). We 98 are not enforcing it though. We do remove the `v` prefix and then enforce 99 that the next character is a number. So, `v0.1.0` and `0.1.0` are virtually the 100 same and both are accepted, while `version0.1.0` is not. 101 102 If you don't want to create a tag yet, you can also create a release 103 based on the latest commit by using the `--snapshot` flag. 104 105 Now you can run GoReleaser at the root of your repository: 106 107 ```console 108 $ goreleaser 109 ``` 110 111 That's all! Check your GitHub project's release page. 112 The release should look like this: 113 114 <a href="https://github.com/goreleaser/goreleaser/releases"> 115 <img width="100%" 116 src="https://cloud.githubusercontent.com/assets/245435/23342061/fbcbd506-fc31-11e6-9d2b-4c1b776dee9c.png"> 117 </a>