feat: release helm scripts updated to be automatic

This commit is contained in:
Daniel Hougaard
2025-03-25 02:10:41 +04:00
parent 95b57e144d
commit 778b0d4368
2 changed files with 122 additions and 44 deletions
@@ -0,0 +1,27 @@
name: Release K8 Operator Helm Chart
on:
workflow_dispatch:
jobs:
release-helm:
name: Release Helm Chart
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Helm
uses: azure/setup-helm@v3
with:
version: v3.10.0
- name: Install python
uses: actions/setup-python@v4
- name: Install Cloudsmith CLI
run: pip install --upgrade cloudsmith-cli
- name: Build and push helm package to CloudSmith
run: cd helm-charts && sh upload-k8s-operator-cloudsmith.sh
env:
CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }}
@@ -1,52 +1,103 @@
name: Release image + Helm chart K8s Operator name: Release K8 Operator Docker Image
on: on:
push: push:
tags: tags:
- "infisical-k8-operator/v*.*.*" - "infisical-k8-operator/v*.*.*"
jobs: jobs:
release: release-image:
runs-on: ubuntu-latest name: Generate Helm Chart PR
steps: runs-on: ubuntu-latest
- name: Extract version from tag outputs:
id: extract_version pr_number: ${{ steps.create-pr.outputs.pull-request-number }}
run: echo "::set-output name=version::${GITHUB_REF_NAME#infisical-k8-operator/}" steps:
- uses: actions/checkout@v2 - name: Extract version from tag
id: extract_version
run: echo "::set-output name=version::${GITHUB_REF_NAME#infisical-k8-operator/}"
- name: 🔧 Set up QEMU - name: Checkout code
uses: docker/setup-qemu-action@v1 uses: actions/checkout@v2
- name: 🔧 Set up Docker Buildx # Dependency for helm generation
uses: docker/setup-buildx-action@v1 - name: Install Helm
uses: azure/setup-helm@v3
with:
version: v3.10.0
- name: 🐋 Login to Docker Hub # Dependency for helm generation
uses: docker/login-action@v1 - name: Install Go
with: uses: actions/setup-go@v4
username: ${{ secrets.DOCKERHUB_USERNAME }} with:
password: ${{ secrets.DOCKERHUB_TOKEN }} go-version: 1.21
- name: Build and push # Install binaries for helm generation
id: docker_build - name: Install dependencies
uses: docker/build-push-action@v2 working-directory: k8-operator
with: run: |
context: k8-operator make helmify
push: true make kustomize
platforms: linux/amd64,linux/arm64 make controller-gen
tags: |
infisical/kubernetes-operator:latest
infisical/kubernetes-operator:${{ steps.extract_version.outputs.version }}
- name: Checkout - name: Generate Helm Chart
uses: actions/checkout@v2 working-directory: k8-operator
- name: Install Helm run: make helm
uses: azure/setup-helm@v3
with: - name: Update Helm Chart Version
version: v3.10.0 run: ./k8-operator/scripts/update-version.sh ${{ steps.extract_version.outputs.version }}
- name: Install python
uses: actions/setup-python@v4 - name: Debug - Check file changes
- name: Install Cloudsmith CLI run: |
run: pip install --upgrade cloudsmith-cli echo "Current git status:"
- name: Build and push helm package to Cloudsmith git status
run: cd helm-charts && sh upload-k8s-operator-cloudsmith.sh echo ""
env: echo "Modified files:"
CLOUDSMITH_API_KEY: ${{ secrets.CLOUDSMITH_API_KEY }} git diff --name-only
# If there is no diff, exit with error. Version should always be changed, so if there is no diff, something is wrong and we should exit.
if [ -z "$(git diff --name-only)" ]; then
echo "No helm changes or version changes. Invalid release detected, Exiting."
exit 1
fi
- name: Create Helm Chart PR
id: create-pr
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Update Helm chart to version ${{ steps.extract_version.outputs.version }}"
committer: GitHub <[email protected]>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
branch: helm-update-${{ steps.extract_version.outputs.version }}
delete-branch: true
title: "Update Helm chart to version ${{ steps.extract_version.outputs.version }}"
body: |
This PR updates the Helm chart to version `${{ steps.extract_version.outputs.version }}`.
Additionally the helm chart has been updated to match the latest operator code changes.
Associated Release Workflow: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
Once you have approved this PR, you can trigger the helm release workflow manually.
base: main
- name: 🔧 Set up QEMU
uses: docker/setup-qemu-action@v1
- name: 🔧 Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: 🐋 Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v2
with:
context: k8-operator
push: true
platforms: linux/amd64,linux/arm64
tags: |
infisical/kubernetes-operator:latest
infisical/kubernetes-operator:${{ steps.extract_version.outputs.version }}