diff --git a/.gitignore b/.gitignore index dc877d69..6034e202 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,5 @@ bin **/*.csr **/server-csr.json .DS_Store + +dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 00000000..ad49a454 --- /dev/null +++ b/.goreleaser.yaml @@ -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:' diff --git a/Makefile b/Makefile index f0b117b6..1ce1c250 100644 --- a/Makefile +++ b/Makefile @@ -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: