Skip to content

Commit

Permalink
Add github workflows to release helm chart
Browse files Browse the repository at this point in the history
* manual-freeze-tag.yaml to run on release branch, modify version and tags
* manual-helm-cd-workflow.yaml to trigger tests
* manual-release-charts.yaml to release the helm charts to public repo

Signed-off-by: Dolpher Du <[email protected]>
  • Loading branch information
yongfengdu committed Nov 16, 2024
1 parent 1d77b81 commit cd6493f
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 24 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/manual-freeze-tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,22 @@ on:
workflow_dispatch:
inputs:
oldversion:
default: "0.9.0"
default: "1.1-dev"
description: "Old helm version to be replaced"
required: true
type: string
newversion:
default: "1.0.0"
default: "1.1.0"
description: "New helm version to replace"
required: true
type: string
imageversion:
default: "v1.0"
default: "1.1"
description: "New image version to replace"
required: true
type: string
branches-ignore:
- main

jobs:
freeze-tag:
Expand All @@ -43,9 +45,9 @@ jobs:
env:
NEWTAG: ${{ inputs.imageversion }}
run: |
find helm-charts/ -name '*values.yaml' -type f -exec sed -i "s#tag: \"latest\"#tag: \"${imageversion}\"#g" {} \;
find helm-charts/ -name '*values.yaml' -type f -exec sed -i "s#tag: \"latest\"#tag: \"${{ inputs.imageversion }}\"#g" {} \;
find helm-charts/ -name 'Chart.yaml' -type f -exec sed -i "s#version: ${{ inputs.oldversion }}#version: ${{ inputs.newversion }}#g" {} \;
find microservices-connector/helm/ -name '*values.yaml' -type f -exec sed -i "s#tag: \"latest\"#tag: \"${imageversion}\"#g" {} \;
find microservices-connector/helm/ -name '*values.yaml' -type f -exec sed -i "s#tag: \"latest\"#tag: \"${{ inputs.imageversion }}\"#g" {} \;
find microservices-connector/helm/ -name 'Chart.yaml' -type f -exec sed -i "s#version: ${{ inputs.oldversion }}#version: ${{ inputs.newversion }}#g" {} \;
sed -i "s|opea/gmcrouter:latest|opea/gmcrouter:$NEWTAG|g" microservices-connector/config/gmcrouter/gmc-router.yaml
sed -i "s|opea/gmcmanager:latest|opea/gmcmanager:$NEWTAG|g" microservices-connector/config/manager/gmc-manager.yaml
Expand All @@ -54,5 +56,5 @@ jobs:
- name: Commit changes
run: |
git add .
git commit -s -m "Freeze Helm charts versions"
git commit -s -m "Freeze Helm charts versions for release ${{ inputs.imageversion }}"
git push
33 changes: 15 additions & 18 deletions .github/workflows/manual-helm-cd-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,44 +42,41 @@ jobs:
set -x
run_matrix="{\"include\":["
if [[ -z "${{ inputs.workloads }}" ]]; then
find "$CHARTS_DIR" -mindepth 1 -maxdepth 1 -type d ! -name "common" -exec basename {} \; | while read -r subfolder; do
for file in "$CHARTS_DIR/$subfolder"/*values.yaml; do
for chart in ${CHARTS_DIR}/*; do
if [[ "$chart" == *"common" ]] || [[ -f $chart ]]; then
continue
fi
for file in "$chart"/ci-*values.yaml; do
if [ -f "$file" ]; then
if [[ "$file" == *"nv-values.yaml" ]] || [[ "$file" == *"hpa-values.yaml" ]]; then
continue
fi
filename=$(basename "$file" .yaml)
if [[ "$filename" == *"gaudi"* ]]; then
run_matrix="${run_matrix}{\"example\":\"${subfolder}\",\"hardware\":\"gaudi\", \"valuefile\":\"${filename}\"},"
run_matrix="${run_matrix}{\"example\":\"$(basename "${chart}\",\"hardware\":\"gaudi\", \"valuefile\":\"${filename}\"},"
else
run_matrix="${run_matrix}{\"example\":\"${subfolder}\",\"hardware\":\"xeon\", \"valuefile\":\"${filename}\"},"
run_matrix="${run_matrix}{\"example\":\"$(basename "${chart}\",\"hardware\":\"xeon\", \"valuefile\":\"${filename}\"},"
fi
fi
done
done
find "$CHARTS_DIR/common" -mindepth 1 -maxdepth 1 -type d -exec basename {} \; | while read -r subfolder; do
for file in "$CHARTS_DIR/common/$subfolder"/*values.yaml; do
for chart in ${CHARTS_DIR}/common/*; do
if [[ -f $chart ]]; then
continue
fi
for file in "$chart"/ci-*values.yaml; do
if [ -f "$file" ]; then
if [[ "$file" == *"nv-values.yaml" ]] || [[ "$file" == *"hpa-values.yaml" ]]; then
continue
fi
filename=$(basename "$file" .yaml)
if [[ "$filename" == *"gaudi"* ]]; then
run_matrix="${run_matrix}{\"example\":\"common/${subfolder}\",\"hardware\":\"gaudi\", \"valuefile\":\"${filename}\"},"
run_matrix="${run_matrix}{\"example\":\"$(basename "${chart}\",\"hardware\":\"gaudi\", \"valuefile\":\"${filename}\",\"directory\":\"common\"},"
else
run_matrix="${run_matrix}{\"example\":\"common/${subfolder}\",\"hardware\":\"xeon\", \"valuefile\":\"${filename}\"},"
run_matrix="${run_matrix}{\"example\":\"$(basename "${chart}\",\"hardware\":\"xeon\", \"valuefile\":\"${filename}\",\"directory\":\"common\"},"
fi
fi
done
done
else
service_list=($(echo ${{ github.event.inputs.workloads }} | tr ',' ' '))
for service in $service_list; do
for file in "$CHARTS_DIR/$service"/*values.yaml; do
for file in "$CHARTS_DIR/$service"/ci-*values.yaml; do
if [ -f "$file" ]; then
if [ "$file" == *"nv-values.yaml" ] || [ "$file" == *"hpa-values.yaml" ]; then
continue
fi
filename=$(basename "$file" .yaml)
if [[ "$filename" == *"gaudi"* ]]; then
run_matrix="${run_matrix}{\"example\":\"$service\",\"hardware\":\"gaudi\", \"valuefile\":\"${filename}\"},"
Expand Down
89 changes: 89 additions & 0 deletions .github/workflows/manual-release-charts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

name: Manual event to release helm chart to public site on release branch

on:
workflow_dispatch:
inputs:
version:
default: "1.1.0"
description: "Release Version"
required: true
type: string
artifacthub:
default: false
description: "Release to ArtifactHub repo"
required: true
type: bool
ghcr:
default: true
description: "Release to ghcr package"
required: true
type: bool

jobs:
release-charts:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.ref }}

- name: Prepare helm packages
env:
SRC_DIR: helm-charts
DEST_DIR: charts
run: |
if grep -r '^version: ' `find helm-charts/ -name "Chart.yaml"` | grep -v "${{ inputs.version }}"; then
echo "Version check failed"
exit 1
fi
git clone --branch charts-release https://github.com/opea-project/GenAIInfra.git charts
# update components
for chart in ${SRC_DIR}/common/*
do
echo "Packaging chart $chart..."
helm dependency update ${chart}
helm package $chart --destination ${DEST_DIR}
done
# update E2E Applications
for chart in ${SRC_DIR}/*
do
if [ -f $chart ]; then continue; fi
if [[ $chart =~ "common" ]]; then continue; fi
echo "Packaging chart $chart..."
helm dependency update ${chart}
helm package $chart --destination ${DEST_DIR}
done
- name: Push package to helm-charts branch and ghcr repo
run: |
set -x
cd charts
if [ "${{ inputs.artifacthub }}" = "true" ]; then
echo "Push ${{ inputs.version }} charts to charts-release branch"
helm repo index .
# Insert copyright to avoid warnings
sed -i '1s/^/# Copyright (C) 2024 Intel Corporation\n# SPDX-License-Identifier: Apache-2.0\n\n/' index.yaml
git config --global user.name "NeuralChatBot"
git config --global user.email "[email protected]"
git remote set-url origin https://NeuralChatBot:"${{ secrets.ACTION_TOKEN }}"@github.com/opea-project/GenAIInfra.git
git status
git add .
git commit -s -m "Add release ${{ inputs.version }} helm charts"
git push
fi
if [ "${{ inputs.ghcr }}" = "true" ]; then
echo "Publish charts version ${{ inputs.version }}to ghcr"
echo "${{ secrets.ACTION_TOKEN }}" | helm registry login ghcr.io -u test --password-stdin
for chart in *-${{ inputs.version }}.tgz; do
echo "Publishing ${chart}\n"
helm push ${chart} oci://ghcr.io/opea-project/charts
done
fi

0 comments on commit cd6493f

Please sign in to comment.