From 47e9361d4cb15d7a5a17a2446e205acd0af7618c Mon Sep 17 00:00:00 2001 From: SenorGrande Date: Sun, 4 Oct 2020 18:43:49 +1300 Subject: [PATCH] Updating the cheatsheet --- goreleaser/README.md | 73 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 67 insertions(+), 6 deletions(-) diff --git a/goreleaser/README.md b/goreleaser/README.md index afeb071..127dfa9 100644 --- a/goreleaser/README.md +++ b/goreleaser/README.md @@ -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 -- 2.25.1