-
Notifications
You must be signed in to change notification settings - Fork 18
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
Add release workflow #123
Conversation
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]>
Signed-off-by: Grzegorz Piotrowski <[email protected]> Co-authored-by: Adam Cattermole <[email protected]>
1546df7
to
4bb0611
Compare
Makefile
Outdated
$(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')) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this 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.)
- 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
- 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]>
Tests are failing now because of missing a value for |
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
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? Line 70 in 254b656
|
Co-authored-by: Grzegorz Piotrowski <[email protected]>
ebce65b
to
1789a7f
Compare
Signed-off-by: Grzegorz Piotrowski <[email protected]> Co-authored-by: Adam Cattermole <[email protected]>
Fixes #114