1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-10 03:47:03 +02:00
goreleaser/www/content/quick-start.md

121 lines
2.8 KiB
Markdown
Raw Normal View History

2017-09-10 22:07:28 +02:00
---
title: Quick Start
weight: 10
menu: true
2017-09-10 22:07:28 +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!")
}
```
2018-07-21 15:33:59 +02:00
Run `goreleaser init` to create an example `.goreleaser.yaml` file:
2017-09-10 22:07:28 +02:00
2018-07-21 15:33:59 +02:00
```console
$ goreleaser init
2017-09-10 22:07:28 +02:00
2018-07-21 15:33:59 +02:00
• Generating .goreleaser.yml file
• config created; please edit accordingly to your needs file=.goreleaser.yml
```
2018-07-21 15:33:59 +02:00
The generated config file will look like this:
2017-09-10 22:07:28 +02:00
```yml
2018-07-21 15:33:59 +02:00
# This is an example goreleaser.yaml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
2017-09-10 22:07:28 +02:00
builds:
2018-07-21 15:33:59 +02:00
- env:
- CGO_ENABLED=0
2017-09-10 22:07:28 +02:00
archive:
replacements:
2018-07-21 15:33:59 +02:00
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
2017-09-10 22:07:28 +02:00
```
2018-07-21 15:33:59 +02:00
GoReleaser will build the binaries for your app for Windows, Linux and macOS,
both amd64 and i386 architectures. You can customize that by changing the
`builds` section. Check the [documentation](/build) for more information.
2017-09-10 22:07:28 +02:00
2018-07-21 15:33:59 +02:00
After building the binaries, GoReleaser will create an archive for each OS/Arch
pair into a separate file. You can customize several things by changing
the `archive` section. Check the [documentation](/archive) for more information.
2017-09-10 22:07:28 +02:00
2018-07-21 15:33:59 +02:00
You'll need to export a `GITHUB_TOKEN` environment variable, which should
contain a valid GitHub token with the `repo` scope.
It will be used to deploy releases to your GitHub repository.
2018-07-21 15:33:59 +02:00
You can create a token [here](https://github.com/settings/tokens/new).
2017-09-10 22:07:28 +02:00
```console
$ export GITHUB_TOKEN=`YOUR_TOKEN`
```
2018-07-21 15:33:59 +02:00
GoReleaser will use the latest
2017-09-10 22:07:28 +02:00
[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
```
2018-08-15 05:15:17 +02:00
> **Attention**: Check if your tag adheres to [semantic versioning](/semver).
2017-09-10 22:07:28 +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
```
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>
2018-10-17 05:41:40 +02:00
## Dry run
If you want to test everything before doing a release "for real", you can
use the `--skip-publish` flag, which will only build and package things:
```console
$ goreleaser release --skip-publish
```
You can check the other options by running:
```console
$ goreleaser --help
```
and
```console
$ goreleaser release --help
```