From 88745b89eec554b637b9e4f741078326c27e58ce Mon Sep 17 00:00:00 2001 From: kencx Date: Wed, 13 Jul 2022 14:57:34 +0800 Subject: [PATCH] ci: add goreleaser --- .github/workflows/test.yml | 29 ++++++++++++++++++++++++++++- .goreleaser.yaml | 27 +++++++++++++++++++++++++++ Makefile | 7 ++++++- README.md | 17 ++++++++--------- examples/tmux.yml | 4 ++-- main.go | 4 +--- 6 files changed, 72 insertions(+), 16 deletions(-) create mode 100644 .goreleaser.yaml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6faef55..11cdde6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,9 +1,11 @@ -name: Test +name: CI on: push: branches: - master + tags: + - "v*" pull_request: branches: - master @@ -37,3 +39,28 @@ jobs: - name: Run tests run: make test + + + release: + needs: [test] + if: startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + steps: + - name: Checkout codebase + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.18 + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + distribution: goreleaser + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..0cab725 --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,27 @@ +project_name: keyb +before: + hooks: + - go mod tidy +builds: + - env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + goarch: + - "arm64" + - "amd64" + - "386" + ldflags: + - "-s -w -X main.version={{ .Tag }}" +archives: + - name_template: "{{ .ProjectName }}-v{{ .Version }}-{{ .Os }}-{{ .Arch }}" + format: tar.gz + format_overrides: + - goos: windows + format: zip +checksum: + name_template: 'checksums.txt' +changelog: + skip: true diff --git a/Makefile b/Makefile index 1dfc39d..928fee1 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ binary = keyb version = $(shell git describe --tags) -ldflags = -ldflags "-s -w" +ldflags = -ldflags "-s -w -X main.version=${version}" .PHONY: help test clean snapshot build @@ -18,6 +18,11 @@ test: clean: if [ -f ${binary} ]; then rm keyb; fi go clean + rm -rf dist + +## snapshot: generate unversioned snapshot release +snapshot: + goreleaser release --snapshot ## build: build binary build: diff --git a/README.md b/README.md index 060cd95..17bd362 100644 --- a/README.md +++ b/README.md @@ -84,18 +84,17 @@ Prefixes are useful for applications with a common leading hotkey like tmux. key: Super + Return - name: tmux - prefix: ctrl + a + prefix: ctrl + b keybinds: - - name: split vertical - key: "|" - - name: split horizontal - key: "-" - - name: {next, prev} window - key: shift + {>, <} + - name: Create new window + key: c + - name: Prev, next window + key: Shift + {←, →} ignore_prefix: true ``` -Refer to the defaults provided in `examples` for more details. +Refer to the defaults provided in `examples` for more details. Multiline fields +are not supported at the moment. ### Search @@ -158,7 +157,7 @@ Both ANSI and hex color codes are supported. ## Similar Tools - [showkeys](https://github.com/adamharmansky/showkeys) offers a keybinding popup similar to awesomewm -- [cheat](https://github.com/cheat/cheat) is a CLI tool to view cheatsheets for +- [cheat](https://github.com/cheat/cheat) is a CLI alternative to view cheatsheets for commands and hotkeys for just about any topic - Refer to [shortcut-pages](https://github.com/mt-empty/shortcut-pages), [cheat/cheatsheets](https://github.com/cheat/cheatsheets) for more cheatsheets diff --git a/examples/tmux.yml b/examples/tmux.yml index b171b55..6e0f7ac 100644 --- a/examples/tmux.yml +++ b/examples/tmux.yml @@ -97,9 +97,9 @@ - name: "Transpose two letters (delete and paste)" key: "[q]" - name: "Move to the previous pane" - key: "[\\{]" + key: "[{]" - name: "Move to the next pane" - key: "[\\}]" + key: "[}]" - name: "Toggle between pane layouts" key: "[Space]" - name: "Resize pane (make taller)" diff --git a/main.go b/main.go index 7b0fd01..9938cb1 100644 --- a/main.go +++ b/main.go @@ -26,9 +26,7 @@ const ( ` ) -var ( - version = "v0.1.0" -) +var version string func main() { log.SetPrefix("keyb: ")