11#! /bin/bash
22
3- # Copyright 2024-2025 Hewlett Packard Enterprise Development LP
3+ # Copyright 2024-2026 Hewlett Packard Enterprise Development LP
44# Other additional copyright holders may be indicated within.
55#
66# The entirety of this work is licensed under the Apache License,
@@ -277,6 +277,34 @@ verify_crd_conversions() {
277277 fi
278278}
279279
280+ verify_clean_build () {
281+ local repo_url=" $1 "
282+ local default_branch=" $2 "
283+ local indent=" $3 "
284+
285+ msg " ${indent} Verifying clean build on GitHub for $default_branch ..."
286+ build_status=$( gh run list --repo " $repo_url " --branch " $default_branch " --limit 1 --json conclusion -q ' .[0].conclusion' 2> /dev/null || echo " unknown" )
287+ if [[ " $build_status " != " success" ]]; then
288+ do_fail " Build status for $default_branch : $build_status (expected: success)" " $indent "
289+ fi
290+ }
291+
292+ # A master branch should have only one chart, and it must be in the charts/
293+ # directory. The chart-releases/ directory will be present only in the release
294+ # branch.
295+ verify_master_one_chart () {
296+ local indent=" $1 "
297+
298+ if [[ -d chart-releases ]]; then
299+ do_fail " ${indent} Expected no chart-releases/ in master branch; the master branch should use charts/ for its charts."
300+ fi
301+ if [[ -d charts ]]; then
302+ if [[ $( find charts/ -maxdepth 1 -mindepth 1 -type d | wc -l | tr -d ' ' ) != 1 ]]; then
303+ do_fail " ${indent} Expected exactly one chart version in charts/ directory."
304+ fi
305+ fi
306+ }
307+
280308# Peer modules refers to the other DWS/NNF modules listed in go.mod.
281309check_peer_modules () {
282310 local indent=" $1 "
@@ -470,11 +498,35 @@ find_latest_release(){
470498 echo " $latest_tag "
471499}
472500
501+ # Update the helm chart version dir in the release branch repo, from the one
502+ # found in the master branch.
503+ update_release_helm_chart_dir () {
504+ local release_ver=" $1 "
505+ local indent=" $2 "
506+
507+ if [[ -d charts ]]; then
508+ if [[ ! -d chart-releases ]]; then
509+ mkdir chart-releases || do_fail " ${indent} Unable to create chart-releases/ directory for release branch."
510+ fi
511+ if [[ $( find chart-releases/ -maxdepth 1 -mindepth 1 -type d | wc -l) -gt 0 ]]; then
512+ git rm -rf chart-releases/* / || echo " No charts to remove"
513+ fi
514+ cp -r charts/* chart-releases/ || do_fail " ${indent} Unable to copy chart from charts/ to chart-releases/ for release branch."
515+ # Rename the chart version dir from its existing chart-releases/v* to
516+ # the new chart-releases/v$release_ver.
517+ # We let the chart version match the app version; the chart and the app
518+ # live in the same repo, so this kind of makes sense.
519+ chartvdir=$( find chart-releases -maxdepth 1 -type d -name ' v*' | head -n 1)
520+ mv " $chartvdir " " chart-releases/v$release_ver " || do_fail " ${indent} Unable to rename chart directory"
521+ fi
522+ }
523+
473524# Update versions where the release is referring to itself.
474525update_own_release_references () {
475526 local repo_short_name=" $1 "
476527 local vrelease_ver=" $2 "
477- local indent=" $3 "
528+ local branch=" $3 "
529+ local indent=" $4 "
478530 local release_ver
479531
480532 # Strip the leading 'v'.
@@ -494,11 +546,15 @@ update_own_release_references() {
494546 # This one also has a helm chart. Use `yq -i e` to do an in-place edit
495547 # with the yq that is written in Go. The yq written in Python uses
496548 # `-yi`.
497- chartvalues=" charts/lustre-csi-driver/values.yaml"
498- yq -i e -M ' (.deployment.tag) = "' " $release_ver " ' "' " $chartvalues " || do_fail " ${indent} Unable to update release version in helm chart"
499- chart=" charts/lustre-csi-driver/Chart.yaml"
500- yq -i e -M ' (.appVersion) = "' " $release_ver " ' "' " $chart " || do_fail " ${indent} Unable to update appVersion in helm chart"
501- git add " $chartvalues " " $chart "
549+ update_release_helm_chart_dir " $release_ver " " $indent "
550+ make helm-app-version CHART_DIR=chart-releases VERSION=" $release_ver " || do_fail " ${indent} Unable to update app version in helm chart"
551+ # Use the chart-releases/v* dir name as the chart version:
552+ make helm-chart-version CHART_DIR=chart-releases || do_fail " ${indent} Unable to update helm chart version"
553+ # Make the new chart package and chart repo index, so when this is
554+ # pushed, github will act like a chart repo.
555+ make helm-repackage CHART_DIR=chart-releases || do_fail " ${indent} Unable to repackage the helm chart"
556+ make helm-reindex CHART_DIR=chart-releases CHART_BRANCH=" $branch " || do_fail " ${indent} Unable to reindex the helm chart"
557+ git add chart-releases
502558 ;;
503559 lustre_fs_operator)
504560 k_yaml=" config/manager"
@@ -663,13 +719,16 @@ check_repo_master() {
663719 msg " Repo $repo_name /$default_branch :"
664720 begin_with_clean_workarea " $repo_name " " $indent "
665721
722+ verify_clean_build " $repo_url " " $default_branch " " $indent "
723+
666724 clone_checkout_fresh_workarea " $repo_name " " $repo_url " " $default_branch " " $indent "
667725
668726 if [[ $repo_short_name != nnf_deploy ]] && [[ $repo_short_name != nnf_ec ]]; then
669727 check_auto_gens " $indent "
670728 fi
671729 verify_clean_workarea " $indent "
672730 verify_crd_conversions " $indent "
731+ verify_master_one_chart " $indent "
673732
674733 check_peer_modules " $indent "
675734 verify_clean_workarea " $indent "
@@ -696,6 +755,9 @@ check_repo_release_vX() {
696755 msg " Merge default branch $default_branch "
697756 begin_with_clean_workarea " $repo_name " " $indent "
698757
758+ verify_clean_build " $repo_url " " $default_branch " " $indent "
759+ verify_clean_build " $repo_url " " $branch " " $indent "
760+
699761 clone_checkout_fresh_workarea " $repo_name " " $repo_url " " $branch " " $indent "
700762
701763 latest_release=$( git describe --match=" v*" --abbrev=0 HEAD) || do_fail " ${indent} Failure getting latest release tag."
@@ -795,7 +857,7 @@ check_repo_release_vX() {
795857
796858 if [[ $( git log --oneline " $branch ...HEAD" | wc -l) -gt 0 ]]; then
797859 # We have updates, so let's designate a new release.
798- update_own_release_references " $repo_short_name " " $new_release " " $indent "
860+ update_own_release_references " $repo_short_name " " $new_release " " $branch " " $ indent"
799861 has_changes=true
800862 else
801863 msg " ${indent} No new changes to release for $repo_name ."
0 commit comments