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

Closed
wants to merge 1 commit into from
Closed

Conversation

dierbei
Copy link

@dierbei dierbei commented Jun 21, 2023

Fix #292

@netlify
Copy link

netlify bot commented Jun 21, 2023

Deploy Preview for kamaji-documentation ready!

Name Link
🔨 Latest commit fbcf89b
🔍 Latest deploy log https://app.netlify.com/sites/kamaji-documentation/deploys/649f7b31e99c4f0007bd2a3c
😎 Deploy Preview https://deploy-preview-309--kamaji-documentation.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member

@prometherion prometherion left a comment

Choose a reason for hiding this comment

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

Thanks for picking up this, @dierbei!

Kamaji is using Go's ldflag to embed some information about itself version:

kamaji/Makefile

Lines 148 to 169 in 4db8230

# Get information about git current status
GIT_HEAD_COMMIT ?= $$(git rev-parse --short HEAD)
GIT_TAG_COMMIT ?= $$(git rev-parse --short v$(VERSION))
GIT_MODIFIED_1 ?= $$(git diff $(GIT_HEAD_COMMIT) $(GIT_TAG_COMMIT) --quiet && echo "" || echo ".dev")
GIT_MODIFIED_2 ?= $$(git diff --quiet && echo "" || echo ".dirty")
GIT_MODIFIED ?= $$(echo "$(GIT_MODIFIED_1)$(GIT_MODIFIED_2)")
GIT_REPO ?= $$(git config --get remote.origin.url)
BUILD_DATE ?= $$(git log -1 --format="%at" | xargs -I{} date -d @{} +%Y-%m-%dT%H:%M:%S)
build: generate fmt vet ## Build manager binary.
go build -o bin/manager main.go
run: manifests generate fmt vet ## Run a controller from your host.
go run ./main.go
docker-build: ## Build docker image with the manager.
docker build -t ${IMG} . --build-arg GIT_HEAD_COMMIT=$(GIT_HEAD_COMMIT) \
--build-arg GIT_TAG_COMMIT=$(GIT_TAG_COMMIT) \
--build-arg GIT_MODIFIED=$(GIT_MODIFIED) \
--build-arg GIT_REPO=$(GIT_REPO) \
--build-arg GIT_LAST_TAG=$(VERSION) \
--build-arg BUILD_DATE=$(BUILD_DATE)

Are you aware if we can pass custom values as we're doing with regular Go builds?

-ldflags "-X github.com/clastix/kamaji/internal.GitRepo=$GIT_REPO -X github.com/clastix/kamaji/internal.GitTag=$GIT_LAST_TAG -X github.com/clastix/kamaji/internal.GitCommit=$GIT_HEAD_COMMIT -X github.com/clastix/kamaji/internal.GitDirty=$GIT_MODIFIED -X github.com/clastix/kamaji/internal.BuildTime=$BUILD_DATE" \

@dierbei
Copy link
Author

dierbei commented Jun 21, 2023

Thanks for your suggestion, I will try it later.

@dierbei
Copy link
Author

dierbei commented Jun 22, 2023

I encountered another problem. When I tried to use make build to build the program, I encountered that fmt and vet were not defined, which caused the program to fail to build.

image

I tried adding the following code in the Makefile, do I need to fix this problem?

fmt:
	go fmt ./...

vet:
	go vet ./...

build: generate fmt vet ## Build manager binary.
	go build -o bin/manager main.go

@dierbei dierbei force-pushed the add-go-releaser branch 7 times, most recently from b44a12a to 7eb1a05 Compare June 22, 2023 06:36
@dierbei
Copy link
Author

dierbei commented Jun 22, 2023

Thanks for picking up this, @dierbei!

Kamaji is using Go's ldflag to embed some information about itself version:

kamaji/Makefile

Lines 148 to 169 in 4db8230

# Get information about git current status
GIT_HEAD_COMMIT ?= $$(git rev-parse --short HEAD)
GIT_TAG_COMMIT ?= $$(git rev-parse --short v$(VERSION))
GIT_MODIFIED_1 ?= $$(git diff $(GIT_HEAD_COMMIT) $(GIT_TAG_COMMIT) --quiet && echo "" || echo ".dev")
GIT_MODIFIED_2 ?= $$(git diff --quiet && echo "" || echo ".dirty")
GIT_MODIFIED ?= $$(echo "$(GIT_MODIFIED_1)$(GIT_MODIFIED_2)")
GIT_REPO ?= $$(git config --get remote.origin.url)
BUILD_DATE ?= $$(git log -1 --format="%at" | xargs -I{} date -d @{} +%Y-%m-%dT%H:%M:%S)
build: generate fmt vet ## Build manager binary.
go build -o bin/manager main.go
run: manifests generate fmt vet ## Run a controller from your host.
go run ./main.go
docker-build: ## Build docker image with the manager.
docker build -t ${IMG} . --build-arg GIT_HEAD_COMMIT=$(GIT_HEAD_COMMIT) \
--build-arg GIT_TAG_COMMIT=$(GIT_TAG_COMMIT) \
--build-arg GIT_MODIFIED=$(GIT_MODIFIED) \
--build-arg GIT_REPO=$(GIT_REPO) \
--build-arg GIT_LAST_TAG=$(VERSION) \
--build-arg BUILD_DATE=$(BUILD_DATE)

Are you aware if we can pass custom values as we're doing with regular Go builds?

-ldflags "-X github.com/clastix/kamaji/internal.GitRepo=$GIT_REPO -X github.com/clastix/kamaji/internal.GitTag=$GIT_LAST_TAG -X github.com/clastix/kamaji/internal.GitCommit=$GIT_HEAD_COMMIT -X github.com/clastix/kamaji/internal.GitDirty=$GIT_MODIFIED -X github.com/clastix/kamaji/internal.BuildTime=$BUILD_DATE" \

After testing, it is already possible to pass parameters in the build process through ldflags.

Can you review it for me?

api/v1alpha1/groupversion_info.go Outdated Show resolved Hide resolved
.goreleaser.yaml Outdated Show resolved Hide resolved
@@ -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

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).

@maxgio92
Copy link
Contributor

Hi @dierbei, did you have the chance to look into the suggestions?
Thank you!

@dierbei
Copy link
Author

dierbei commented Oct 14, 2023

Hi @dierbei, did you have the chance to look into the suggestions? Thank you!

Sorry, I've been busy with grad school exams lately.

May not have much time.

@prometherion
Copy link
Member

Closing this due to inactivity, sorry for the small support we've been able to provide 😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add manifests to the published releases
3 participants