Skip to content

Commit e6a8c4a

Browse files
committed
chore: set up and document a publishing workflow
1 parent 970f54c commit e6a8c4a

File tree

4 files changed

+127
-19
lines changed

4 files changed

+127
-19
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Release Go project
2+
3+
on:
4+
push:
5+
tags:
6+
- "*" # triggers a release whenever when we push new tag up to Github
7+
8+
jobs:
9+
build:
10+
name: GoReleaser build
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Check out code into the Go module directory
15+
uses: actions/checkout@v2
16+
with:
17+
fetch-depth: 0 # See: https://goreleaser.com/ci/actions/
18+
19+
- name: Set up Go 1.14
20+
uses: actions/setup-go@v2
21+
with:
22+
go-version: 1.14
23+
id: go
24+
25+
# Creates a new release, including:
26+
# - Publishing a new release at https://github.com/sparkbox/commit-colors/releases
27+
# - Updates the homebrew tap at https://github.com/sparkbox/homebrew-commit-colors
28+
- name: Run GoReleaser
29+
uses: goreleaser/goreleaser-action@master
30+
with:
31+
version: latest
32+
args: release --rm-dist
33+
env:
34+
GITHUB_TOKEN: ${{ secrets.GH_COMMIT_COLORS_PUBLISH_TOKEN }}

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
node_modules
21
.vscode
2+
3+
# Built output of go generate
34
all-colors.go
5+
6+
# Builds for local devlopment
47
build
8+
9+
# Folder for publishing binaries
10+
dist

.goreleaser.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# For details on this, see the docs at http://goreleaser.com
2+
before:
3+
hooks:
4+
- go mod download
5+
- go generate ./...
6+
builds:
7+
- dir: cmd
8+
env:
9+
- CGO_ENABLED=0
10+
goos:
11+
- linux
12+
- windows
13+
- darwin
14+
archives:
15+
- replacements:
16+
darwin: Darwin
17+
linux: Linux
18+
windows: Windows
19+
386: i386
20+
amd64: x86_64
21+
checksum:
22+
name_template: 'checksums.txt'
23+
snapshot:
24+
name_template: "{{ .Tag }}-next"
25+
changelog:
26+
sort: asc
27+
filters:
28+
exclude:
29+
- '^docs:'
30+
- '^test:'
31+
# Automatically publishes to sparkbox/homebrew-commit-colors
32+
# See more details here: https://goreleaser.com/customization/homebrew/
33+
brews:
34+
- tap:
35+
owner: sparkbox
36+
name: homebrew-commit-colors
37+
dependencies:
38+
homepage: "https://github.com/sparkbox/commit-colors"
39+
description: "See a lovely color swatch in your terminal every time you author a commit."
40+

README.md

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,64 @@
11
# Commit Colors
22

3-
See a lovely color swatch in your terminal every time you author a commit. Here's what it looks like:
3+
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:
44

55
![animated gif demonstrating commit colors](https://raw.githubusercontent.com/sparkbox/commit-colors/master/demo.gif)
66

7-
The hexadecimal color comes from the first six characters in your commit hash.
7+
Commit colors is written in Go, and is usable on Mac, Windows, and Linux.
88

99
*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).*
1010

11-
## Installing
11+
## Installation
1212

13-
1. Install the package with homebrew:
13+
**Using Homebrew**
1414

15-
```bash
16-
brew tap sparkbox/commit-colors
17-
brew install commit-colors
18-
```
15+
```bash
16+
brew install sparkbox/commit-colors/commit-colors
17+
```
1918

20-
2. Set up a post-commit hook. Options include:
19+
**Direct Download**
2120

22-
**The manual way**
21+
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).
22+
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).
2323

24-
Copy/paste the following text into a post-commit hook:
24+
Once installed, you can do a quick test in the terminal:
2525

26-
```bash
27-
#!/bin/bash
28-
commit-colors $(git rev-parse HEAD)
29-
```
26+
```bash
27+
commit-colors 123ADD5db8d67ba9621eb5d6765ffdef4c24077a
28+
```
3029

31-
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).
30+
## Commit Hooks Setup
3231

33-
**Using a Git Hooks manager**
32+
**Option 1: Create the hook by hand**
33+
34+
Copy/paste the following text into a post-commit hook:
35+
36+
```bash
37+
#!/bin/bash
38+
commit-colors $(git rev-parse HEAD)
39+
```
40+
41+
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).
42+
43+
**Option 2: Use a Git Hooks manager**
44+
45+
See [this list of tools for managing git hooks](https://github.com/aitemr/awesome-git-hooks#tools).
46+
47+
Whatever tool you use, this is the command you'll want it to run: `commit-colors $(git rev-parse HEAD)`
48+
49+
## For Maintainers
50+
51+
### Publishing
52+
53+
1. Create a new tag, and push it up to Github:
54+
55+
```bash
56+
git tag -a 2.0.0 -m "Version 2 release"
57+
git push origin 2.0.0
58+
```
59+
60+
2. The Github Action handles the rest!
61+
- The action publishes [a Github release](https://github.com/sparkbox/commit-colors/releases) and a [homebrew update](https://github.com/sparkbox/homebrew-commit-colors).
62+
- Additional publishing settings can be found in `goreleaser.yml`
3463

35-
See [this list of tools for managing git hooks](https://github.com/aitemr/awesome-git-hooks#tools).
3664

0 commit comments

Comments
 (0)