Skip to content

Commit

Permalink
feat: add go releaser
Browse files Browse the repository at this point in the history
Fix #292
  • Loading branch information
dierbei committed Jul 1, 2023
1 parent 4db8230 commit fbcf89b
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ bin
**/*.csr
**/server-csr.json
.DS_Store

dist/
55 changes: 55 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
before:
hooks:
- go mod tidy
builds:
-
# Binary name
id: "kamaji"

# Custom environment variables to be set during the builds.
# Invalid environment variables will be ignored.
#
# Default: os.Environ() ++ env config section
# Templates: allowed (since v1.14)
env:
- CGO_ENABLED=0

# GOOS list to build for.
# For more info refer to: https://golang.org/doc/install/source#environment
#
# Default: [ 'darwin', 'linux', 'windows' ]
goos:
- linux

# GOARCH to build for.
# For more info refer to: https://golang.org/doc/install/source#environment
#
# Default: [ '386', 'amd64', 'arm64' ]
goarch:
- amd64
- arm64

# Custom ldflags.
ldflags: "-X github.com/clastix/kamaji/internal.GitRepo=${{.Env.GIT_REPO}} -X github.com/clastix/kamaji/internal.GitTag={{.Env.VERSION}} -X github.com/clastix/kamaji/internal.GitCommit={{.Env.GIT_HEAD_COMMIT}} -X github.com/clastix/kamaji/internal.GitDirty={{.Env.GIT_MODIFIED}} -X github.com/clastix/kamaji/internal.BuildTime={{.Env.BUILD_DATE}}"

archives:
- format: tar.gz
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}amd64
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
format_overrides:
- goos: windows
format: zip
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ incpatch .Version }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,24 @@ docker-build: ## Build docker image with the manager.
docker-push: ## Push docker image with the manager.
docker push ${IMG}

create-tag: # Add a tag to the current commit and push it to the remote repository.
@git tag -a v$(VERSION) -m "Welcome to kamoji version $(VERSION)"
@git push origin v$(VERSION)

# Prerequisites: git is not in dirty state
# If GITHUB_TOKEN exists, release a version according to the current tag.
# If an error is encountered, the local tag and the remote tag will be deleted.
# - use the VERSION as arg (e.g make release VERSION=0.4.0)
# - use environment variables to overwrite this value (e.g export VERSION=0.4.0)
release: create-tag
GIT_REPO=$(GIT_REPO) \
GIT_HEAD_COMMIT=$(GIT_HEAD_COMMIT) \
VERSION=$(VERSION) \
GIT_MODIFIED=$(GIT_MODIFIED) \
BUILD_DATE=$(BUILD_DATE) \
goreleaser release --clean || \
(git tag -d v$(VERSION) && git push origin :refs/tags/v$(VERSION))

##@ Deployment

metallb:
Expand Down

0 comments on commit fbcf89b

Please sign in to comment.