Skip to content

Commit

Permalink
build: 🍻 introduce mostly automated releases
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostsquad committed Aug 9, 2020
1 parent f14e4de commit 10e2e82
Show file tree
Hide file tree
Showing 12 changed files with 238 additions and 39 deletions.
56 changes: 56 additions & 0 deletions .chglog/CHANGELOG.tpl.md
@@ -0,0 +1,56 @@
{{ if .Versions -}}
<a name="unreleased"></a>
## [Unreleased]

{{ if .Unreleased.CommitGroups -}}
{{ range .Unreleased.CommitGroups -}}
### {{ .Title }}
{{ range .Commits -}}
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
{{ end }}
{{ end -}}
{{ end -}}
{{ end -}}

{{ range .Versions }}
<a name="{{ .Tag.Name }}"></a>
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]{{ else }}{{ .Tag.Name }}{{ end }} - {{ datetime "2006-01-02" .Tag.Date }}
{{ range .CommitGroups -}}
### {{ .Title }}
{{ range .Commits -}}
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
{{ end }}
{{ end -}}

{{- if .RevertCommits -}}
### Reverts
{{ range .RevertCommits -}}
- {{ .Revert.Header }}
{{ end }}
{{ end -}}

{{- if .MergeCommits -}}
### Pull Requests
{{ range .MergeCommits -}}
- {{ .Header }}
{{ end }}
{{ end -}}

{{- if .NoteGroups -}}
{{ range .NoteGroups -}}
### {{ .Title }}
{{ range .Notes }}
{{ .Body }}
{{ end }}
{{ end -}}
{{ end -}}
{{ end -}}

