2017-09-10 22:07:28 +02:00
|
|
|
---
|
|
|
|
title: Quick Start
|
2018-04-25 07:20:12 +02:00
|
|
|
weight: 10
|
|
|
|
menu: true
|
2017-09-10 22:07:28 +02:00
|
|
|
---
|
|
|
|
|
2017-10-01 18:57:52 +02:00
|
|
|
In this example we will build, archive and release a Go project.
|
|
|
|
|
2017-09-10 22:07:28 +02:00
|
|
|
Create a GitHub repository and add a single main package:
|
|
|
|
|
|
|
|
```go
|
|
|
|
// main.go
|
|
|
|
package main
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
println("Ba dum, tss!")
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
By default GoReleaser will build the current directory, but you can change
|
2017-10-01 18:57:52 +02:00
|
|
|
the package path in the GoReleaser configuration file:
|
2017-09-10 22:07:28 +02:00
|
|
|
|
|
|
|
```yml
|
|
|
|
# .goreleaser.yml
|
|
|
|
# Build customization
|
|
|
|
builds:
|
|
|
|
- binary: drum-roll
|
|
|
|
goos:
|
|
|
|
- windows
|
|
|
|
- darwin
|
|
|
|
- linux
|
|
|
|
goarch:
|
|
|
|
- amd64
|
|
|
|
```
|
|
|
|
|
2017-10-01 18:57:52 +02:00
|
|
|
GoReleaser skips invalid GOOS/GOARCH combinations.
|
2017-09-10 22:07:28 +02:00
|
|
|
|
2017-10-01 18:57:52 +02:00
|
|
|
With the above configuration the name of all created binaries will be `drum-roll`
|
|
|
|
and GoReleaser will build one binary in 64bit architecture for each of the operating systems Windows, Linux and MacOS.
|
2017-09-10 22:07:28 +02:00
|
|
|
|
2017-10-01 18:57:52 +02:00
|
|
|
GoReleaser will then archive the resulting binaries of each OS/Arch pair into a
|
2017-09-10 22:07:28 +02:00
|
|
|
separate file. The default format is `{{.ProjectName}}_{{.Os}}_{{.Arch}}`.
|
2017-10-01 18:57:52 +02:00
|
|
|
You can change the archive's name and format. You can also replace the OS
|
2017-09-10 22:07:28 +02:00
|
|
|
and the Architecture with your own.
|
2017-10-01 18:57:52 +02:00
|
|
|
|
|
|
|
Another useful feature is to add additional files to the created archives:
|
2017-09-10 22:07:28 +02:00
|
|
|
|
|
|
|
```yml
|
|
|
|
# .goreleaser.yml
|
|
|
|
# Build customization
|
|
|
|
builds:
|
|
|
|
- main: main.go
|
|
|
|
binary: drum-roll
|
|
|
|
goos:
|
|
|
|
- windows
|
|
|
|
- darwin
|
|
|
|
- linux
|
|
|
|
goarch:
|
|
|
|
- amd64
|
|
|
|
# Archive customization
|
|
|
|
archive:
|
|
|
|
format: tar.gz
|
|
|
|
replacements:
|
|
|
|
amd64: 64-bit
|
|
|
|
darwin: macOS
|
|
|
|
linux: Tux
|
|
|
|
files:
|
|
|
|
- drum-roll.licence.txt
|
|
|
|
```
|
|
|
|
|
2017-10-01 18:57:52 +02:00
|
|
|
This configuration will generate `tar` archives, each containing an additional
|
|
|
|
file called `drum-roll.licence.txt`.
|
|
|
|
The archives will be located in the `dist` folder:
|
2017-09-10 22:07:28 +02:00
|
|
|
|
2017-12-10 19:17:29 +02:00
|
|
|
* `./dist/drum-roll_windows_64-bit.tar.gz`
|
|
|
|
* `./dist/drum-roll_macOS_64-bit.tar.gz`
|
|
|
|
* `./dist/drum-roll_Tux_64-bit.tar.gz`
|
2017-09-10 22:07:28 +02:00
|
|
|
|
2017-10-01 18:57:52 +02:00
|
|
|
Next, you need to export a `GITHUB_TOKEN` environment variable, which should contain a
|
|
|
|
GitHub token with the `repo` scope selected.
|
|
|
|
It will be used to deploy releases to your GitHub repository.
|
|
|
|
Create a token [here](https://github.com/settings/tokens/new).
|
2017-09-10 22:07:28 +02:00
|
|
|
|
|
|
|
```console
|
|
|
|
$ export GITHUB_TOKEN=`YOUR_TOKEN`
|
|
|
|
```
|
|
|
|
|
|
|
|
GoReleaser uses the latest
|
|
|
|
[Git tag](https://git-scm.com/book/en/v2/Git-Basics-Tagging) of your repository.
|
|
|
|
Create a tag and push it to GitHub:
|
|
|
|
|
|
|
|
```console
|
|
|
|
$ git tag -a v0.1.0 -m "First release"
|
|
|
|
$ git push origin v0.1.0
|
|
|
|
```
|
|
|
|
|
2017-09-28 21:16:43 +02:00
|
|
|
**Note**: We recommend the use of [semantic versioning](http://semver.org/). We
|
2017-09-10 22:07:28 +02:00
|
|
|
are not enforcing it though. We do remove the `v` prefix and then enforce
|
|
|
|
that the next character is a number. So, `v0.1.0` and `0.1.0` are virtually the
|
2017-10-01 18:57:52 +02:00
|
|
|
same and both are accepted, while `version0.1.0` is not.
|
2017-09-10 22:07:28 +02:00
|
|
|
|
2017-10-01 18:57:52 +02:00
|
|
|
If you don't want to create a tag yet, you can also create a release
|
|
|
|
based on the latest commit by using the `--snapshot` flag.
|
2017-09-10 22:07:28 +02:00
|
|
|
|
|
|
|
Now you can run GoReleaser at the root of your repository:
|
|
|
|
|
|
|
|
```console
|
|
|
|
$ goreleaser
|
|
|
|
```
|
|
|
|
|
2017-10-01 18:57:52 +02:00
|
|
|
That's all! Check your GitHub project's release page.
|
2017-09-10 22:07:28 +02:00
|
|
|
The release should look like this:
|
|
|
|
|
|
|
|
<a href="https://github.com/goreleaser/goreleaser/releases">
|
|
|
|
<img width="100%"
|
|
|
|
src="https://cloud.githubusercontent.com/assets/245435/23342061/fbcbd506-fc31-11e6-9d2b-4c1b776dee9c.png">
|
|
|
|
</a>
|