Updating the cheatsheet
authorSenorGrande <clooneyjh@gmail.com>
Sun, 4 Oct 2020 05:43:49 +0000 (18:43 +1300)
committerSenorGrande <clooneyjh@gmail.com>
Sun, 4 Oct 2020 05:43:49 +0000 (18:43 +1300)
goreleaser/README.md

index afeb07131ba7b5d7b9669740165238d882450884..127dfa9bd75993b65fb39dc622442a49dc96df1c 100644 (file)
@@ -13,19 +13,80 @@ Use the `@beta` tag for pre-releases.
 
 ## Cheat Sheet
 
-> `goreleaser` doesn't exist and this text should have been replaced. It doesn't do
-> anything, but what it does is useful because it is; everybody knows it.
+> `goreleaser` builds Go binaries for serveral platforms, creates a GitHub release
+> and then pushes a Homebrew formula to a tap repository. All that wrapped in your
+> favourite CI.
 
-To run goreleaser:
+To create an example `.goreleaser.yaml` file, and test the configuration:
+
+```bash
+goreleaser init
+goreleaser --snapshot --skip-publish --rm-dist
+```
+
+You'll need to export 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.
+
+```bash
+export GITHUB_TOKEN="YOUR_GITHUB_TOKEN"
+```
+
+or
+
+```bash
+export GITLAB_TOKEN="YOUR_GITLAB_TOKEN"
+```
+
+GoReleaser will use 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:
+
+```bash
+git tag -a v0.1.0 -m "First release"
+git push origin v0.1.0
+```
+
+Now you can run GoReleaser at the root of your repository:
 
 ```bash
 goreleaser
 ```
 
-### Add Baz Highlighting
+That's all! Check your GitHub/GitLab project's release page.
+
+### To cross-compile for Windows / Linux
+
+```bash
+brew install mingw-w64
+brew install FiloSottile/musl-cross/musl-cross
+```
+
+```bash
+GOARCH=amd64 GOOS=darwin                              go build -o unarr_darwin cmd/unarr/unarr.go
+GOARCH=amd64 GOOS=windows CC=x86_64-w64-mingw32-gcc   go build -o unarr.exe cmd/unarr/unarr.go
+GOARCH=amd64 GOOS=linux   CC=x86_64-linux-musl-gcc    go build -o unarr_linux_amd64 cmd/unarr/unarr.go
+```
 
-To run goreleaser with both bar and baz highlighting turned on:
+The linux in question would need the musl libs installed to run a musl bin
 
 ```bash
-goreleaser --bar=baz
+sudo apt-get install -y musl
 ```
+
+```bash
+- builds:
+  - id: unarr-linux-x64
+    main: ./cmd/unarr/unarr.go
+    env:
+      - CGO_ENABLED=1
+      - CC=x86_64-linux-musl-gcc
+    flags:
+      - "-ldflags"
+      - '-extldflags "-static"'
+    goos:
+      - linux
+    goarch:
+      - amd64
+```
\ No newline at end of file