2020-05-10 21:57:11 +02:00
# Quick Start
2017-09-10 22:07:28 +02:00
2019-03-25 01:10:30 +02:00
In this example we will build, archive and release a sample Go project.
2017-10-01 18:57:52 +02:00
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!")
}
```
2020-12-20 15:56:00 +02:00
Run `goreleaser init` to create an example `.goreleaser.yml` file:
2017-09-10 22:07:28 +02:00
2020-08-14 23:13:02 +02:00
```sh
goreleaser init
2018-07-21 15:33:59 +02:00
```
2017-10-01 18:57:52 +02:00
2020-07-23 19:31:02 +02:00
You can [customize ](/customization/ ) the generated `.goreleaser.yml` or leave
2020-07-13 10:37:55 +02:00
it as-is, it's up to you. It is best practice to check `.goreleaser.yml` into the source control.
2017-09-10 22:07:28 +02:00
2019-03-25 01:10:30 +02:00
You can test the configuration at any time by running GoReleaser with a few
extra parameters to not require a version tag, skip publishing to GitHub,
and remove any already-built files:
2019-02-06 19:14:38 +02:00
2020-08-14 23:13:02 +02:00
```sh
goreleaser --snapshot --skip-publish --rm-dist
2019-02-06 19:14:38 +02:00
```
2019-03-25 01:10:30 +02:00
If you are not using vgo or Go modules, then you will need to comment out the
before hooks in the generated config file or update them to match your setup
accordingly.
2019-02-06 19:14:38 +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
2020-05-10 23:59:21 +02:00
`builds` section. Check the [documentation ](/customization/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
2019-03-25 01:10:30 +02:00
the `archive` section, including releasing only the binaries and not creating
2020-05-10 23:59:21 +02:00
archives at all. Check the [documentation ](/customization/archive ) for more information.
2017-09-10 22:07:28 +02:00
2019-06-29 16:02:40 +02:00
You'll need to export either a `GITHUB_TOKEN` **or** `GITLAB_TOKEN` environment variable, which should
contain a valid GitHub token with the `repo` scope or GitLab token with `api` scope.
It will be used to deploy releases to your GitHub/GitLab repository.
You can create a token [here ](https://github.com/settings/tokens/new ) for GitHub or [here ](https://gitlab.com/profile/personal_access_tokens ) for GitLab.
2017-09-10 22:07:28 +02:00
2020-08-14 23:13:02 +02:00
```sh
export GITHUB_TOKEN="YOUR_GH_TOKEN"
```
or
```sh
export GITLAB_TOKEN="YOUR_GL_TOKEN"
2017-09-10 22:07:28 +02:00
```
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:
2020-08-14 23:13:02 +02:00
```sh
git tag -a v0.1.0 -m "First release"
git push origin v0.1.0
2017-09-10 22:07:28 +02:00
```
2020-05-10 21:57:11 +02:00
!!! info
2020-05-10 23:59:21 +02:00
Check if your tag adheres to [semantic versioning ](/limitations/semver ).
2017-09-10 22:07:28 +02:00
2020-02-20 20:39:42 +02:00
If you don't want to create a tag yet, you can also run GoReleaser without publishing
based on the latest commit by using the `--snapshot` flag:
2020-08-14 23:13:02 +02:00
```sh
goreleaser --snapshot
2020-02-20 20:39:42 +02:00
```
2017-09-10 22:07:28 +02:00
Now you can run GoReleaser at the root of your repository:
2020-08-14 23:13:02 +02:00
```sh
2021-01-21 06:04:16 +02:00
goreleaser release
2017-09-10 22:07:28 +02:00
```
2021-01-21 05:54:12 +02:00
That's all!
2017-09-10 22:07:28 +02:00
2021-01-21 05:54:12 +02:00
Check your GitHub project's releases page!
< a href = "https://github.com/goreleaser/example/releases" >
< figure >
< img src = "https://img.carlosbecker.dev/goreleaser-github.png" / >
< figcaption > Example release on GitHub.< / figcaption >
< / figure >
2017-09-10 22:07:28 +02:00
< / a >
2018-10-17 05:41:40 +02:00
2021-01-21 05:54:12 +02:00
Or, if you released to GitLab, check it out too!
< a href = "https://gitlab.com/goreleaser/example/-/releases" >
< figure >
< img src = "https://img.carlosbecker.dev/goreleaser-gitlab.png" / >
< figcaption > Example release on GitLab.< / figcaption >
< / figure >
2019-06-29 16:02:40 +02:00
< / a >
2020-05-11 14:35:58 +02:00
!!! note
2021-05-17 19:33:04 +02:00
Releasing to a private-hosted GitLab CE will only work for version `v12.9+` , due to dependencies
on [release ](https://docs.gitlab.com/ee/user/project/releases/index.html ) functionality
and [direct asset linking ](https://docs.gitlab.com/ee/user/project/releases/index.html#permanent-links-to-release-assets ).
2019-08-14 15:07:59 +02:00
2018-10-17 05:41:40 +02:00
## Dry run
If you want to test everything before doing a release "for real", you can
2020-05-15 16:19:20 +02:00
use the following techniques.
### Build-only Mode
Build command will build the project
2020-08-14 23:13:02 +02:00
```sh
goreleaser build
2020-05-15 16:19:20 +02:00
```
This can be useful as part of CI pipelines to verify the project builds
without errors for all build targets.
You can check the other options by running:
2020-08-14 23:13:02 +02:00
```sh
goreleaser build --help
2020-05-15 16:19:20 +02:00
```
### Release Flags
Use the `--skip-publish` flag to skip publishing:
2018-10-17 05:41:40 +02:00
2020-08-14 23:13:02 +02:00
```sh
goreleaser release --skip-publish
2018-10-17 05:41:40 +02:00
```
You can check the other options by running:
2020-08-14 23:13:02 +02:00
```sh
goreleaser --help
2018-10-17 05:41:40 +02:00
```
and
2020-08-14 23:13:02 +02:00
```sh
goreleaser release --help
2018-10-17 05:41:40 +02:00
```