Skip to content

Commit

Permalink
chore: set up and document a publishing workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanbraun committed Sep 30, 2020
1 parent 970f54c commit e6a8c4a
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 19 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/release_build.yml
Original file line number Diff line number Diff line change
@@ -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 }}
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -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
40 changes: 40 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -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."

64 changes: 46 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -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).

0 comments on commit e6a8c4a

Please sign in to comment.