Skip to content

Commit

Permalink
Merge pull request #3 from ksctl/ci/release
Browse files Browse the repository at this point in the history
feat(ci): release workflow
  • Loading branch information
dipankardas011 authored Jan 25, 2025
2 parents df422c9 + a0c99c3 commit 8ff9694
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 22 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Release

on:
push:
tags:
- "v*" # Trigger on version tags

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
TAG_NAME: ${{ github.ref_name }}

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write # Needed for creating releases
packages: write # Needed for ghcr.io push

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "stable"

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Install dependencies
run: |
make
- name: Build installer YAML
run: |
make build-installer IMG=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG_NAME }}
- name: Build and push Docker images
run: |
make docker-buildx IMG=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG_NAME }}
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: dist/install.yaml
generate_release_notes: true
draft: true
prerelease: false
make_latest: true
token: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ go.work
*.swo
*~

dist/
2 changes: 1 addition & 1 deletion PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repo: github.com/ksctl/kcm
resources:
- api:
crdVersion: v1
namespaced: true
namespaced: false
controller: true
domain: ksctl.com
group: manage
Expand Down
37 changes: 18 additions & 19 deletions config/default/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Adds namespace to all resources.
namespace: ksctl-system
namespace: kcm-ksctl-system

# Value of this field is prepended to the
# names of all resources, e.g. a deployment named
Expand All @@ -15,18 +15,18 @@ namePrefix: kcm-
# someName: someValue

resources:
- ../crd
- ../rbac
- ../manager
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
# crd/kustomization.yaml
#- ../webhook
# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER'. 'WEBHOOK' components are required.
#- ../certmanager
# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'.
#- ../prometheus
# [METRICS] Expose the controller manager metrics service.
- metrics_service.yaml
- ../crd
- ../rbac
- ../manager
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
# crd/kustomization.yaml
#- ../webhook
# [CERTMANAGER] To enable cert-manager, uncomment all sections with 'CERTMANAGER'. 'WEBHOOK' components are required.
#- ../certmanager
# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'.
#- ../prometheus
# [METRICS] Expose the controller manager metrics service.
- metrics_service.yaml
# [NETWORK POLICY] Protect the /metrics endpoint and Webhook Server with NetworkPolicy.
# Only Pod(s) running a namespace labeled with 'metrics: enabled' will be able to gather the metrics.
# Only CR(s) which requires webhooks and are applied on namespaces labeled with 'webhooks: enabled' will
Expand All @@ -35,12 +35,11 @@ resources:

# Uncomment the patches line if you enable Metrics
patches:
# [METRICS] The following patch will enable the metrics endpoint using HTTPS and the port :8443.
# More info: https://book.kubebuilder.io/reference/metrics
- path: manager_metrics_patch.yaml
target:
kind: Deployment

# [METRICS] The following patch will enable the metrics endpoint using HTTPS and the port :8443.
# More info: https://book.kubebuilder.io/reference/metrics
- path: manager_metrics_patch.yaml
target:
kind: Deployment
# Uncomment the patches line if you enable Metrics and CertManager
# [METRICS-WITH-CERTS] To enable metrics protected with certManager, uncomment the following line.
# This patch will protect the metrics with certManager self-signed certs.
Expand Down
6 changes: 6 additions & 0 deletions config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
resources:
- manager.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: controller
newName: controller
newTag: latest
4 changes: 2 additions & 2 deletions internal/controller/addons.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ func (r *ClusterAddonReconciler) DeleteNamespaceIfExists(ctx context.Context, na
func (r *ClusterAddonReconciler) GetData(ctx context.Context) (*corev1.ConfigMap, error) {
cf := &corev1.ConfigMap{}

if err := r.Get(ctx, client.ObjectKey{Namespace: cf.Namespace, Name: cf.Name}, cf); err != nil {
if err := r.Get(ctx, client.ObjectKey{Namespace: "kcm-ksctl-system", Name: "kcm-addons"}, cf); err != nil {
if errors.IsNotFound(err) {
cf = &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: "kcm-addons",
Namespace: "ksctl-system",
Namespace: "kcm-ksctl-system",
},
Data: map[string]string{},
}
Expand Down

0 comments on commit 8ff9694

Please sign in to comment.