Add release tools, GoReleaser config and chglog config

This commit is contained in:
James Mills 2022-03-20 08:10:05 +10:00
parent 345d3ee685
commit f926981e02
No known key found for this signature in database
GPG Key ID: AC4C014F1440EBD6
6 changed files with 131 additions and 28 deletions

22
.chglog/CHANGELOG.tpl.md Executable file
View File

@ -0,0 +1,22 @@
{{ range .Versions }}
<a name="{{ .Tag.Name }}"></a>
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]({{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}){{ else }}{{ .Tag.Name }}{{ end }} ({{ datetime "2006-01-02" .Tag.Date }})
{{ range .CommitGroups -}}
### {{ .Title }}
{{ range .Commits -}}
* {{ .Subject }}
{{ end }}
{{ end -}}
{{- if .NoteGroups -}}
{{ range .NoteGroups -}}
### {{ .Title }}
{{ range .Notes }}
{{ .Body }}
{{ end }}
{{ end -}}
{{ end -}}
{{ end -}}

37
.chglog/config.yml Executable file
View File

@ -0,0 +1,37 @@
---
style: Github
template: CHANGELOG.tpl.md
info:
title: CHANGELOG
repository_url: https://git.mills.io/prologic/msgbus
options:
commits:
filters:
Type:
- Add
- Fix
- Update
- Document
commit_groups:
title_maps:
Add: Features
Update: Updates
Fix: Bug Fixes
Document: Documentation
header:
pattern: "^((\\w+)\\s.*)$"
pattern_maps:
- Subject
- Type
refs:
actions:
- Closes
- Fixes
reverts:
pattern: "^Revert \"([\\s\\S]*)\"$"
pattern_maps:
- Header
notes:
keywords:
- NOTE
- BREAKING CHANGE

2
.gitignore vendored
View File

@ -3,6 +3,8 @@
*.swp
*.prof
**/.DS_Store
/dist
/coverage.txt
/msgbus

View File

@ -1,41 +1,51 @@
---
builds:
-
main: ./cmd/msgbusd/
binary: msgbusd
flags: -tags "static_build"
ldflags: -w -X msgbus.Version={{.Version}} -X msgbus.Commit={{.Commit}}
env:
- CGO_ENABLED=0
goos:
- darwin
- freebsd
- linux
goarch:
- i386
- amd64
- arm
- amd64
goarm:
- 6
- 7
-
main: ./cmd/msgbus/
- id: msgbus
binary: msgbus
main: ./cmd/msgbus
flags: -tags "static_build"
ldflags: -w -X msgbus.Version={{.Version}} -X msgbus.Commit={{.Commit}}
ldflags: >-
-w
-X git.mills.io/msgbus.Version={{.Version}}
-X git.mills.io/msgbus.Commit={{.Commit}}
env:
- CGO_ENABLED=0
goos:
- windows
- darwin
- freebsd
- linux
goarch:
- i386
- amd64
- arm
- amd64
- arm64
goarm:
- 6
- 7
sign:
artifacts: checksum
- id: msgbusd
binary: msgbusd
main: ./cmd/msgbusd
flags: -tags "static_build"
ldflags: >-
-w
-X git.mills.io/msgbus.Version={{.Version}}
-X git.mills.io/msgbus.Commit={{.Commit}}
env:
- CGO_ENABLED=0
goos:
- windows
- darwin
- linux
goarch:
- amd64
- arm64
goarm:
- 6
- 7
signs:
- artifacts: checksum
release:
gitea:
owner: prologic
name: msgbus
draft: false
gitea_urls:
api: https://git.mills.io/api/v1/

0
CHANGELOG.md Normal file
View File

32
tools/release.sh Executable file
View File

@ -0,0 +1,32 @@
#!/bin/bash
# Get the highest tag number
VERSION="$(git describe --abbrev=0 --tags)"
VERSION=${VERSION:-'0.0.0'}
# Get number parts
MAJOR="${VERSION%%.*}"
VERSION="${VERSION#*.}"
MINOR="${VERSION%%.*}"
VERSION="${VERSION#*.}"
PATCH="${VERSION%%.*}"
VERSION="${VERSION#*.}"
# Increase version
PATCH=$((PATCH + 1))
TAG="${1}"
if [ "${TAG}" = "" ]; then
TAG="${MAJOR}.${MINOR}.${PATCH}"
fi
echo "Releasing ${TAG} ..."
git-chglog --next-tag="${TAG}" --output CHANGELOG.md
git commit -a -m "Update CHANGELOG for ${TAG}"
git tag -a -s -m "Release ${TAG}" "${TAG}"
git push && git push --tags
goreleaser release \
--rm-dist \
--release-notes <(git-chglog "${TAG}" | tail -n+5)