@@ -50,13 +50,9 @@ main() {
50
50
repo_root=$( git rev-parse --show-toplevel)
51
51
pushd " $repo_root " > /dev/null
52
52
53
- echo ' Looking up latest tag...'
54
- local latest_tag
55
- latest_tag=$( lookup_latest_tag)
56
-
57
- echo " Discovering changed charts since '$latest_tag '..."
53
+ echo " Discovering changed charts..."
58
54
local changed_charts=()
59
- readarray -t changed_charts <<< " $(lookup_changed_charts " $latest_tag " )"
55
+ readarray -t changed_charts <<< " $(lookup_changed_charts)"
60
56
61
57
if [[ -n " ${changed_charts[*]} " ]]; then
62
58
install_chart_releaser
@@ -199,38 +195,18 @@ install_chart_releaser() {
199
195
fi
200
196
}
201
197
202
- lookup_latest_tag () {
203
- git fetch --tags > /dev/null 2>&1
204
-
205
- if ! git describe --tags --abbrev=0 2> /dev/null; then
206
- git rev-list --max-parents=0 --first-parent HEAD
207
- fi
208
- }
209
-
210
- filter_charts () {
211
- while read -r chart; do
212
- [[ ! -d " $chart " ]] && continue
213
- local file=" $chart /Chart.yaml"
214
- if [[ -f " $file " ]]; then
215
- echo " $chart "
216
- else
217
- echo " WARNING: $file is missing, assuming that '$chart ' is not a Helm chart. Skipping." 1>&2
198
+ lookup_changed_charts () {
199
+ charts_dir=charts
200
+ charts=$( find " $charts_dir " -name Chart.yaml -type f -exec dirname {} +)
201
+ for chart_path in $charts ; do
202
+ chart_version=$( helm show chart $chart_path | yq eval ' .version' -)
203
+ chart_tag=" $( basename $chart_path ) -$chart_version "
204
+ if [ ! $( git tag -l $chart_tag ) ]; then
205
+ echo $chart_path
218
206
fi
219
207
done
220
208
}
221
209
222
- lookup_changed_charts () {
223
- local commit=" $1 "
224
-
225
- local changed_files
226
- changed_files=$( git diff --find-renames --name-only " $commit " -- " $charts_dir " )
227
-
228
- local depth=$(( $(tr "/ " "\n" <<< "$charts_dir " | wc - l) + 1 ))
229
- local fields=" 1-${depth} "
230
-
231
- cut -d ' /' -f " $fields " <<< " $changed_files" | uniq | filter_charts
232
- }
233
-
234
210
package_chart () {
235
211
local chart=" $1 "
236
212
0 commit comments