Skip to content

Commit 04c0c70

Browse files
Update version.yml (#283)
1 parent 15e3e3a commit 04c0c70

File tree

1 file changed

+89
-85
lines changed

1 file changed

+89
-85
lines changed

.github/workflows/version.yml

Lines changed: 89 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -15,93 +15,12 @@ on:
1515
- 'aws-sm-proxy/**'
1616
- 'auth-service/**'
1717

18-
permissions:
19-
contents: write
2018

21-
jobs:
22-
bump-chart:
23-
runs-on: ubuntu-latest
24-
steps:
25-
- uses: actions/checkout@v4
26-
with:
27-
token: ${{ secrets.PAT_TOKEN || secrets.GITHUB_TOKEN }}
28-
ref: ${{ github.head_ref }}
29-
fetch-depth: 0 # Needed to get diff info
30-
31-
- name: Install yq
32-
run: |
33-
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
34-
sudo chmod +x /usr/local/bin/yq
35-
36-
- name: Get changed charts
37-
id: changed-charts
38-
run: |
39-
# Get the base branch for comparison
40-
git fetch origin ${{ github.base_ref }}
41-
42-
# Find all Chart.yaml files that have been modified or are in modified directories
43-
changed_files=$(git diff --name-only origin/${{ github.base_ref }}...HEAD)
44-
45-
# Find chart directories that contain changes
46-
changed_charts=""
47-
for chart_dir in charts/*/; do
48-
if [ -d "$chart_dir" ] && [ -f "${chart_dir}Chart.yaml" ]; then
49-
chart_name=$(basename "$chart_dir")
50-
# Check if any files in this chart directory have been modified
51-
if echo "$changed_files" | grep -q "^${chart_dir}"; then
52-
changed_charts="$changed_charts $chart_name"
53-
echo "Found changes in chart: $chart_name"
54-
fi
55-
fi
56-
done
57-
58-
echo "changed_charts=$changed_charts" >> $GITHUB_OUTPUT
5919

60-
- name: Bump Chart Versions
61-
if: steps.changed-charts.outputs.changed_charts != ''
62-
run: |
63-
changed_charts="${{ steps.changed-charts.outputs.changed_charts }}"
64-
updated_charts=""
65-
66-
for chart_name in $changed_charts; do
67-
CHART_FILE="charts/$chart_name/Chart.yaml"
68-
69-
if [ -f "$CHART_FILE" ]; then
70-
current_version=$(yq eval '.version' "$CHART_FILE")
71-
72-
# Simple patch version bump
73-
IFS='.' read -ra VERSION_PARTS <<< "$current_version"
74-
major=${VERSION_PARTS[0]}
75-
minor=${VERSION_PARTS[1]}
76-
patch=${VERSION_PARTS[2]}
77-
new_patch=$((patch + 1))
78-
new_version="${major}.${minor}.${new_patch}"
79-
80-
echo "Bumping $chart_name version from $current_version to $new_version"
81-
82-
yq eval ".version = \"$new_version\"" -i "$CHART_FILE"
83-
84-
updated_charts="$updated_charts $chart_name"
85-
fi
86-
done
87-
88-
# Check if there are changes to commit
89-
if git diff --quiet charts/; then
90-
echo "No version changes to commit"
91-
exit 0
92-
fi
93-
94-
git config --local user.email "[email protected]"
95-
git config --local user.name "GitHub Action"
96-
git add charts/
97-
98-
# Create commit message with all updated charts
99-
if [ -n "$updated_charts" ]; then
100-
commit_msg="chore: bump chart versions for:$updated_charts"
101-
git commit -m "$commit_msg"
102-
git push origin ${{ github.head_ref }}
103-
fi
20+
jobs:
10421
bump-app:
22+
permissions:
23+
contents: write
10524
runs-on: ubuntu-latest
10625
steps:
10726
- uses: actions/checkout@v4
@@ -213,4 +132,89 @@ jobs:
213132
commit_msg="chore: bump app and chart versions for:$updated_apps"
214133
git commit -m "$commit_msg"
215134
git push origin ${{ github.head_ref }}
216-
fi
135+
fi
136+
137+
bump-chart:
138+
permissions:
139+
contents: write
140+
runs-on: ubuntu-latest
141+
steps:
142+
- uses: actions/checkout@v4
143+
with:
144+
token: ${{ secrets.PAT_TOKEN || secrets.GITHUB_TOKEN }}
145+
ref: ${{ github.head_ref }}
146+
fetch-depth: 0 # Needed to get diff info
147+
148+
- name: Install yq
149+
run: |
150+
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
151+
sudo chmod +x /usr/local/bin/yq
152+
153+
- name: Get changed charts
154+
id: changed-charts
155+
run: |
156+
# Get the base branch for comparison
157+
git fetch origin ${{ github.base_ref }}
158+
159+
# Find all Chart.yaml files that have been modified or are in modified directories
160+
changed_files=$(git diff --name-only origin/${{ github.base_ref }}...HEAD)
161+
162+
# Find chart directories that contain changes
163+
changed_charts=""
164+
for chart_dir in charts/*/; do
165+
if [ -d "$chart_dir" ] && [ -f "${chart_dir}Chart.yaml" ]; then
166+
chart_name=$(basename "$chart_dir")
167+
# Check if any files in this chart directory have been modified
168+
if echo "$changed_files" | grep -q "^${chart_dir}"; then
169+
changed_charts="$changed_charts $chart_name"
170+
echo "Found changes in chart: $chart_name"
171+
fi
172+
fi
173+
done
174+
175+
echo "changed_charts=$changed_charts" >> $GITHUB_OUTPUT
176+
177+
- name: Bump Chart Versions
178+
if: steps.changed-charts.outputs.changed_charts != ''
179+
run: |
180+
changed_charts="${{ steps.changed-charts.outputs.changed_charts }}"
181+
updated_charts=""
182+
183+
for chart_name in $changed_charts; do
184+
CHART_FILE="charts/$chart_name/Chart.yaml"
185+
186+
if [ -f "$CHART_FILE" ]; then
187+
current_version=$(yq eval '.version' "$CHART_FILE")
188+
189+
# Simple patch version bump
190+
IFS='.' read -ra VERSION_PARTS <<< "$current_version"
191+
major=${VERSION_PARTS[0]}
192+
minor=${VERSION_PARTS[1]}
193+
patch=${VERSION_PARTS[2]}
194+
new_patch=$((patch + 1))
195+
new_version="${major}.${minor}.${new_patch}"
196+
197+
echo "Bumping $chart_name version from $current_version to $new_version"
198+
199+
yq eval ".version = \"$new_version\"" -i "$CHART_FILE"
200+
201+
updated_charts="$updated_charts $chart_name"
202+
fi
203+
done
204+
205+
# Check if there are changes to commit
206+
if git diff --quiet charts/; then
207+
echo "No version changes to commit"
208+
exit 0
209+
fi
210+
211+
git config --local user.email "[email protected]"
212+
git config --local user.name "GitHub Action"
213+
git add charts/
214+
215+
# Create commit message with all updated charts
216+
if [ -n "$updated_charts" ]; then
217+
commit_msg="chore: bump chart versions for:$updated_charts"
218+
git commit -m "$commit_msg"
219+
git push origin ${{ github.head_ref }}
220+
fi

0 commit comments

Comments
 (0)