{{- if .Versions }}
[Unreleased]: {{ .Info.RepositoryURL }}/compare/{{ $latest := index .Versions 0 }}{{ $latest.Tag.Name }}...HEAD
{{ range .Versions -}}
{{ if .Tag.Previous -}}
[{{ .Tag.Name }}]: {{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}
{{ end -}}
{{ end -}}
{{ end -}}
27 changes: 27 additions & 0 deletions .chglog/config.yml
@@ -0,0 +1,27 @@
style: github
template: CHANGELOG.tpl.md
info:
title: CHANGELOG
repository_url: https://github.com/cakehappens/seaworthy
options:
commits:
# filters:
# Type:
# - sparkles
# - bug
# - zap
# - recycle
commit_groups:
# title_maps:
# sparkles: Features
# bug: Bug Fixes
# zap: Performance Improvements
# recycle: Code Refactoring
header:
pattern: "^:(\\w*)\\:\\s(.*)$"
pattern_maps:
- Type
- Subject
notes:
keywords:
- BREAKING CHANGE
28 changes: 28 additions & 0 deletions .github/workflows/release.yml
@@ -0,0 +1,28 @@
# build binaries and add to release - see
# https://github.com/goreleaser/goreleaser-action
name: release

on:
push:
tags:
- '*'

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.14
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70 changes: 35 additions & 35 deletions .github/workflows/tests.yml
Expand Up @@ -2,14 +2,14 @@ name: tests
on:
push:
paths:
- '**.go'
- 'go.mod'
- 'go.sum'
- '.github/workflows/tests.yml'
- 'pkg/**'
- 'cmd/**'
- '.pre-commit-config.yaml'
- '.golangci.yml'
- '**.go'
- 'go.mod'
- 'go.sum'
- '.github/workflows/tests.yml'
- 'pkg/**'
- 'cmd/**'
- '.pre-commit-config.yaml'
- '.golangci.yml'
pull_request: {}
jobs:
test:
Expand All @@ -19,33 +19,33 @@ jobs:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Install dependencies
run: |
make dl
- name: Run Unit tests
run: |
make cover
- name: Send coverage
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: coverage.out
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
- name: Checkout code
uses: actions/checkout@v2
- name: Install dependencies
run: |
make dl
- name: Run Unit tests
run: |
make cover
- name: Send coverage
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: coverage.out
linting:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.14.x
- name: Checkout code
uses: actions/checkout@v2
- name: Install tools
run: |
make tools
- uses: actions/setup-python@v1
- uses: pre-commit/action@v2.0.0
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.14.x
- name: Checkout code
uses: actions/checkout@v2
- name: Install tools
run: |
make tools
- uses: actions/setup-python@v1
- uses: pre-commit/action@v2.0.0
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -15,6 +15,7 @@
vendor/

tmp/
dist/

# Built Binary
/seaworthy
31 changes: 31 additions & 0 deletions .goreleaser.yml
@@ -0,0 +1,31 @@
# Make sure to check the documentation at http://goreleaser.com
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarch:
- amd64
id: seaworthy
main: ./cmd/seaworthy
binary: seaworthy
archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
checksum:
name_template: 'checksums.txt'
#signs:
# - cmd: gpg2
# artifacts: all
# args: ["-u", "1C08DB44DEC7CAFC", "--output", "${signature}", "--detach-sign", "${artifact}"]
release:
prerelease: auto
draft: true
changelog:
skip: true
8 changes: 8 additions & 0 deletions CHANGELOG.md
@@ -0,0 +1,8 @@
<a name="unreleased"></a>
## [Unreleased]


<a name="v0.0.1"></a>
## v0.0.1 - 2020-08-09

[Unreleased]: https://github.com/cakehappens/seaworthy/compare/v0.0.1...HEAD
12 changes: 9 additions & 3 deletions Makefile
Expand Up @@ -23,12 +23,13 @@ vet:

.PHONY: build
build: clean
go build -o ./seaworthy ./cmd/seaworthy
chmod +x ./seaworthy
mkdir -p ./dist
go build -o ./dist/seaworthy ./cmd/seaworthy
chmod +x ./dist/seaworthy

.PHONY: clean
clean:
rm -f ./seaworthy
rm -fr ./dist

.PHONY: test
test:
Expand All @@ -45,3 +46,8 @@ pre-commit.install:

pre-commit.run:
pre-commit run --all-files

release: clean
@echo "--skip-publish, as we will use github actions to do this"
git-chglog -o CHANGELOG.md
goreleaser --snapshot --skip-publish --rm-dist --release-notes CHANGELOG.md
9 changes: 8 additions & 1 deletion cmd/seaworthy/main.go
Expand Up @@ -21,6 +21,13 @@ import (
_ "github.com/cakehappens/seaworthy/pkg/kubernetes/health/install"
)

var (
version = "dev"
commit = "none"
date = "unknown"
builtBy = "unknown"
)

const binaryName = "seaworthy"

// NewSeaworthyCommand returns the root command for the CLI
Expand All @@ -33,7 +40,7 @@ func NewSeaworthyCommand(in io.Reader, out, err io.Writer) *cobra.Command {
return nil
}

fmt.Println("main")
fmt.Printf("seaworthy %s, commit %s, built at %s by %s", version, commit, date, builtBy)

fmt.Printf("running: %s\n", args)

Expand Down
5 changes: 5 additions & 0 deletions go.mod
Expand Up @@ -4,6 +4,7 @@ go 1.14

require (
github.com/ghostsquad/go-timejumper v0.1.2
github.com/git-chglog/git-chglog v0.0.0-20200414013904-db796966b373
github.com/golangci/golangci-lint v1.30.0
github.com/gookit/color v1.2.7
github.com/goreleaser/goreleaser v0.141.0
Expand All @@ -16,8 +17,12 @@ require (
github.com/spf13/viper v1.7.0
github.com/stretchr/testify v1.6.1
github.com/theckman/yacspin v0.8.0
github.com/tsuyoshiwada/go-gitcmd v0.0.0-20180205145712-5f1f5f9475df // indirect
github.com/urfave/cli v1.22.4 // indirect
golang.org/x/sys v0.0.0-20200808120158-1030fc2bf1d9
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
gopkg.in/AlecAivazis/survey.v1 v1.8.8 // indirect
gopkg.in/kyokomi/emoji.v1 v1.5.1 // indirect
gotest.tools/gotestsum v0.4.0
k8s.io/api v0.18.6
k8s.io/apimachinery v0.18.6
Expand Down

0 comments on commit 10e2e82

Please sign in to comment.