@@ -7,7 +7,7 @@ set export := true
77set dotenv-filename := " just.env"
88set dotenv-load := true
99
10- path := env_var (' PATH' ) + " :" + justfile_directory () + " /bin"
10+ PATH := env_var (' PATH' ) + " :" + justfile_directory () + " /bin"
1111repo := " https://github.com/SovereignCloudStack/cluster-stacks"
1212mainBranch := " main"
1313workingBranchPrefix := " chore/update-"
@@ -26,7 +26,7 @@ help: default
2626dependencies :
2727 #!/usr/bin/env bash
2828 set -euo pipefail
29- export PATH=${path}
29+
3030 if ! which csctl >/ dev/ null 2 >&1 ; then
3131 echo -e " \e [33m\e [1mcsctl not found, building it from source.\e [0m"
3232 mkdir -p bin
9292
9393
9494# Build Clusterstacks version directories according to changes in versions.yaml. Builds out directoy
95- [group (' Building Manifests' )]
95+ [group (' Build Manifests' )]
9696build-versions : dependencies
9797 #!/usr/bin/env bash
9898 set -euo pipefail
@@ -102,7 +102,7 @@ build-versions: dependencies
102102 done
103103
104104# Generate manifest for all Kubernetes Version regardless of changes to versions.
105- [group (' Building Manifests' )]
105+ [group (' Build Manifests' )]
106106build-versions-all : dependencies
107107 #!/usr/bin/env bash
108108 set -euo pipefail
@@ -114,12 +114,12 @@ build-versions-all: dependencies
114114 done
115115
116116# Generate Manifest for a specific Kubernetes version. Builds out directory
117- [group (' Building Manifests' )]
117+ [group (' Build Manifests' )]
118118build-version VERSION :
119119 #!/usr/bin/env bash
120120 set -euo pipefail
121121 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
123123 if [[ -e providers/ openstack/ out/ {{ replace (VERSION, " ." , " -" ) }} ]]; then
124124 versionsFile=" providers/openstack/scs/versions.yaml"
125125 k8sVersion=$(yq -r " .[] | select(.kubernetes | test(\" {{ replace (VERSION, " -" , " ." ) }} \" )).kubernetes" ${versionsFile})
@@ -137,10 +137,9 @@ build-version VERSION:
137137
138138
139139# Build assets for a certain Kubernetes Version. Out directory needs to be present.
140- [group (' Building Assets' )]
140+ [group (' Build Assets' )]
141141build-assets-local-for VERSION : dependencies
142142 #!/usr/bin/env bash
143- export PATH=${path}
144143 set -euo pipefail
145144 just build-version {{ VERSION }}
146145 echo -e " \e [33m\e [1mBuild Assets for {{ VERSION }} \e [0m"
@@ -153,43 +152,45 @@ build-assets-local-for VERSION: dependencies
153152 csctl create -m hash providers/ openstack/ out/ {{ replace (VERSION, " ." , " -" ) }} /
154153
155154# Build assets for a certain Kubernetes Version. Out directory needs to be present.
156- [group (' Building Assets' )]
155+ [group (' Build Assets' )]
157156build-assets-local : build-versions
158157 #!/usr/bin/env bash
159- export PATH=${path}
160158 set -euo pipefail
161159 changedVersions=$(just diff)
162160 for version in ${changedVersions[@]}; do
163161 just build-assets-local-for ${version}
164162 done
165163
166164# Build assets for a certain Kubernetes Version.
167- [group (' Building Assets' )]
165+ [group (' Build Assets' )]
168166build-assets-all-local : build-versions-all
169167 #!/usr/bin/env bash
170- export PATH=${path}
171168 set -euo pipefail
172169 versions=" $(cd providers/openstack/out/ && echo *)"
173170 for version in ${versions[@]}; do
174171 just build-assets-local-for ${version}
175172 done
176173
177174# Publish assets to OCI registry
178- [group (' Building Assets ' )]
175+ [group (' Release ' )]
179176publish-assets VERSION :
180177 #!/usr/bin/env bash
181- export PATH=${path}
182178 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
184186 else
185187 echo " Manifest directory for {{ replace (VERSION, " ." , " -" ) }} " does not exist.
186188 fi
187189
188- # Publish alles available assets to OCI registry
189- [group (' Building Assets ' )]
190+ # Publish all available assets to OCI registry
191+ [group (' Release ' )]
190192publish-assets-all :
191193 #!/usr/bin/env bash
192- export PATH=${path}
193194 set -euo pipefail
194195 versions=" $(cd providers/openstack/out/ && echo *)"
195196 for version in ${versions[@]}; do
@@ -199,19 +200,25 @@ publish-assets-all:
199200# Remove old branches that had been merged to main
200201[group (' git' )]
201202git-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
203204
204- # Create Chore branch for specific Kubernetes Version
205+ # Create chore branch and PR for specific Kubernetes Version
205206[group (' git' )]
206- git-chore-branch VERSION :
207+ git-chore-branch VERSION : && ( gh-create-chore-pr VERSION)
207208 #!/usr/bin/env bash
208209 set -euo pipefail
209210 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
211218 cp -r providers/ openstack/ out/ {{ replace (VERSION, " ." , " -" ) }} / * providers/ openstack/ scs/
212219 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, " -" , " ." ) }}
215222 git switch ${currentBranch}
216223
217224# Create chore branches for all available out versions
@@ -229,3 +236,42 @@ git-chore-branches-all:
229236 just git-chore-branch $version
230237 done
231238 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