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

119 lines
3.4 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
---
2019-03-25 01:10:30 +02:00
In this example we will build, archive and release a sample 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
2019-03-25 01:10:30 +02:00
```sh
2018-07-21 15:33:59 +02:00
$ 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
```
2019-03-25 01:10:30 +02:00
You can [customize](/customization) the generated `.goreleaser.yml` or leave
it as-is, it's up to you.
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-03-25 01:10:30 +02:00
```sh
$ goreleaser --snapshot --skip-publish --rm-dist
```
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.
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
2019-03-25 01:10:30 +02:00
the `archive` section, including releasing only the binaries and not creating
archives at all. Check the [documentation](/archive) for more information.
2017-09-10 22:07:28 +02:00
feat: add gitlab for releases (#1038) * outlines gitlab client integration * makes client parameter more explicit * adds gitlab url to config * changes releaseID to string to adapt to gitlab * updates to latest gitlab client lib 0.18 * fixes copy paster in gitlab upload func * fixes gitlab typo in config * adds gitlab token to env and context * release now uses the client factory method * skips brew pipe if it is not a github release * add github tokentype to publish tests * skips scoop pipe if it is not a github release * corrects brew skip msg * adds gitlab token to main test * adds gitlab to release docs * validates config and errors accordingly * adapt release pipe name to include gitlab * fixes gitlab client after testing * moves not-configured brew and scoop pipe checks as first check * adds more debug to gitlab client * adapts changelog generation for gitlab markdown * adds debug log for gitlab changelog * env needs to run before changelog pipe * moves gitlab default download url to default pipe * moves multiple releases check to from config to release pipe * release differs now for github and gitlab * adds debug gitlab release update msgs * moves env pipe as second after before because it determines the token type other pipes depend on * adaptes error check on gitlab release creation * Revert "adaptes error check on gitlab release creation" This reverts commit 032024571c76140f8e2207ee01cc08088f37594b. * simplifies gitlab client logic. removes comments * skips tls verification for gitlab client if specified in config * updates the docs * adds clarification that brew and scoop are not supported if it is a gitlab release * fixes copy paster in release.md * adds missing blob pipe in defaults and publish due to missing in merge * updates comment in gitlab client
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
2019-03-25 01:10:30 +02:00
```sh
feat: add gitlab for releases (#1038) * outlines gitlab client integration * makes client parameter more explicit * adds gitlab url to config * changes releaseID to string to adapt to gitlab * updates to latest gitlab client lib 0.18 * fixes copy paster in gitlab upload func * fixes gitlab typo in config * adds gitlab token to env and context * release now uses the client factory method * skips brew pipe if it is not a github release * add github tokentype to publish tests * skips scoop pipe if it is not a github release * corrects brew skip msg * adds gitlab token to main test * adds gitlab to release docs * validates config and errors accordingly * adapt release pipe name to include gitlab * fixes gitlab client after testing * moves not-configured brew and scoop pipe checks as first check * adds more debug to gitlab client * adapts changelog generation for gitlab markdown * adds debug log for gitlab changelog * env needs to run before changelog pipe * moves gitlab default download url to default pipe * moves multiple releases check to from config to release pipe * release differs now for github and gitlab * adds debug gitlab release update msgs * moves env pipe as second after before because it determines the token type other pipes depend on * adaptes error check on gitlab release creation * Revert "adaptes error check on gitlab release creation" This reverts commit 032024571c76140f8e2207ee01cc08088f37594b. * simplifies gitlab client logic. removes comments * skips tls verification for gitlab client if specified in config * updates the docs * adds clarification that brew and scoop are not supported if it is a gitlab release * fixes copy paster in release.md * adds missing blob pipe in defaults and publish due to missing in merge * updates comment in gitlab client
2019-06-29 16:02:40 +02:00
$ export GITHUB_TOKEN=`YOUR_GH_TOKEN`
# or
$ 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:
2019-03-25 01:10:30 +02:00
```sh
2017-09-10 22:07:28 +02:00
$ 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
feat: add gitlab for releases (#1038) * outlines gitlab client integration * makes client parameter more explicit * adds gitlab url to config * changes releaseID to string to adapt to gitlab * updates to latest gitlab client lib 0.18 * fixes copy paster in gitlab upload func * fixes gitlab typo in config * adds gitlab token to env and context * release now uses the client factory method * skips brew pipe if it is not a github release * add github tokentype to publish tests * skips scoop pipe if it is not a github release * corrects brew skip msg * adds gitlab token to main test * adds gitlab to release docs * validates config and errors accordingly * adapt release pipe name to include gitlab * fixes gitlab client after testing * moves not-configured brew and scoop pipe checks as first check * adds more debug to gitlab client * adapts changelog generation for gitlab markdown * adds debug log for gitlab changelog * env needs to run before changelog pipe * moves gitlab default download url to default pipe * moves multiple releases check to from config to release pipe * release differs now for github and gitlab * adds debug gitlab release update msgs * moves env pipe as second after before because it determines the token type other pipes depend on * adaptes error check on gitlab release creation * Revert "adaptes error check on gitlab release creation" This reverts commit 032024571c76140f8e2207ee01cc08088f37594b. * simplifies gitlab client logic. removes comments * skips tls verification for gitlab client if specified in config * updates the docs * adds clarification that brew and scoop are not supported if it is a gitlab release * fixes copy paster in release.md * adds missing blob pipe in defaults and publish due to missing in merge * updates comment in gitlab client
2019-06-29 16:02:40 +02:00
based on the latest commit by using the `--snapshot` flag. (*Note*: ony GitHub supports snapshots)
2017-09-10 22:07:28 +02:00
Now you can run GoReleaser at the root of your repository:
2019-03-25 01:10:30 +02:00
```sh
2017-09-10 22:07:28 +02:00
$ 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
feat: add gitlab for releases (#1038) * outlines gitlab client integration * makes client parameter more explicit * adds gitlab url to config * changes releaseID to string to adapt to gitlab * updates to latest gitlab client lib 0.18 * fixes copy paster in gitlab upload func * fixes gitlab typo in config * adds gitlab token to env and context * release now uses the client factory method * skips brew pipe if it is not a github release * add github tokentype to publish tests * skips scoop pipe if it is not a github release * corrects brew skip msg * adds gitlab token to main test * adds gitlab to release docs * validates config and errors accordingly * adapt release pipe name to include gitlab * fixes gitlab client after testing * moves not-configured brew and scoop pipe checks as first check * adds more debug to gitlab client * adapts changelog generation for gitlab markdown * adds debug log for gitlab changelog * env needs to run before changelog pipe * moves gitlab default download url to default pipe * moves multiple releases check to from config to release pipe * release differs now for github and gitlab * adds debug gitlab release update msgs * moves env pipe as second after before because it determines the token type other pipes depend on * adaptes error check on gitlab release creation * Revert "adaptes error check on gitlab release creation" This reverts commit 032024571c76140f8e2207ee01cc08088f37594b. * simplifies gitlab client logic. removes comments * skips tls verification for gitlab client if specified in config * updates the docs * adds clarification that brew and scoop are not supported if it is a gitlab release * fixes copy paster in release.md * adds missing blob pipe in defaults and publish due to missing in merge * updates comment in gitlab client
2019-06-29 16:02:40 +02:00
Or check your GitLab project's release page.
The release should also look like this:
<a href="https://gitlab.com/mavogel/release-testing/-/releases">
<img width="100%"
src="https://user-images.githubusercontent.com/8409778/59390011-55fcdf80-8d70-11e9-840f-c568ddc0e965.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:
2019-03-25 01:10:30 +02:00
```sh
2018-10-17 05:41:40 +02:00
$ goreleaser release --skip-publish
```
You can check the other options by running:
2019-03-25 01:10:30 +02:00
```sh
2018-10-17 05:41:40 +02:00
$ goreleaser --help
```
and
2019-03-25 01:10:30 +02:00
```sh
2018-10-17 05:41:40 +02:00
$ goreleaser release --help
```