Skip to content

Verify that BMCSettings correctly transition to a deletable #1742

Verify that BMCSettings correctly transition to a deletable

Verify that BMCSettings correctly transition to a deletable #1742

Workflow file for this run

name: Release Helm Chart
on:
release:
types:
- published
push:
branches:
- main
tags:
- 'v*.*.*'
paths-ignore:
- 'docs/**'
- '**/*.md'
pull_request:
branches:
- main
paths-ignore:
- 'docs/**'
- '**/*.md'
types: [labeled, opened, synchronize, reopened]
jobs:
helm-chart:
name: Run chart publish
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
if: |
github.event_name == 'push' ||
(github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ok-to-charts')) ||
(github.event_name == 'release' && github.event.action == 'published')
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: v3.16.2
- name: Determine chart version
id: chart_version
run: |
if [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
# Use tag version (strip 'v' prefix)
CHART_VERSION="${GITHUB_REF#refs/tags/v}"
else
# Get the latest tag
LATEST_TAG=$(git describe --tags --abbrev=0 --match 'v[0-9]*.[0-9]*.[0-9]*' 2>/dev/null || echo "v0.0.0")
# Strip 'v' prefix
VERSION="${LATEST_TAG#v}"
# Remove prerelease/build metadata (everything after '-' or '+')
BASE_VERSION="${VERSION%%-*}"
BASE_VERSION="${BASE_VERSION%%+*}"
# Parse base version
MAJOR=$(echo $BASE_VERSION | cut -d. -f1)
MINOR=$(echo $BASE_VERSION | cut -d. -f2)
PATCH=$(echo $BASE_VERSION | cut -d. -f3)
# Increment patch version
NEXT_PATCH=$((PATCH + 1))
# Get timestamp and short SHA
TIMESTAMP=$(date -u +%Y%m%d%H%M%S)
SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7)
# Format: major.minor.patch+1-timestamp-sha
CHART_VERSION="${MAJOR}.${MINOR}.${NEXT_PATCH}-${TIMESTAMP}-${SHORT_SHA}"
fi
echo "version=$CHART_VERSION" >> $GITHUB_OUTPUT
- name: Install Kustomize
run: |
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
mv kustomize /usr/local/bin
- name: Package Helm chart with crds folder in template
run: |
helm package dist/chart --version ${{ steps.chart_version.outputs.version }}-crds
- name: Prepare CRDs folder
run: |
mkdir -p dist/chart/crds
kustomize build config/default | yq ea 'select(.kind == "CustomResourceDefinition")' > dist/chart/crds/crds.yaml
rm -rf dist/chart/templates/crd
- name: Package Helm chart with removed crds folder from template folder
run: |
helm package dist/chart --version ${{ steps.chart_version.outputs.version }}
- name: Log in to GitHub Container Registry
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push Helm chart to GHCR
run: |
helm push metal-operator-${{ steps.chart_version.outputs.version }}.tgz oci://ghcr.io/${{ github.repository_owner }}/charts
helm push metal-operator-${{ steps.chart_version.outputs.version }}-crds.tgz oci://ghcr.io/${{ github.repository_owner }}/charts