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