Skip to content

Commit 84108ed

Browse files
committed
fix: Chart version validation has been added, and now we can manually re-run the release if the release pipeline is broken due to an error.
1 parent 681e777 commit 84108ed

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

.github/workflows/manual-chart-release.yaml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,49 @@ jobs:
6565
echo "App Version: ${{ github.event.inputs.app_version }}"
6666
echo "Release Type: ${{ github.event.inputs.release_type }}"
6767
68+
# Validate semantic versioning format
6869
if [[ ! "$CHART_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
6970
echo "ERROR: Invalid chart version format. Use semantic versioning (e.g., 0.2.0)"
7071
exit 1
7172
fi
7273
74+
# Check if chart exists
7375
if [ ! -f "charts/$CHART_NAME/Chart.yaml" ]; then
7476
echo "ERROR: Chart not found: charts/$CHART_NAME/Chart.yaml"
7577
exit 1
7678
fi
7779
80+
# Get current version and compare
7881
CURRENT_VERSION=$(yq eval '.version' "charts/$CHART_NAME/Chart.yaml")
7982
echo "Current chart version: $CURRENT_VERSION"
8083
echo "New chart version: $CHART_VERSION"
8184
85+
# Prevent same version release
8286
if [ "$CURRENT_VERSION" = "$CHART_VERSION" ]; then
83-
echo "WARNING: New version is the same as current version"
87+
echo "ERROR: New version must be different from current version"
88+
echo "Current version in Chart.yaml: $CURRENT_VERSION"
89+
echo "Requested version: $CHART_VERSION"
90+
echo ""
91+
echo "Please increment the version number before releasing."
92+
exit 1
8493
fi
8594
95+
# Check if version is being incremented (not decremented)
96+
IFS='.' read -ra CURR <<< "$CURRENT_VERSION"
97+
IFS='.' read -ra NEW <<< "$CHART_VERSION"
98+
99+
CURRENT_NUM=$((CURR[0] * 10000 + CURR[1] * 100 + CURR[2]))
100+
NEW_NUM=$((NEW[0] * 10000 + NEW[1] * 100 + NEW[2]))
101+
102+
if [ $NEW_NUM -le $CURRENT_NUM ]; then
103+
echo "ERROR: New version ($CHART_VERSION) must be greater than current version ($CURRENT_VERSION)"
104+
echo ""
105+
echo "Semantic versioning requires incrementing version numbers."
106+
exit 1
107+
fi
108+
109+
echo "Version validation passed"
110+
86111
- name: Update Chart.yaml
87112
run: |
88113
CHART_NAME="${{ github.event.inputs.chart_name }}"
@@ -202,6 +227,7 @@ jobs:
202227
echo ""
203228
echo "Common issues:"
204229
echo " - Invalid version format (must be X.Y.Z)"
230+
echo " - Version not incremented properly"
205231
echo " - Chart validation errors"
206232
echo " - Git configuration issues"
207233
echo " - Missing chart files"

.github/workflows/release.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
- main
77
paths:
88
- "charts/*/Chart.yaml"
9+
workflow_dispatch:
910

1011
jobs:
1112
release:

0 commit comments

Comments
 (0)