@@ -7,7 +7,7 @@ set export := true
7
7
set dotenv-filename := " just.env"
8
8
set dotenv-load := true
9
9
10
- path := env_var (' PATH' ) + " :" + justfile_directory () + " /bin"
10
+ PATH := env_var (' PATH' ) + " :" + justfile_directory () + " /bin"
11
11
repo := " https://github.com/SovereignCloudStack/cluster-stacks"
12
12
mainBranch := " main"
13
13
workingBranchPrefix := " chore/update-"
@@ -26,7 +26,7 @@ help: default
26
26
dependencies :
27
27
#!/usr/bin/env bash
28
28
set -euo pipefail
29
- export PATH=${path}
29
+
30
30
if ! which csctl >/ dev/ null 2 >&1 ; then
31
31
echo -e " \e [33m\e [1mcsctl not found, building it from source.\e [0m"
32
32
mkdir -p bin
92
92
93
93
94
94
# Build Clusterstacks version directories according to changes in versions.yaml. Builds out directoy
95
- [group (' Building Manifests' )]
95
+ [group (' Build Manifests' )]
96
96
build-versions : dependencies
97
97
#!/usr/bin/env bash
98
98
set -euo pipefail
@@ -102,7 +102,7 @@ build-versions: dependencies
102
102
done
103
103
104
104
# Generate manifest for all Kubernetes Version regardless of changes to versions.
105
- [group (' Building Manifests' )]
105
+ [group (' Build Manifests' )]
106
106
build-versions-all : dependencies
107
107
#!/usr/bin/env bash
108
108
set -euo pipefail
@@ -114,12 +114,12 @@ build-versions-all: dependencies
114
114
done
115
115
116
116
# Generate Manifest for a specific Kubernetes version. Builds out directory
117
- [group (' Building Manifests' )]
117
+ [group (' Build Manifests' )]
118
118
build-version VERSION :
119
119
#!/usr/bin/env bash
120
120
set -euo pipefail
121
121
echo -e " \e [33m\e [1mBuild Manifests for {{ VERSION }} \e [0m"
122
- ## CHECK IF THERE IS A CHANGE IN THE COMPONENT VERSIONS
122
+ # check if there is a change in the component versions
123
123
if [[ -e providers/ openstack/ out/ {{ replace (VERSION, " ." , " -" ) }} ]]; then
124
124
versionsFile=" providers/openstack/scs/versions.yaml"
125
125
k8sVersion=$(yq -r " .[] | select(.kubernetes | test(\" {{ replace (VERSION, " -" , " ." ) }} \" )).kubernetes" ${versionsFile})
@@ -137,10 +137,9 @@ build-version VERSION:
137
137
138
138
139
139
# Build assets for a certain Kubernetes Version. Out directory needs to be present.
140
- [group (' Building Assets' )]
140
+ [group (' Build Assets' )]
141
141
build-assets-local-for VERSION : dependencies
142
142
#!/usr/bin/env bash
143
- export PATH=${path}
144
143
set -euo pipefail
145
144
just build-version {{ VERSION }}
146
145
echo -e " \e [33m\e [1mBuild Assets for {{ VERSION }} \e [0m"
@@ -153,43 +152,45 @@ build-assets-local-for VERSION: dependencies
153
152
csctl create -m hash providers/ openstack/ out/ {{ replace (VERSION, " ." , " -" ) }} /
154
153
155
154
# Build assets for a certain Kubernetes Version. Out directory needs to be present.
156
- [group (' Building Assets' )]
155
+ [group (' Build Assets' )]
157
156
build-assets-local : build-versions
158
157
#!/usr/bin/env bash
159
- export PATH=${path}
160
158
set -euo pipefail
161
159
changedVersions=$(just diff)
162
160
for version in ${changedVersions[@]}; do
163
161
just build-assets-local-for ${version}
164
162
done
165
163
166
164
# Build assets for a certain Kubernetes Version.
167
- [group (' Building Assets' )]
165
+ [group (' Build Assets' )]
168
166
build-assets-all-local : build-versions-all
169
167
#!/usr/bin/env bash
170
- export PATH=${path}
171
168
set -euo pipefail
172
169
versions=" $(cd providers/openstack/out/ && echo *)"
173
170
for version in ${versions[@]}; do
174
171
just build-assets-local-for ${version}
175
172
done
176
173
177
174
# Publish assets to OCI registry
178
- [group (' Building Assets ' )]
175
+ [group (' Release ' )]
179
176
publish-assets VERSION :
180
177
#!/usr/bin/env bash
181
- export PATH=${path}
182
178
if [[ -e providers/ openstack/ out/ {{ replace (VERSION, " ." , " -" ) }} ]]; then
183
- csctl create -m hash --publish --remote oci providers/ openstack/ out/ {{ replace (VERSION, " ." , " -" ) }} /
179
+ if [[ -n ${OCI_REGISTRY} && \
180
+ - n ${OCI_REPOSITORY} && \
181
+ (( -n ${OCI_USERNAME} && -n ${OCI_PASSWORD} ) || -n ${OCI_ACCESS_TOKEN} ) ]]; then
182
+ csctl create -m hash --publish --remote oci providers/ openstack/ out/ {{ replace (VERSION, " ." , " -" ) }} /
183
+ else
184
+ echo " Please define OCI_* Variables in just.env"
185
+ fi
184
186
else
185
187
echo " Manifest directory for {{ replace (VERSION, " ." , " -" ) }} " does not exist.
186
188
fi
187
189
188
- # Publish alles available assets to OCI registry
189
- [group (' Building Assets ' )]
190
+ # Publish all available assets to OCI registry
191
+ [group (' Release ' )]
190
192
publish-assets-all :
191
193
#!/usr/bin/env bash
192
- export PATH=${path}
193
194
set -euo pipefail
194
195
versions=" $(cd providers/openstack/out/ && echo *)"
195
196
for version in ${versions[@]}; do
@@ -199,19 +200,25 @@ publish-assets-all:
199
200
# Remove old branches that had been merged to main
200
201
[group (' git' )]
201
202
git-clean :
202
- git branch --merged | grep -Ev " (^\* |^\+ |master |main|dev )" | xargs --no-run-if -empty git branch -d
203
+ git branch --merged | grep -Ev " (^\* |^\+ |^release/ \+ |main)" | xargs --no-run-if -empty git branch -d
203
204
204
- # Create Chore branch for specific Kubernetes Version
205
+ # Create chore branch and PR for specific Kubernetes Version
205
206
[group (' git' )]
206
- git-chore-branch VERSION :
207
+ git-chore-branch VERSION : && ( gh-create-chore-pr VERSION)
207
208
#!/usr/bin/env bash
208
209
set -euo pipefail
209
210
currentBranch=$(git branch --show-current)
210
- git switch -c chore/ update-{{ replace (VERSION, " -" , " ." ) }}
211
+ if git show-ref -q --branches {{ workingBranchPrefix }}{{ replace (VERSION, " -" , " ." ) }} ; then
212
+ # Switch to branch if it exists
213
+ git switch {{ workingBranchPrefix }}{{ replace (VERSION, " -" , " ." ) }}
214
+ else
215
+ # Create branch and switch to it
216
+ git switch -c {{ workingBranchPrefix }}{{ replace (VERSION, " -" , " ." ) }}
217
+ fi
211
218
cp -r providers/ openstack/ out/ {{ replace (VERSION, " ." , " -" ) }} / * providers/ openstack/ scs/
212
219
git add providers/ openstack/ scs/
213
- git commit -s -S - m " chore(versions): Update Release for {{ replace (VERSION, " -" , " ." ) }} "
214
- # git push
220
+ git commit -s -m " chore(versions): Update Release for {{ replace (VERSION, " -" , " ." ) }} "
221
+ git push --set-upstream origin {{ workingBranchPrefix }}{{ replace (VERSION, " -" , " ." ) }}
215
222
git switch ${currentBranch}
216
223
217
224
# Create chore branches for all available out versions
@@ -229,3 +236,42 @@ git-chore-branches-all:
229
236
just git-chore-branch $version
230
237
done
231
238
fi
239
+
240
+ # Publish new release of providers/openstack/scs
241
+ [group (' Release' )]
242
+ [confirm (' Are you sure to publish a new stable release? (y|n)' )]
243
+ publish-release : dependencies
244
+ csctl create --publish --remote oci providers/ openstack/ scs/
245
+
246
+ # Login to Github with GitHub CLI
247
+ [group (' GitHub' )]
248
+ gh-login GH_TOKEN = " ${GH_TOKEN}":
249
+ #!/usr/bin/env bash
250
+ set -euo pipefail
251
+ if ! which gh >/ dev/ null 2 >&1 ; then
252
+ echo " GitHub CLI not installed."
253
+ else
254
+ if ! gh auth status >/ dev/ null 2 >&1 ; then
255
+ gh config set -h github.com git_protocol https
256
+ # If TOKEN is empty use WebUI Authentication
257
+ if [[ -z $GH_TOKEN ]]; then
258
+ gh auth login --hostname github.com
259
+ else
260
+ echo $GH_TOKEN | gh auth login --hostname github.com --with-token
261
+ fi
262
+ fi
263
+ fi
264
+
265
+ # Create chore PR for given VERSION against correspondend release branch
266
+ [group (' GitHub' )]
267
+ gh-create-chore-pr VERSION : gh-login
268
+ #!/usr/bin/env bash
269
+ set -euo pipefail
270
+ if ! which gh >/ dev/ null 2 >&1 ; then
271
+ echo " GitHub CLI not installed."
272
+ else
273
+ gh pr --title " chore(versions): Update Release for {{ replace (VERSION, " -" , " ." ) }} " \
274
+ - -head {{ workingBranchPrefix }}{{ replace (VERSION, " -" , " ." ) }} \
275
+ - -base {{ targetBranchPrefix }}{{ replace (VERSION, " -" , " ." ) }} \
276
+ - -dry-run
277
+ fi
0 commit comments