Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make release.yml check for pre-release #316

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
name: Release Charts

on:
push:
branches:
- main
workflow_dispatch:

jobs:
release:
runs-on: ubuntu-latest
Expand All @@ -22,7 +24,42 @@ jobs:
run: |
helm repo add bitnami https://charts.bitnami.com/bitnami

- name: Run chart-releaser
- name: Get Chart Version
id: chart_version
run: |
CHART_VERSION=$(grep '^version:' charts/*/Chart.yaml | awk '{print $2}')
echo "CHART_VERSION=$CHART_VERSION" >> $GITHUB_ENV

- name: Determine if Pre-release
id: pre_release
run: |
if [[ "$CHART_VERSION" =~ -rc|-beta|-alpha ]]; then
echo "PRERELEASE=true" >> $GITHUB_ENV
else
echo "PRERELEASE=false" >> $GITHUB_ENV
fi

- name: Run chart-releaser (Skip Pre-release in Latest)
uses: helm/[email protected]
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
with:
charts_dir: ./charts
skip_existing: true # Prevents overwriting existing latest

- name: Remove Pre-release from Latest
if: env.PRERELEASE == 'true'
run: |
# Ensure index.yaml exists
if [ -f .cr-index/index.yaml ]; then
yq eval 'del(.entries[].[] | select(.version | test(".*-(rc|beta|alpha)")))' -i .cr-index/index.yaml
git add .cr-index/index.yaml
git commit -m "Remove pre-release from index.yaml" || echo "No changes to commit"
git push origin main
fi

- name: Tag stable releases as latest
if: env.PRERELEASE == 'false'
run: |
git tag -f latest
git push origin latest --force
Loading