-
Notifications
You must be signed in to change notification settings - Fork 26
236 lines (205 loc) · 7.98 KB
/
Copy pathmanual-chart-release.yaml
File metadata and controls
236 lines (205 loc) · 7.98 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
name: Manual Chart Release
on:
workflow_dispatch:
inputs:
chart_version:
description: "New chart version (e.g., 0.2.0)"
required: true
type: string
app_version:
description: "App version compatibility (e.g., 2025.8.1)"
required: true
type: string
release_type:
description: "Type of release"
required: true
type: choice
default: "minor"
options:
- patch
- minor
- major
- hotfix
release_notes:
description: "Release notes (what changed in the chart)"
required: false
type: string
default: "Manual chart release"
chart_name:
description: "Chart name to release"
required: true
type: choice
default: "hoppscotch"
options:
- hoppscotch
- she
- shc
jobs:
manual-chart-release:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Install yq
run: |
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
sudo chmod +x /usr/local/bin/yq
- name: Validate Inputs
run: |
CHART_VERSION="${{ github.event.inputs.chart_version }}"
CHART_NAME="${{ github.event.inputs.chart_name }}"
echo "Validating inputs..."
echo "Chart: $CHART_NAME"
echo "Chart Version: $CHART_VERSION"
echo "App Version: ${{ github.event.inputs.app_version }}"
echo "Release Type: ${{ github.event.inputs.release_type }}"
# Validate semantic versioning format
if [[ ! "$CHART_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "ERROR: Invalid chart version format. Use semantic versioning (e.g., 0.2.0)"
exit 1
fi
# Check if chart exists
if [ ! -f "charts/$CHART_NAME/Chart.yaml" ]; then
echo "ERROR: Chart not found: charts/$CHART_NAME/Chart.yaml"
exit 1
fi
# Get current version and compare
CURRENT_VERSION=$(yq eval '.version' "charts/$CHART_NAME/Chart.yaml")
echo "Current chart version: $CURRENT_VERSION"
echo "New chart version: $CHART_VERSION"
# Prevent same version release
if [ "$CURRENT_VERSION" = "$CHART_VERSION" ]; then
echo "ERROR: New version must be different from current version"
echo "Current version in Chart.yaml: $CURRENT_VERSION"
echo "Requested version: $CHART_VERSION"
echo ""
echo "Please increment the version number before releasing."
exit 1
fi
# Check if version is being incremented (not decremented)
IFS='.' read -ra CURR <<< "$CURRENT_VERSION"
IFS='.' read -ra NEW <<< "$CHART_VERSION"
CURRENT_NUM=$((CURR[0] * 10000 + CURR[1] * 100 + CURR[2]))
NEW_NUM=$((NEW[0] * 10000 + NEW[1] * 100 + NEW[2]))
if [ $NEW_NUM -le $CURRENT_NUM ]; then
echo "ERROR: New version ($CHART_VERSION) must be greater than current version ($CURRENT_VERSION)"
echo ""
echo "Semantic versioning requires incrementing version numbers."
exit 1
fi
echo "Version validation passed"
- name: Update Chart.yaml
run: |
CHART_NAME="${{ github.event.inputs.chart_name }}"
CHART_VERSION="${{ github.event.inputs.chart_version }}"
APP_VERSION="${{ github.event.inputs.app_version }}"
CHART_FILE="charts/$CHART_NAME/Chart.yaml"
cp "$CHART_FILE" "$CHART_FILE.backup"
yq eval '.version = "'$CHART_VERSION'"' -i "$CHART_FILE"
yq eval '.appVersion = "'$APP_VERSION'"' -i "$CHART_FILE"
echo "Updated $CHART_FILE:"
echo " Chart version: $CHART_VERSION"
echo " App version: $APP_VERSION"
echo ""
echo "Changes made:"
diff "$CHART_FILE.backup" "$CHART_FILE" || true
rm "$CHART_FILE.backup"
- name: Setup Helm
uses: azure/setup-helm@v4
with:
version: v3.14.4
- name: Build Chart Dependencies
run: |
CHART_NAME="${{ github.event.inputs.chart_name }}"
echo "Building chart dependencies for charts/$CHART_NAME..."
cd charts/$CHART_NAME
if grep -q "dependencies:" Chart.yaml; then
echo "Chart dependencies found:"
cat Chart.yaml | grep -A 10 "dependencies:"
echo ""
echo "Building dependencies from OCI repositories..."
helm dependency build
echo "Chart dependencies built successfully"
if [ -d "charts" ]; then
echo "Downloaded dependencies:"
ls -la charts/
fi
else
echo "No dependencies defined in Chart.yaml"
fi
- name: Validate Chart
run: |
CHART_NAME="${{ github.event.inputs.chart_name }}"
echo "Testing template generation..."
helm template test-release charts/$CHART_NAME > /dev/null
echo "Chart validation passed"
- name: Commit Changes
run: |
CHART_NAME="${{ github.event.inputs.chart_name }}"
CHART_VERSION="${{ github.event.inputs.chart_version }}"
APP_VERSION="${{ github.event.inputs.app_version }}"
RELEASE_TYPE="${{ github.event.inputs.release_type }}"
RELEASE_NOTES="${{ github.event.inputs.release_notes }}"
git add charts/$CHART_NAME/Chart.yaml
if git diff --staged --quiet; then
echo "No changes to commit"
echo "skip_release=true" >> $GITHUB_ENV
exit 0
fi
git commit -m "chore(release): bump $CHART_NAME chart to v$CHART_VERSION" \
-m "App version: $APP_VERSION" \
-m "Release type: $RELEASE_TYPE" \
-m "$RELEASE_NOTES"
- name: Push Changes
if: env.skip_release != 'true'
run: |
echo "Pushing changes to main branch..."
git push origin main
echo "Changes pushed successfully"
- name: Wait for Release Workflow
if: env.skip_release != 'true'
run: |
echo "Waiting for automatic release workflow to trigger..."
echo "The 'Release charts' workflow will:"
echo " 1. Build chart dependencies"
echo " 2. Package the chart"
echo " 3. Create GitHub release"
echo " 4. Update Helm repository index"
sleep 10
- name: Success Summary
run: |
CHART_VERSION="${{ github.event.inputs.chart_version }}"
RELEASE_TYPE="${{ github.event.inputs.release_type }}"
if [ "${{ env.skip_release }}" = "true" ]; then
echo "No release created - no changes detected"
else
echo "Chart Release Initiated Successfully"
echo ""
echo "Chart: ${{ github.event.inputs.chart_name }}"
echo "Version: $CHART_VERSION"
echo "Type: $RELEASE_TYPE"
echo "App Version: ${{ github.event.inputs.app_version }}"
echo ""
fi
- name: Failure Summary
if: failure()
run: |
echo "Chart Release Failed"
echo ""
echo "Please check the logs above for details."
echo ""
echo "Common issues:"
echo " - Invalid version format (must be X.Y.Z)"
echo " - Version not incremented properly"
echo " - Chart validation errors"
echo " - Git configuration issues"
echo " - Missing chart files"
echo " - Dependency build failures"