Skip to content

Commit

Permalink
feat: Introduce goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomasz-Smelcerz-SAP committed Oct 23, 2023
1 parent 2b09d21 commit f00aaef
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 0 deletions.
60 changes: 60 additions & 0 deletions runtime-watcher/.goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Documentation for how to configure goreleaser can be found at http://goreleaser.com
project_name: kyma
release:
github:
owner: kyma-project
name: runtime-watcher
prerelease: auto
before:
hooks:
- make resolve
builds:
- env:
- CGO_ENABLED=0
main: ./runtime-watcher/
goos:
- darwin
- linux
- windows
ignore:
- goos: darwin
goarch: 386
archives:
- id: foo
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
format_overrides:
- goos: windows
format: zip
checksum:
name_template: "checksums.txt"
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
use: github
sort: asc
groups:
- title: Bug fixes
regexp: '^.*?fix(\([[:word:]]+\))??!?:.+$'
order: 1
- title: Dependencies
regexp: '^.*?deps(\([[:word:]]+\))??!?:.+$'
order: 2
- title: Documentation
regexp: '^.*?docs(\([[:word:]]+\))??!?:.+$'
order: 3
- title: Test suites
regexp: '^.*?test(\([[:word:]]+\))??!?:.+$'
order: 4
- title: Features
order: 0
filters:
exclude:
- "^docs:"
- "^test:"
- '^(B|b)ump'
- '^.*?chore(\([[:word:]]+\))??!?:.+$'
7 changes: 7 additions & 0 deletions runtime-watcher/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,10 @@ $(ENVTEST): $(LOCALBIN)
lint: ## Run golangci-lint against code.
GOBIN=$(LOCALBIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANG_CI_LINT_VERSION)
$(LOCALBIN)/golangci-lint run -v -c .golangci.yaml

.PHONY: release
release:
./hack/release.sh

.PHONY: ci-release
ci-release: resolve build test release
32 changes: 32 additions & 0 deletions runtime-watcher/hack/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

# standard bash error handling
set -o nounset # treat unset variables as an error and exit immediately.
set -o errexit # exit immediately when a command fails.
set -E # needs to be set if we want the ERR trap

get_new_release_version() {
# get the list of tags in a reverse chronological order
TAG_LIST=($(git tag --sort=-creatordate))
export GORELEASER_CURRENT_TAG=${TAG_LIST[0]}
}

get_previous_release_version() {
# get the list of tags in a reverse chronological order excluding release candidate tags
TAG_LIST_WITHOUT_RC=($(git tag --sort=-creatordate | grep -v -e "-rc"))
if [[ $GORELEASER_CURRENT_TAG == *"-rc"* ]]; then
export GORELEASER_PREVIOUS_TAG=${TAG_LIST_WITHOUT_RC[0]}
else
export GORELEASER_PREVIOUS_TAG=${TAG_LIST_WITHOUT_RC[1]}
fi
}

main() {
git remote add origin [email protected]:kyma-project/runtime-watcher.git
get_new_release_version
get_previous_release_version
# release watcher with release notes generated by goreleaser
curl -sL https://git.io/goreleaser | VERSION=v0.0.1-test1 bash -s --
}

main

0 comments on commit f00aaef

Please sign in to comment.