-
-
Notifications
You must be signed in to change notification settings - Fork 619
150 lines (143 loc) · 6.3 KB
/
renovate-bump.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
name: "Renovate: Bump on Push"
on:
push:
branches:
- "renovate/**"
tags-ignore:
- "**"
jobs:
renovate-bump:
name: Get changed Apps
runs-on: ubuntu-22.04
container:
image: ghcr.io/truecharts/devcontainer:3.1.10@sha256:c239addf725eb5cedf79517f8089fdafdc32b5270d1893ee87ae6e511b9bcae3
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
name: Checkout
with:
fetch-depth: 0
token: ${{ secrets.BOT_TOKEN }}
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
name: Checkout
with:
fetch-depth: 0
ref: master
path: master
- name: Setting repo parent dir as safe safe.directory
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- uses: dorny/paths-filter@v2
id: filter
with:
list-files: json
filters: |
changed:
- 'charts/stable/**'
- 'charts/incubator/**'
- 'charts/SCALE/**'
- 'charts/library/**'
- 'charts/dependency/**'
- 'charts/core/**'
- 'charts/enterprise/**'
- 'charts/games/**'
- 'charts/operators/**'
- name: Filter filter-output
run: echo '${{ toJson(steps.filter.outputs) }}' > changes.json
- name: Bump and Sync
shell: bash
run: |
# Designed to ensure the appversion in Chart.yaml is in sync with the primary Chart tag if found
# Also makes sure that home link is pointing to the correct url
sync_tag() {
local chart="$1"
local chartname="$2"
local train="$3"
echo "Attempting to sync primary tag with appversion for: ${chartname}"
local tag="$(cat ${chart}/values.yaml | grep '^ tag: ' | awk -F" " '{ print $2 }' | head -1)"
tag="${tag%%@*}"
tag="${tag:-auto}"
tag=$(echo $tag | sed "s/release-//g")
tag=$(echo $tag | sed "s/release_//g")
tag=$(echo $tag | sed "s/version-//g")
tag=$(echo $tag | sed "s/version_//g")
tag="${tag#*V.}"
tag="${tag#*v-}"
tag="${tag#*v}"
tag="${tag%-*}"
tag="${tag:0:10}"
tag="${tag%-}"
tag="${tag%_}"
tag="${tag%.}"
echo "Updating tag of ${chartname} to ${tag}..."
sed -i -e "s|appVersion: .*|appVersion: \"${tag}\"|" "${chart}/Chart.yaml"
echo "Updating icon of ${chartname}..."
sed -i -e "s|icon: .*|icon: https:\/\/truecharts.org\/img\/hotlink-ok\/chart-icons\/${chartname}.png|" "${chart}/Chart.yaml"
echo "Updating home of ${chartname}..."
sed -i -e "s|home: .*|home: https:\/\/truecharts.org\/charts\/${train}\/${chartname}|" "${chart}/Chart.yaml"
echo "Attempting to update sources of ${chartname}..."
echo "Using go-yq verion: <$(go-yq -V)>"
# Get all sources (except truecharts)
curr_sources=$(go-yq '.sources[] | select(. != "https://github.com/truecharts*")' "${chart}/Chart.yaml")
# Empty sources list in-place
go-yq -i 'del(.sources.[])' "${chart}/Chart.yaml"
# Add truechart source
tcsource="https://github.com/truecharts/charts/tree/master/charts/$train/$chartname" go-yq -i '.sources += env(tcsource)' "${chart}/Chart.yaml"
# Add the rest of the sources
while IFS= read -r line; do
src="$line" go-yq -i '.sources += env(src)' "${chart}/Chart.yaml" || echo "src set error"
done <<< "$curr_sources"
echo "Sources of ${chartname} updated!"
}
export -f sync_tag
# The actual script
APPS=$(jq --raw-output '.changed_files | fromjson | .[] |= sub("(?<filepath>(?<first_directory>(?<root1>[\/]?)[^\/]+\/)(?<second_directory>(?<root2>[\/]?)[^\/]+\/)(?<third_directory>(?<root3>[\/]?)[^\/]+)(?<extra_paths>.+))"; "\(.third_directory)") | unique' changes.json | jq -r '.[]')
echo "changed apps: ${APPS[*]}"
for chart in ${APPS[*]}
do
if [[ "${chart}" == '.gitkeep' ]]; then
echo "Skipping..."
return
elif test -f "./charts/stable/${chart}/Chart.yaml"; then
train="stable"
elif test -f "./charts/incubator/${chart}/Chart.yaml"; then
train="incubator"
elif test -f "./charts/SCALE/${chart}/Chart.yaml"; then
train="SCALE"
elif test -f "./charts/library/${chart}/Chart.yaml"; then
train="library"
elif test -f "./charts/dependency/${chart}/Chart.yaml"; then
train="dependency"
elif test -f "./charts/core/${chart}/Chart.yaml"; then
train="core"
elif test -f "./charts/games/${chart}/Chart.yaml"; then
train="games"
elif test -f "./charts/enterprise/${chart}/Chart.yaml"; then
train="enterprise"
elif test -f "./charts/operators/${chart}/Chart.yaml"; then
train="operators"
else
train="incubator"
fi
echo "Comparing versions for ${train}/${chart}"
master=$(cat ./master/charts/${train}/${chart}/Chart.yaml | grep "^version")
current=$(cat ./charts/${train}/${chart}/Chart.yaml | grep "^version")
echo "master version: ${master}"
echo "current version: ${current}"
if [[ "${master}" != "${current}" ]]; then
echo "Version does not have to be bumped"
else
echo "Bumping patch version for ${train}/${chart}"
./tools/bump.sh patch ./charts/${train}/${chart}
fi
sync_tag "charts/${train}/${chart}" "${chart}" "${train}"
done
- name: Cleanup
run: |
rm -rf changes.json
rm -rf master
- name: Commit and Push new version
run: |
git config user.name "TrueCharts-Bot"
git config user.email "bot@truecharts.org"
git add --all
git commit -sm "Commit bumped Chart Version" || exit 0
git push