-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #123 from grzpiotrowski/add-release-workflow
Add release workflow
- Loading branch information
Showing
8 changed files
with
137 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: Release operator | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
gitRef: | ||
description: Commit SHA or branch name | ||
required: true | ||
operatorVersion: | ||
description: Operator version | ||
required: true | ||
authorinoVersion: | ||
description: Authorino version | ||
required: true | ||
default: latest | ||
prerelease: | ||
description: Is the release a prerelease | ||
required: false | ||
type: boolean | ||
|
||
jobs: | ||
build: | ||
name: Release operator | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Install gettext-base | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y gettext-base | ||
- name: Set up Go 1.19.x | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.19.x | ||
id: go | ||
- name: Checkout code at git ref | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.event.inputs.gitRef }} | ||
- name: Create release branch | ||
if: ${{ !startsWith(github.event.inputs.gitRef, 'release-v') }} | ||
run: | | ||
git checkout -b release-v${{ github.event.inputs.operatorVersion }} | ||
- name: Prepare release | ||
run: VERSION=${{ github.event.inputs.operatorVersion }} AUTHORINO_VERSION=${{ github.event.inputs.authorinoVersion }} make prepare-release | ||
- name: Commit and push | ||
run: | | ||
git config --global user.name "github-actions[bot]" | ||
git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
git commit -m "Prepared release v${{ github.event.inputs.operatorVersion }}" -a | ||
git push origin release-v${{ github.event.inputs.operatorVersion }} | ||
- name: Create release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
name: v${{ github.event.inputs.operatorVersion }} | ||
tag_name: v${{ github.event.inputs.operatorVersion }} | ||
body: "**This release enables installations of Authorino v${{ github.event.inputs.authorinoVersion }}**" | ||
generate_release_notes: true | ||
target_commitish: release-v${{ github.event.inputs.operatorVersion }} | ||
prerelease: ${{ github.event.inputs.prerelease }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,13 +78,56 @@ else | |
AUTHORINO_BRANCH = v$(AUTHORINO_VERSION) | ||
endif | ||
|
||
AUTHORINO_IMAGE_FILE ?= authorino_image | ||
DEFAULT_AUTHORINO_IMAGE ?= $(shell cat $(AUTHORINO_IMAGE_FILE) || echo $(DEFAULT_REGISTRY)/$(DEFAULT_ORG)/authorino:latest) | ||
|
||
all: build | ||
|
||
##@ General | ||
|
||
help: ## Display this help. | ||
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-20s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) | ||
|
||
|
||
##@ Tools | ||
|
||
OPERATOR_SDK = $(shell pwd)/bin/operator-sdk | ||
OPERATOR_SDK_VERSION = v1.22.0 | ||
operator-sdk: ## Download operator-sdk locally if necessary. | ||
./utils/install-operator-sdk.sh $(OPERATOR_SDK) $(OPERATOR_SDK_VERSION) | ||
|
||
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen | ||
controller-gen: ## Download controller-gen locally if necessary. | ||
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/[email protected]) | ||
|
||
KUSTOMIZE = $(shell pwd)/bin/kustomize | ||
kustomize: ## Download kustomize locally if necessary. | ||
$(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/[email protected]) | ||
|
||
YQ = $(shell pwd)/bin/yq | ||
$(YQ): | ||
$(call go-get-tool,$(YQ),github.com/mikefarah/yq/v4@latest) | ||
|
||
.PHONY: yq | ||
yq: $(YQ) ## Download yq locally if necessary. | ||
|
||
.PHONY: opm | ||
OPM = ./bin/opm | ||
opm: ## Download opm locally if necessary. | ||
ifeq (,$(wildcard $(OPM))) | ||
ifeq (,$(shell which opm 2>/dev/null)) | ||
@{ \ | ||
set -e ;\ | ||
mkdir -p $(dir $(OPM)) ;\ | ||
OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \ | ||
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.15.1/$${OS}-$${ARCH}-opm ;\ | ||
chmod +x $(OPM) ;\ | ||
} | ||
else | ||
OPM = $(shell which opm) | ||
endif | ||
endif | ||
|
||
##@ Development | ||
|
||
manifests: controller-gen kustomize authorino-manifests ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects. | ||
|
@@ -119,18 +162,18 @@ endif | |
# Run the tests | ||
test: manifests generate fmt vet setup-envtest | ||
echo $(SETUP_ENVTEST) | ||
KUBEBUILDER_ASSETS='$(strip $(shell $(SETUP_ENVTEST) --arch=amd64 use -p path 1.22.x))' go test ./... -coverprofile cover.out | ||
KUBEBUILDER_ASSETS='$(strip $(shell $(SETUP_ENVTEST) --arch=amd64 use -p path 1.22.x))' go test -ldflags="-X github.com/kuadrant/authorino-operator/controllers.DefaultAuthorinoImage=$(DEFAULT_AUTHORINO_IMAGE)" ./... -coverprofile cover.out | ||
|
||
##@ Build | ||
|
||
build: generate fmt vet ## Build manager binary. | ||
go build -ldflags "-X main.version=$(VERSION)" -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)" ./main.go | ||
go run -ldflags "-X main.version=$(VERSION) -X github.com/kuadrant/authorino-operator/controllers.DefaultAuthorinoImage=$(DEFAULT_AUTHORINO_IMAGE)" ./main.go | ||
|
||
docker-build: ## Build docker image with the manager. | ||
docker build --build-arg version=$(VERSION) -t $(OPERATOR_IMAGE) . | ||
docker build --build-arg VERSION=$(VERSION) --build-arg DEFAULT_AUTHORINO_IMAGE=$(DEFAULT_AUTHORINO_IMAGE) -t $(OPERATOR_IMAGE) . | ||
|
||
docker-push: ## Push docker image with the manager. | ||
docker push ${OPERATOR_IMAGE} | ||
|
@@ -155,14 +198,6 @@ undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/confi | |
install-authorino: ## install RBAC and CRD for authorino | ||
$(KUSTOMIZE) build config/authorino | kubectl apply -f - | ||
|
||
CONTROLLER_GEN = $(shell pwd)/bin/controller-gen | ||
controller-gen: ## Download controller-gen locally if necessary. | ||
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/[email protected]) | ||
|
||
KUSTOMIZE = $(shell pwd)/bin/kustomize | ||
kustomize: ## Download kustomize locally if necessary. | ||
$(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/[email protected]) | ||
|
||
# go-get-tool will 'go install' any package $2 and install it to $1. | ||
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) | ||
define go-get-tool | ||
|
@@ -187,11 +222,6 @@ deploy-manifest: | |
# clean up | ||
cd $(PROJECT_DIR)/config/manager && $(KUSTOMIZE) edit set image controller=${DEFAULT_OPERATOR_IMAGE} | ||
|
||
OPERATOR_SDK = $(shell pwd)/bin/operator-sdk | ||
OPERATOR_SDK_VERSION = v1.22.0 | ||
operator-sdk: ## Download operator-sdk locally if necessary. | ||
./utils/install-operator-sdk.sh $(OPERATOR_SDK) $(OPERATOR_SDK_VERSION) | ||
|
||
.PHONY: bundle | ||
bundle: export IMAGE_TAG := $(IMAGE_TAG) | ||
bundle: export BUNDLE_VERSION := $(BUNDLE_VERSION) | ||
|
@@ -214,22 +244,22 @@ bundle-build: ## Build the bundle image. | |
bundle-push: ## Push the bundle image. | ||
$(MAKE) docker-push OPERATOR_IMAGE=$(BUNDLE_IMG) | ||
|
||
.PHONY: opm | ||
OPM = ./bin/opm | ||
opm: ## Download opm locally if necessary. | ||
ifeq (,$(wildcard $(OPM))) | ||
ifeq (,$(shell which opm 2>/dev/null)) | ||
@{ \ | ||
set -e ;\ | ||
mkdir -p $(dir $(OPM)) ;\ | ||
OS=$(shell go env GOOS) && ARCH=$(shell go env GOARCH) && \ | ||
curl -sSLo $(OPM) https://github.com/operator-framework/operator-registry/releases/download/v1.15.1/$${OS}-$${ARCH}-opm ;\ | ||
chmod +x $(OPM) ;\ | ||
} | ||
else | ||
OPM = $(shell which opm) | ||
endif | ||
endif | ||
.PHONY: fix-csv-replaces | ||
fix-csv-replaces: $(YQ) | ||
$(eval REPLACES_VERSION=$(shell curl -sSL -H "Accept: application/vnd.github+json" \ | ||
https://api.github.com/repos/Kuadrant/authorino-operator/releases/latest | \ | ||
jq -r '.name')) | ||
V="authorino-operator.$(REPLACES_VERSION)" $(YQ) eval '.spec.replaces = strenv(V)' -i bundle/manifests/authorino-operator.clusterserviceversion.yaml | ||
|
||
.PHONY: prepare-release | ||
prepare-release: | ||
$(MAKE) manifests bundle VERSION=$(VERSION) AUTHORINO_VERSION=$(AUTHORINO_VERSION) | ||
@if [ "$(AUTHORINO_VERSION)" = "latest" ]; then\ | ||
[ -e "$(AUTHORINO_IMAGE_FILE)" ] && rm $(AUTHORINO_IMAGE_FILE); \ | ||
else \ | ||
echo quay.io/kuadrant/authorino:v$(AUTHORINO_VERSION) > $(AUTHORINO_IMAGE_FILE); \ | ||
fi | ||
$(MAKE) fix-csv-replaces | ||
|
||
# A comma-separated list of bundle images (e.g. make catalog-build BUNDLE_IMGS=example.com/operator-bundle:v0.1.0,example.com/operator-bundle:v0.2.0). | ||
# These images MUST exist in a registry and be pull-able. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters