Skip to content

Commit 5a1eafc

Browse files
committed
feat: ci & release actions
1 parent 46b61b0 commit 5a1eafc

File tree

7 files changed

+90
-4
lines changed

7 files changed

+90
-4
lines changed

.github/workflows/ci.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: CI
2+
on: [push]
3+
jobs:
4+
build:
5+
runs-on: ubuntu-16.04
6+
name: Build & Test
7+
steps:
8+
- uses: actions/checkout@v2
9+
- name: Setup go
10+
uses: actions/setup-go@v1
11+
with:
12+
go-version: "1.13"
13+
- run: go test -coverprofile=coverage.txt -covermode=atomic ./...
14+
- uses: codecov/codecov-action@v1

.github/workflows/release.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: goreleaser
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
8+
jobs:
9+
goreleaser:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v2
14+
- name: Unshallow
15+
run: git fetch --prune --unshallow
16+
- name: Set up Go
17+
uses: actions/setup-go@v2
18+
with:
19+
go-version: 1.14
20+
- name: Run GoReleaser
21+
uses: goreleaser/goreleaser-action@v2
22+
with:
23+
version: latest
24+
args: release --rm-dist
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GH_PAT }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist
2+
TODO*

.goreleaser.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# This is an example goreleaser.yaml file with some sane defaults.
2+
# Make sure to check the documentation at http://goreleaser.com
3+
before:
4+
hooks:
5+
- go mod download
6+
builds:
7+
- env:
8+
- CGO_ENABLED=0
9+
goos:
10+
- linux
11+
- darwin
12+
- windows
13+
ignore:
14+
- goos: darwin
15+
goarch: 386
16+
archives:
17+
- name_template: "{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}"
18+
replacements:
19+
darwin: mac
20+
386: i386
21+
amd64: x86_64
22+
format_overrides:
23+
- goos: windows
24+
format: zip
25+
brews:
26+
- github:
27+
owner: danielgtaylor
28+
name: homebrew-restish
29+
homepage: https://rest.sh/
30+
description: Restish is a CLI for interacting with REST-ish HTTP APIs with some nice features built-in.
31+
checksum:
32+
name_template: "checksums.txt"
33+
snapshot:
34+
name_template: "{{ .Tag }}-next"
35+
changelog:
36+
sort: asc
37+
filters:
38+
exclude:
39+
- "^docs:"
40+
- "^test:"

cli/cli.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ func generic(method string, addr string, args []string) {
9090
}
9191

9292
// Init will set up the CLI.
93-
func Init(name string) {
93+
func Init(name string, version string) {
9494
initConfig(name, "")
9595
initCache(name)
9696

@@ -123,7 +123,7 @@ func Init(name string) {
123123
Root = &cobra.Command{
124124
Use: filepath.Base(os.Args[0]),
125125
Long: "A generic client for REST-ish APIs <https://rest.sh/>",
126-
Version: "0.1",
126+
Version: version,
127127
Example: fmt.Sprintf(` # Get a URI
128128
$ %s google.com
129129

cli/cli_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212

1313
func run(cmd string) string {
1414
viper.Set("nocolor", true)
15-
Init("test")
15+
Init("test", "1.0.0'")
1616
AddContentType("application/json", 1, JSON{})
1717

1818
capture := &strings.Builder{}

main.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ import (
66
"github.com/danielgtaylor/restish/openapi"
77
)
88

9+
var version string = "dev"
10+
var commit string
11+
var date string
12+
913
func main() {
10-
cli.Init("restish")
14+
cli.Init("restish", version)
1115

1216
// Register content encodings
1317
cli.AddEncoding("gzip", &cli.GzipEncoding{})

0 commit comments

Comments
 (0)