Skip to content

Commit

Permalink
Allow forcing a specific chart version. (#479)
Browse files Browse the repository at this point in the history
This is useful for patch releases on older release lines.
  • Loading branch information
robholland authored Apr 10, 2024
1 parent 79d0493 commit 7c33893
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions .github/workflows/publish-charts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ on:
options:
- minor
- patch
force_version:
description: "Force a chart version (ignore Chart bump level)"
mark_latest:
description: "Mark this release as the latest"
type: boolean
default: true

jobs:
release:
Expand Down Expand Up @@ -46,19 +52,23 @@ jobs:
run: |
RE='([0-9]+)\.([0-9]+)\.([0-9]+)'
current="$(grep -m 1 '^version:' Chart.yaml | awk '{print $2}')"
NEW_VERSION="${{ github.event.inputs.force_version }}"
MAJOR=`echo $current | sed -E "s#$RE#\1#"`
MINOR=`echo $current | sed -E "s#$RE#\2#"`
PATCH=`echo $current | sed -E "s#$RE#\3#"`
if [ -z "${NEW_VERSION}" ]; then
current="$(grep -m 1 '^version:' Chart.yaml | awk '{print $2}')"
if [ "${{ github.event.inputs.bump }}" == "minor" ]; then
MINOR=$((MINOR+1))
PATCH=0
else
PATCH=$((PATCH+1))
MAJOR=`echo $current | sed -E "s#$RE#\1#"`
MINOR=`echo $current | sed -E "s#$RE#\2#"`
PATCH=`echo $current | sed -E "s#$RE#\3#"`
if [ "${{ github.event.inputs.bump }}" == "minor" ]; then
MINOR=$((MINOR+1))
PATCH=0
else
PATCH=$((PATCH+1))
fi
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
fi
NEW_VERSION="$MAJOR.$MINOR.$PATCH"
sed -i -e "s/^version: .*/version: $NEW_VERSION/" Chart.yaml
sed -i -e "s/^appVersion: .*/appVersion: ${{ github.event.inputs.version }}/" Chart.yaml
Expand All @@ -73,5 +83,7 @@ jobs:

- name: Run chart-releaser
uses: helm/[email protected]
with:
mark_as_latest: "${{ github.event.inputs.mark_latest }}"
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

0 comments on commit 7c33893

Please sign in to comment.