From e6a8c4ada48a864095bc756f008fba3f1df3be01 Mon Sep 17 00:00:00 2001 From: Bryan Braun Date: Wed, 30 Sep 2020 17:10:27 -0400 Subject: [PATCH] chore: set up and document a publishing workflow --- .github/workflows/release_build.yml | 34 +++++++++++++++ .gitignore | 8 +++- .goreleaser.yml | 40 ++++++++++++++++++ README.md | 64 +++++++++++++++++++++-------- 4 files changed, 127 insertions(+), 19 deletions(-) create mode 100644 .github/workflows/release_build.yml create mode 100644 .goreleaser.yml diff --git a/.github/workflows/release_build.yml b/.github/workflows/release_build.yml new file mode 100644 index 0000000..cc794a6 --- /dev/null +++ b/.github/workflows/release_build.yml @@ -0,0 +1,34 @@ +name: Release Go project + +on: + push: + tags: + - "*" # triggers a release whenever when we push new tag up to Github + +jobs: + build: + name: GoReleaser build + runs-on: ubuntu-latest + + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + with: + fetch-depth: 0 # See: https://goreleaser.com/ci/actions/ + + - name: Set up Go 1.14 + uses: actions/setup-go@v2 + with: + go-version: 1.14 + id: go + + # Creates a new release, including: + # - Publishing a new release at https://github.com/sparkbox/commit-colors/releases + # - Updates the homebrew tap at https://github.com/sparkbox/homebrew-commit-colors + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@master + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GH_COMMIT_COLORS_PUBLISH_TOKEN }} diff --git a/.gitignore b/.gitignore index 74c886a..adc8565 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,10 @@ -node_modules .vscode + +# Built output of go generate all-colors.go + +# Builds for local devlopment build + +# Folder for publishing binaries +dist diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..4a06a6a --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,40 @@ +# For details on this, see the docs at http://goreleaser.com +before: + hooks: + - go mod download + - go generate ./... +builds: + - dir: cmd + env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin +archives: + - replacements: + darwin: Darwin + linux: Linux + windows: Windows + 386: i386 + amd64: x86_64 +checksum: + name_template: 'checksums.txt' +snapshot: + name_template: "{{ .Tag }}-next" +changelog: + sort: asc + filters: + exclude: + - '^docs:' + - '^test:' +# Automatically publishes to sparkbox/homebrew-commit-colors +# See more details here: https://goreleaser.com/customization/homebrew/ +brews: + - tap: + owner: sparkbox + name: homebrew-commit-colors + dependencies: + homepage: "https://github.com/sparkbox/commit-colors" + description: "See a lovely color swatch in your terminal every time you author a commit." + diff --git a/README.md b/README.md index 442e618..4196e95 100644 --- a/README.md +++ b/README.md @@ -1,36 +1,64 @@ # Commit Colors -See a lovely color swatch in your terminal every time you author a commit. Here's what it looks like: +See a lovely color swatch in your terminal every time you author a commit. The hexadecimal color comes from the first six characters in your commit ID. Here's what it looks like: ![animated gif demonstrating commit colors](https://raw.githubusercontent.com/sparkbox/commit-colors/master/demo.gif) -The hexadecimal color comes from the first six characters in your commit hash. +Commit colors is written in Go, and is usable on Mac, Windows, and Linux. *Note: commit-colors 1.0.0 was written in JavaScript and [distributed on npm](https://www.npmjs.com/package/@sparkbox/commit-colors). For instructions on that version of the project, see [the v1 README](https://github.com/sparkbox/commit-colors/tree/76a6b46fed76aeb5e1c813d86ead5185ee1e5cc1).* -## Installing +## Installation -1. Install the package with homebrew: +**Using Homebrew** - ```bash - brew tap sparkbox/commit-colors - brew install commit-colors - ``` +```bash +brew install sparkbox/commit-colors/commit-colors +``` -2. Set up a post-commit hook. Options include: +**Direct Download** - **The manual way** +1. Browse to [the list of releases](https://github.com/sparkbox/commit-colors/releases), and download the package that corresponds to your system (Mac, Windows or Linux). +2. Move the executable to a location on [your PATH](https://superuser.com/a/284351/193516) ([like `/usr/local/bin`](https://superuser.com/q/7150/193516), for example). - Copy/paste the following text into a post-commit hook: +Once installed, you can do a quick test in the terminal: - ```bash - #!/bin/bash - commit-colors $(git rev-parse HEAD) - ``` +```bash +commit-colors 123ADD5db8d67ba9621eb5d6765ffdef4c24077a +``` - In other words, put the above code in a file named `post-commit` at the location `.git/hooks/post-commit` in your git project of choice. [Make sure this file is executable](https://stackoverflow.com/a/14208849/1154642). If you want this hook to run on all your repos, [see how to do that here](https://stackoverflow.com/q/2293498/1154642). +## Commit Hooks Setup - **Using a Git Hooks manager** +**Option 1: Create the hook by hand** + +Copy/paste the following text into a post-commit hook: + +```bash +#!/bin/bash +commit-colors $(git rev-parse HEAD) +``` + +In other words, put the above code in a file named `post-commit` at the location `.git/hooks/post-commit` in your git project of choice. [Make sure this file is executable](https://stackoverflow.com/a/14208849/1154642). If you want this hook to run on all your repos, [see how to do that here](https://stackoverflow.com/q/2293498/1154642). + +**Option 2: Use a Git Hooks manager** + +See [this list of tools for managing git hooks](https://github.com/aitemr/awesome-git-hooks#tools). + +Whatever tool you use, this is the command you'll want it to run: `commit-colors $(git rev-parse HEAD)` + +## For Maintainers + +### Publishing + +1. Create a new tag, and push it up to Github: + +```bash +git tag -a 2.0.0 -m "Version 2 release" +git push origin 2.0.0 +``` + +2. The Github Action handles the rest! +- The action publishes [a Github release](https://github.com/sparkbox/commit-colors/releases) and a [homebrew update](https://github.com/sparkbox/homebrew-commit-colors). +- Additional publishing settings can be found in `goreleaser.yml` - See [this list of tools for managing git hooks](https://github.com/aitemr/awesome-git-hooks#tools).