Skip to content

Commit

Permalink
automatically bump minor versions
Browse files Browse the repository at this point in the history
  • Loading branch information
schoren committed Jun 14, 2024
1 parent ec55e4d commit 43ad4bf
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .github/workflows/release-charts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ jobs:
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

- name: Install pybump
run: |
python3 -m pip install --upgrade pip
pip install pybump
- name: Bump Chart Versions
run: scripts/bump-charts.sh

- name: Run chart-releaser
uses: helm/[email protected]
env:
Expand Down
2 changes: 1 addition & 1 deletion charts/tracetest-onprem/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: tracetest-onprem
description: A Helm chart for tracetest On Prem
type: application
version: 1.104.0
version: 1.0.0
dependencies:
- name: tracetest-core
version: 1.0.0
Expand Down
52 changes: 52 additions & 0 deletions scripts/bump_charts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

ONPREM_CHART_FILE="charts/tracetest-onprem/Chart.yaml"
ONPREM_CHART_NAME="tracetest-onprem"

changed_charts=$(git --no-pager diff --name-only HEAD~1 charts | grep '/' | cut -d'/' -f1-2 | uniq)

# If no changed charts, exit with a message
if [[ -z "$changed_charts" ]]; then
echo "No charts have been changed."
exit 0
fi

# Loop through the unique charts and run pybump on each Chart.yaml
for chart in $changed_charts; do
chartName=$(basename "$chart")
if [[ "$chartName" == "$ONPREM_CHART_NAME" ]]; then
continue
fi

echo "Running pybump on $chart/Chart.yaml"
newChartVersion=$(pybump bump --file "$chart/Chart.yaml" --level minor)

if [[ $? -ne 0 ]]; then
echo "Error occurred while running pybump on $chart/Chart.yaml"
exit 1
fi

echo "Update $chartName to $newChartVersion in $ONPREM_CHART_FILE"
yq eval '.dependencies[] |= (select(.name == "'"$chartName"'").version = "'"$newChartVersion"'")' "$ONPREM_CHART_FILE" -i

if [[ $? -ne 0 ]]; then
echo "Error occurred while updating $chartName in $ONPREM_CHART_FILE"
exit 1
fi

git add "$chart/Chart.yaml"
done

echo "Bumping version of $ONPREM_CHART_FILE"
newVersion=$(pybump bump --file "$ONPREM_CHART_FILE" --level minor)
if [[ $? -ne 0 ]]; then
echo "Error occurred while bumping the minor version of $ONPREM_CHART_FILE"
exit 1
fi
echo "Updated version: $newVersion"

git add $ONPREM_CHART_FILE

git status
git commit -m "Update tracetest-onprem version to $newVersion"
git push --force-with-lease

0 comments on commit 43ad4bf

Please sign in to comment.