Updating the cheatsheet
[webi-installers/.git] / goreleaser / README.md
1 ---
2 title: goreleaser
3 homepage: https://goreleaser.com
4 tagline: |
5   goreleaser: Deliver Go binaries as fast and easily as possible
6 ---
7
8 ### Updating `goreleaser`
9
10 `webi goreleaser@stable`
11
12 Use the `@beta` tag for pre-releases.
13
14 ## Cheat Sheet
15
16 > `goreleaser` builds Go binaries for serveral platforms, creates a GitHub release
17 > and then pushes a Homebrew formula to a tap repository. All that wrapped in your
18 > favourite CI.
19
20 To create an example `.goreleaser.yaml` file, and test the configuration:
21
22 ```bash
23 goreleaser init
24 goreleaser --snapshot --skip-publish --rm-dist
25 ```
26
27 You'll need to export a `GITHUB_TOKEN` or `GITLAB_TOKEN` environment variable, which should 
28 contain a valid GitHub token with the `repo` scope or GitLab token with `api` scope. It will 
29 be used to deploy releases to your GitHub/GitLab repository. You can create a token
30 [here](https://github.com/settings/tokens/new) for GitHub or 
31 [here](https://gitlab.com/profile/personal_access_tokens) for GitLab.
32
33 ```bash
34 export GITHUB_TOKEN="YOUR_GITHUB_TOKEN"
35 ```
36
37 or
38
39 ```bash
40 export GITLAB_TOKEN="YOUR_GITLAB_TOKEN"
41 ```
42
43 GoReleaser will use the latest [Git tag](https://git-scm.com/book/en/v2/Git-Basics-Tagging) of your 
44 repository. Create a tag and push it to GitHub:
45
46 ```bash
47 git tag -a v0.1.0 -m "First release"
48 git push origin v0.1.0
49 ```
50
51 Now you can run GoReleaser at the root of your repository:
52
53 ```bash
54 goreleaser
55 ```
56
57 That's all! Check your GitHub/GitLab project's release page.
58
59 ### To cross-compile for Windows / Linux
60
61 ```bash
62 brew install mingw-w64
63 brew install FiloSottile/musl-cross/musl-cross
64 ```
65
66 ```bash
67 GOARCH=amd64 GOOS=darwin                              go build -o unarr_darwin cmd/unarr/unarr.go
68 GOARCH=amd64 GOOS=windows CC=x86_64-w64-mingw32-gcc   go build -o unarr.exe cmd/unarr/unarr.go
69 GOARCH=amd64 GOOS=linux   CC=x86_64-linux-musl-gcc    go build -o unarr_linux_amd64 cmd/unarr/unarr.go
70 ```
71
72 The linux in question would need the musl libs installed to run a musl bin
73
74 ```bash
75 sudo apt-get install -y musl
76 ```
77
78 ```bash
79 - builds:
80   - id: unarr-linux-x64
81     main: ./cmd/unarr/unarr.go
82     env:
83       - CGO_ENABLED=1
84       - CC=x86_64-linux-musl-gcc
85     flags:
86       - "-ldflags"
87       - '-extldflags "-static"'
88     goos:
89       - linux
90     goarch:
91       - amd64
92 ```