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

Add release workflow #123

Merged
merged 6 commits into from
Jul 28, 2023
Merged

Conversation

grzpiotrowski
Copy link
Contributor

  • Added a new make target fix-csv-replaces
  • Added a new make target prepare-release
  • Moved tool installation to a different section in the Makefile
  • Added the Release operator workflow

Fixes #114

grzpiotrowski and others added 2 commits July 19, 2023 14:15
Signed-off-by: Grzegorz Piotrowski <[email protected]>
Co-authored-by: Adam Cattermole <[email protected]>
Co-authored-by: Adam Cattermole <[email protected]>
Signed-off-by: Grzegorz Piotrowski <[email protected]>
Makefile Outdated Show resolved Hide resolved
Signed-off-by: Grzegorz Piotrowski <[email protected]>
Co-authored-by: Adam Cattermole <[email protected]>
Makefile Outdated
Comment on lines 249 to 253
$(eval REPLACES_VERSION=$(shell curl -sSL -H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${GH_TOKEN}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/Kuadrant/authorino-operator/releases/latest | \
jq -r '.name'))
Copy link
Collaborator

Choose a reason for hiding this comment

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

This also works without the GH_TOKEN, doesn't it?

❯ curl -sSL \
  -H "Accept: application/vnd.github+json" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/repos/Kuadrant/authorino-operator/releases/latest | jq -r '.name'
v0.8.0

Copy link
Member

@adam-cattermole adam-cattermole Jul 28, 2023

Choose a reason for hiding this comment

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

Aha you're not wrong - we followed the docs described here which did not state the token as optional for public repos - https://docs.github.com/en/free-pro-team@latest/rest/releases/releases?apiVersion=2022-11-28#get-the-latest-release

I see now it only specifies one header as recommended - If this is the case I'd prefer to opt for removing the GH_TOKEN and possibly the other Github-Api-Version header and just leave the one recommended header.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd prefer to opt for removing the GH_TOKEN

I was thinking the same. The main (only?) benefit of the token here is to avoid getting rate-limited, but since this is for the release workflow, it's not like it's something that requires many requests anyway.

Copy link
Member

Choose a reason for hiding this comment

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

Yep agreed, we'll update this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just pushed the changes as suggested. However, in the meantime I noticed the workflow failing when authorinoVersion parameter is left as "latest". Works fine when it is set to a specific version like 0.14.0 for example.

Copy link
Collaborator

@guicassolato guicassolato left a comment

Choose a reason for hiding this comment

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

A couple extra things missing here. (Sorry. I've just spotted them now.)

  1. The defaultAuthorinoImage constant needs to become a variable or the ldflag will not work.
diff --git a/controllers/constants.go b/controllers/constants.go
index dd49876..f4ceb4f 100644
--- a/controllers/constants.go
+++ b/controllers/constants.go
@@ -53,7 +53,6 @@ const (
 	flagMaxHttpRequestBodySize         string = "max-http-request-body-size"
 
 	// defaults
-	defaultAuthorinoImage      string = "quay.io/kuadrant/authorino:latest"
 	defaultTlsCertPath         string = "/etc/ssl/certs/tls.crt"
 	defaultTlsCertKeyPath      string = "/etc/ssl/private/tls.key"
 	defaultOidcTlsCertPath     string = "/etc/ssl/certs/oidc.crt"
@@ -89,3 +88,6 @@ const (
 	statusUnableToUpdateDeployment                = "UnableToUpdateDeployment"
 	statusDeploymentNotReady                      = "DeploymentNotReady"
 )
+
+// ldflags
+var defaultAuthorinoImage string
  1. We need to specify the full path of the variable to modify at build-time
diff --git a/Makefile b/Makefile
index 10ebdf0..1b58af0 100644
--- a/Makefile
+++ b/Makefile
@@ -167,10 +167,10 @@ test: manifests generate fmt vet setup-envtest
 ##@ Build
 
 build: generate fmt vet ## Build manager binary.
-	go build -ldflags "-X main.version=$(VERSION) -X controllers.defaultAuthorinoImage=$(DEFAULT_AUTHORINO_IMAGE)" -o bin/manager main.go
+	go build -ldflags "-X main.version=$(VERSION) -X github.com/kuadrant/authorino-operator/controllers.defaultAuthorinoImage=$(DEFAULT_AUTHORINO_IMAGE)" -o bin/manager main.go
 
 run: manifests generate fmt vet ## Run a controller from your host.
-	go run -ldflags "-X main.version=$(VERSION) -X controllers.defaultAuthorinoImage=$(DEFAULT_AUTHORINO_IMAGE)" ./main.go
+	go run -ldflags "-X main.version=$(VERSION) -X github.com/kuadrant/authorino-operator/controllers.defaultAuthorinoImage=$(DEFAULT_AUTHORINO_IMAGE)" ./main.go
 

BTW, to check the name of a variable you want to set using -ldflags, you can use the go tool nm command:

❯ go tool nm bin/manager| grep main.version
101dee240 D main.version
101088f00 R main.version.str

❯ go tool nm bin/manager| grep controllers.defaultAuthorinoImage
101e05140 B github.com/kuadrant/authorino-operator/controllers.defaultAuthorinoImage

Signed-off-by: Grzegorz Piotrowski <[email protected]>
Co-authored-by: Adam Cattermole <[email protected]>
@guicassolato
Copy link
Collaborator

Tests are failing now because of missing a value for controllers.defaultAuthorinoImage; the Authorino deployments do not get a valid image and therefore are rejected. We may need to set the -ldflags in go test as well.

Dockerfile Outdated
RUN CGO_ENABLED=0 GO111MODULE=on go build -a -ldflags "-X main.version=${version}" -o manager main.go
ARG VERSION=latest
ARG DEFAULT_AUTHORINO_IMAGE=quay.io/kuadrant/authorino:latest
RUN CGO_ENABLED=0 GO111MODULE=on go build -a -ldflags "-X main.version=${VERSION} -X controllers.defaultAuthorinoImage=${DEFAULT_AUTHORINO_IMAGE}" -o manager main.go
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
RUN CGO_ENABLED=0 GO111MODULE=on go build -a -ldflags "-X main.version=${VERSION} -X controllers.defaultAuthorinoImage=${DEFAULT_AUTHORINO_IMAGE}" -o manager main.go
RUN CGO_ENABLED=0 GO111MODULE=on go build -a -ldflags "-X main.version=${VERSION} -X github.com/kuadrant/authorino-operator/controllers.defaultAuthorinoImage=${DEFAULT_AUTHORINO_IMAGE}" -o manager main.go

@guicassolato
Copy link
Collaborator

Now that we will no longer be able to read the default authorino image anywhere in the code, what do you think about logging it together with the operator version?

setupLog.Info("botting up authorino operator", "version", version)

Signed-off-by: Grzegorz Piotrowski <[email protected]>
Co-authored-by: Adam Cattermole <[email protected]>
@guicassolato guicassolato merged commit d07e246 into Kuadrant:main Jul 28, 2023
4 of 6 checks passed
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.

Set the replaces directive in the CSV
3 participants