-
Notifications
You must be signed in to change notification settings - Fork 7
133 lines (118 loc) · 4.99 KB
/
helm-release.yml
File metadata and controls
133 lines (118 loc) · 4.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: Helm Release
on:
push:
branches:
- main
jobs:
detect-changes:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
any_changed: ${{ steps.set-matrix.outputs.any_changed }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Detect changed charts with version bumps
id: set-matrix
run: |
# Get changed files in the last commit
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD)
echo "Changed files:"
echo "$CHANGED_FILES"
# Find charts with version changes
CHARTS_TO_RELEASE=()
# Check if openlit chart changed and version was bumped
if echo "$CHANGED_FILES" | grep -E "^charts/openlit/" > /dev/null; then
if echo "$CHANGED_FILES" | grep -E "^charts/openlit/Chart\.yaml$" > /dev/null; then
# Chart.yaml was modified, check if version changed
OLD_VERSION=$(git show HEAD~1:charts/openlit/Chart.yaml | grep '^version:' | awk '{print $2}')
NEW_VERSION=$(grep '^version:' charts/openlit/Chart.yaml | awk '{print $2}')
if [ "$OLD_VERSION" != "$NEW_VERSION" ]; then
echo "openlit version bumped from $OLD_VERSION to $NEW_VERSION"
CHARTS_TO_RELEASE+=("openlit")
else
echo "openlit Chart.yaml changed but version not bumped ($OLD_VERSION)"
fi
else
echo "openlit files changed but Chart.yaml not modified - no release needed"
fi
fi
# Check if openlit-operator chart changed and version was bumped
if echo "$CHANGED_FILES" | grep -E "^charts/openlit-operator/" > /dev/null; then
if echo "$CHANGED_FILES" | grep -E "^charts/openlit-operator/Chart\.yaml$" > /dev/null; then
# Chart.yaml was modified, check if version changed
OLD_VERSION=$(git show HEAD~1:charts/openlit-operator/Chart.yaml | grep '^version:' | awk '{print $2}')
NEW_VERSION=$(grep '^version:' charts/openlit-operator/Chart.yaml | awk '{print $2}')
if [ "$OLD_VERSION" != "$NEW_VERSION" ]; then
echo "openlit-operator version bumped from $OLD_VERSION to $NEW_VERSION"
CHARTS_TO_RELEASE+=("openlit-operator")
else
echo "openlit-operator Chart.yaml changed but version not bumped ($OLD_VERSION)"
fi
else
echo "openlit-operator files changed but Chart.yaml not modified - no release needed"
fi
fi
# Create matrix and set any_changed flag
if [ ${#CHARTS_TO_RELEASE[@]} -eq 0 ]; then
echo "matrix={\"include\":[]}" >> "$GITHUB_OUTPUT"
echo "any_changed=false" >> "$GITHUB_OUTPUT"
echo "No charts need to be released"
else
# Build JSON matrix manually
MATRIX_JSON="{\"include\":["
for i in "${!CHARTS_TO_RELEASE[@]}"; do
if [ $i -gt 0 ]; then
MATRIX_JSON="$MATRIX_JSON,"
fi
MATRIX_JSON="$MATRIX_JSON{\"chart\":\"${CHARTS_TO_RELEASE[$i]}\"}"
done
MATRIX_JSON="$MATRIX_JSON]}"
echo "matrix=$MATRIX_JSON" >> "$GITHUB_OUTPUT"
echo "any_changed=true" >> "$GITHUB_OUTPUT"
echo "Charts ready for release: ${CHARTS_TO_RELEASE[*]}"
fi
release:
needs: detect-changes
if: needs.detect-changes.outputs.any_changed == 'true'
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Install Helm
uses: azure/setup-helm@v4
- name: Add Helm repositories
run: |
echo "📦 Adding OpenLIT Helm repository"
helm repo add openlit https://openlit.github.io/helm/
helm repo update
echo "✅ Helm repositories added and updated"
- name: Build chart dependencies
run: |
echo "📦 Building dependencies for all charts with dependencies"
for chart in charts/*/Chart.yaml; do
chart_dir=$(dirname "$chart")
if [ -f "$chart_dir/Chart.yaml" ] && grep -q "^dependencies:" "$chart_dir/Chart.yaml"; then
echo "Building dependencies for $chart_dir"
cd "$chart_dir"
helm dependency build
cd - > /dev/null
fi
done
echo "✅ All chart dependencies built"
- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.6.0
with:
skip_existing: true
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"