Skip to content

Commit

Permalink
Automate Github Release Draft with Github Action
Browse files Browse the repository at this point in the history
Automatically create Github release when we create git tag, and it creates the draft with a nice structure and with the bundle dir (for community releases). We also create new targets for community usage
  • Loading branch information
razo7 committed May 8, 2023
1 parent 01fd9d5 commit 487af11
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 12 deletions.
31 changes: 29 additions & 2 deletions .github/workflows/post-submit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,39 @@ jobs:

- name: Build and push operator and bundle images, using version 0.0.1, for pushes to main
if: ${{ github.ref_type != 'tag' }}
run: make container-build container-push
run: make container-build-community container-push

- name: Build and push versioned CSV and images, for tags
if: ${{ github.ref_type == 'tag' }}
# remove leading 'v' from tag!
run: export VERSION=$(echo $GITHUB_REF_NAME | sed 's/v//') && make container-build container-push
run: export VERSION=$(echo $GITHUB_REF_NAME | sed 's/v//') && make container-build-community container-push

- name: Create release with manifests, for tags
if: ${{ github.ref_type == 'tag' }}
# https://github.com/marketplace/actions/github-release-create-update-and-upload-assets
uses: meeDamian/github-release@2.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
draft: true
body: |
# Self Node Remediation ${{ github.ref_name }}
## Notable Changes
* TODO
## Release Artifacts
### Images
* Operator: quay.io/medik8s/self-node-remediation-operator:${{ github.ref_name }}
* Bundle: quay.io/medik8s/self-node-remediation-operator-bundle:${{ github.ref_name }}
* Catalog aka Index: quay.io/medik8s/self-node-remediation-operator-catalog:${{ github.ref_name }}
### Source code and OLM manifests
Please find the source code and the OLM manifests in the `Assets` section below.
gzip: folders
files: >
Manifests:bundle/
- name: Build and push index image with versioned NHC + SNR images
if: ${{ github.ref_type != 'tag' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pre-submit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ jobs:
run: make test

- name: Test container build
run: make container-build
run: make container-build-community
28 changes: 19 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ endef

DEFAULT_ICON_BASE64 := $(shell base64 --wrap=0 ./config/assets/snr_icon_blue.png)
export ICON_BASE64 ?= ${DEFAULT_ICON_BASE64}
export BUNDLE_CSV ?= "./bundle/manifests/$(OPERATOR_NAME).clusterserviceversion.yaml"
.PHONY: bundle
bundle: manifests operator-sdk kustomize ## Generate bundle manifests and metadata, then validate generated files.
$(OPERATOR_SDK) generate kustomize manifests -q
Expand All @@ -250,23 +251,24 @@ bundle: manifests operator-sdk kustomize ## Generate bundle manifests and metada
.PHONY: bundle-community-k8s
bundle-community-k8s: bundle-community ## Generate bundle manifests and metadata customized to k8s community release, then validate generated files.
# Note that k8s 1.25+ needs PSA label
sed -r -i "s|by default\.|by default.\n Note that prior to installing SNR on a Kubernetes 1.25+ cluster, a user must manually set a [privileged PSA label](https://kubernetes.io/docs/tasks/configure-pod-container/enforce-standards-namespace-labels/) on SNR's namespace. It gives SNR's agents permissions to reboot the node (in case it needs to be remediated).|;" ./bundle/manifests/$(OPERATOR_NAME).clusterserviceversion.yaml
sed -r -i "s|by default\.|by default.\n Note that prior to installing SNR on a Kubernetes 1.25+ cluster, a user must manually set a [privileged PSA label](https://kubernetes.io/docs/tasks/configure-pod-container/enforce-standards-namespace-labels/) on SNR's namespace. It gives SNR's agents permissions to reboot the node (in case it needs to be remediated).|;" ${BUNDLE_CSV}
$(MAKE) bundle-update

.PHONY: bundle-community
bundle-community: bundle
#Add Community Edition suffix to operator name
bundle-community: bundle ## Update displayName field in the bundle's CSV
# Add Community Edition suffix to operator name
sed -r -i "s|displayName: Self Node Remediation Operator.*|displayName: Self Node Remediation Operator - Community Edition|;" ./bundle/manifests/$(OPERATOR_NAME).clusterserviceversion.yaml

.PHONY: bundle-update
bundle-update:
# update container image in the metadata
sed -r -i "s|containerImage: .*|containerImage: ${IMG}|;" ./bundle/manifests/$(OPERATOR_NAME).clusterserviceversion.yaml
sed -r -i "s|containerImage: .*|containerImage: ${IMG}|;" ${BUNDLE_CSV}
# set creation date
sed -r -i "s|createdAt: \".*\"|createdAt: \"`date "+%Y-%m-%d %T" `\"|;" ./bundle/manifests/$(OPERATOR_NAME).clusterserviceversion.yaml
sed -r -i "s|createdAt: \".*\"|createdAt: \"`date "+%Y-%m-%d %T" `\"|;" ${BUNDLE_CSV}
# set skipRange
sed -r -i "s|olm.skipRange: .*|olm.skipRange: '>=0.4.0 <${VERSION}'|;" ./bundle/manifests/$(OPERATOR_NAME).clusterserviceversion.yaml
sed -r -i "s|olm.skipRange: .*|olm.skipRange: '>=0.4.0 <${VERSION}'|;" ${BUNDLE_CSV}
# set icon (not version or build date related, but just to not having this huge data permanently in the CSV)
sed -r -i "s|base64data:.*|base64data: ${ICON_BASE64}|;" ./bundle/manifests/$(OPERATOR_NAME).clusterserviceversion.yaml
sed -r -i "s|base64data:.*|base64data: ${ICON_BASE64}|;" ${BUNDLE_CSV}
$(MAKE) bundle-validate

.PHONY: bundle-validate
Expand Down Expand Up @@ -347,11 +349,21 @@ catalog-push: ## Push a catalog image.
$(MAKE) docker-push IMG=$(CATALOG_IMG)

##@ Targets used by CI

.PHONY: check
# WORKAROUND: add "protoc" as dependency for downloading binary first, the golang image misses the needed "unzip"tool
check: protoc ## Dockerized version of make test
$(DOCKER_GO) "make test"

.PHONY: bundle-build-community
bundle-build-community: bundle-community ## Run bundle community changes in CSV, and then build the bundle image.
docker build -f bundle.Dockerfile -t $(BUNDLE_IMG) .

.PHONY: container-build-community
container-build-community: protoc check ## Build containers for community
$(DOCKER_GO) "make bundle-community"
make docker-build bundle-build-community

.PHONY: container-build
container-build: ## Build containers
make docker-build bundle bundle-build
Expand All @@ -368,10 +380,8 @@ vendor: ## Runs go mod vendor
tidy: ## Runs go mod tidy
go mod tidy


.PHONY:verify-vendor
verify-vendor:tidy vendor verify-no-changes ##Verifies vendor and tidy didn't cause changes


.PHONY:verify-bundle
verify-bundle: manifests bundle verify-no-changes ##Verifies bundle and manifests didn't cause changes

0 comments on commit 487af11

Please sign in to comment.