|
8 | 8 | - releaseId: server |
9 | 9 |
|
10 | 10 | requirements: |
| 11 | + # We use wget here, because curl --fail-with-body was introduced in a version ulterior to what we can have on the CI agents. |
| 12 | + - name: "wget" |
| 13 | + cmd: "wget --help" |
11 | 14 | - name: "Github CLI" |
12 | 15 | cmd: gh version |
13 | 16 | fixInstructions: brew install gh |
@@ -172,6 +175,27 @@ internal: |
172 | 175 | echo "🚢 Please check the associated CI build to ensure the process completed". |
173 | 176 | finalize: |
174 | 177 | steps: |
| 178 | + - name: 'Register on release registry' |
| 179 | + cmd: | |
| 180 | + echo "Registering internal deploy-sourcegraph-k8s {{version}} release on release registry" |
| 181 | + COMMIT_SHA=$(git rev-parse HEAD) |
| 182 | + body=$(wget --content-on-error -O- --header="Content-Type: application/json" --header="Authorization: ${RELEASE_REGISTRY_TOKEN}" --post-data '{ |
| 183 | + "name": "k8s", |
| 184 | + "version": "{{version}}", |
| 185 | + "git_sha": "'${COMMIT_SHA}'" |
| 186 | + }' "https://releaseregistry.sourcegraph.com/v1/releases") |
| 187 | + exit_code=$? |
| 188 | +
|
| 189 | + if [ $exit_code != 0 ]; then |
| 190 | + echo "❌ Failed to create release in release registry, got:" |
| 191 | + echo "--- raw body ---" |
| 192 | + echo $body |
| 193 | + echo "--- raw body ---" |
| 194 | + exit $exit_code |
| 195 | + else |
| 196 | + echo "Release created, see:" |
| 197 | + echo $body | jq .web_url |
| 198 | + fi |
175 | 199 | - name: "notifications" |
176 | 200 | cmd: | |
177 | 201 | set -eu |
@@ -254,6 +278,25 @@ promoteToPublic: |
254 | 278 | echo "🚢 Please check the associated CI build to ensure the process completed". |
255 | 279 | finalize: |
256 | 280 | steps: |
| 281 | + - name: 'validate promotion criteria' |
| 282 | + cmd: | |
| 283 | + echo "validating promotion criteria" |
| 284 | + body=$(wget --content-on-error -O- --header="Content-Type: application/json" "https://releaseregistry.sourcegraph.com/v1/releases/k8s/{{version}}") |
| 285 | + exit_code=$? |
| 286 | +
|
| 287 | + if [ $exit_code != 0 ]; then |
| 288 | + echo "❌ Failed to fetch release on release registry, got:" |
| 289 | + echo "--- raw body ---" |
| 290 | + echo $body |
| 291 | + echo "--- raw body ---" |
| 292 | + exit $exit_code |
| 293 | + fi |
| 294 | +
|
| 295 | + is_development=$(echo "$body" | jq -r '.is_development') |
| 296 | + if [ "$is_development" = "true" ]; then |
| 297 | + echo "cannot promote a development release" |
| 298 | + exit 1 |
| 299 | + fi |
257 | 300 | - name: git:tag |
258 | 301 | cmd: | |
259 | 302 | set -eu |
@@ -289,3 +332,19 @@ promoteToPublic: |
289 | 332 | cat << EOF | buildkite-agent annotate --style info |
290 | 333 | Promoted release is **publicly available** through a git tag at [\`{{version}}\`](https://github.com/sourcegraph/deploy-sourcegraph-k8s/tree/{{version}}). |
291 | 334 | EOF |
| 335 | + - name: 'Promote on release registry' |
| 336 | + cmd: | |
| 337 | + echo "Promoting deploy-sourcegraph-k8s {{version}} release on release registry" |
| 338 | + body=$(wget --content-on-error -O- --header="Content-Type: application/json" --header="Authorization: ${RELEASE_REGISTRY_TOKEN}" --post-data '' "https://releaseregistry.sourcegraph.com/v1/releases/k8s/{{version}}/promote") |
| 339 | + exit_code=$? |
| 340 | +
|
| 341 | + if [ $exit_code != 0 ]; then |
| 342 | + echo "❌ Failed to promote release on release registry, got:" |
| 343 | + echo "--- raw body ---" |
| 344 | + echo $body |
| 345 | + echo "--- raw body ---" |
| 346 | + exit $exit_code |
| 347 | + else |
| 348 | + echo "Build created, see:" |
| 349 | + echo $body | jq .web_url |
| 350 | + fi |
0 commit comments