Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add go releaser #309

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @dierbei, about releasing also the manifests we can use the release.extra_files to include with a glob pattern manifest files expected to be released to install Kamaji from bare manifets.

Then, update the checksum with the same extra_files content. What do you think?

In any case @prometherion, we should have in place (also generated from the pipeline with GitHub actions), a manifest that contain CRDs and Kamaji plus default DataStore (or CRDs and deployments separated).

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)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @dierbei thank you! There's a typo here in kamaji 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