Skip to content

Commit 7a63fbf

Browse files
misc(release): plug release registry (#130)
* misc(release): plug release registry * use wget instead of curl * remove trailing new line --------- Co-authored-by: Bolaji Olajide <[email protected]>
1 parent 8cfeb71 commit 7a63fbf

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

release.yaml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ inputs:
88
- releaseId: server
99

1010
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"
1114
- name: "Github CLI"
1215
cmd: gh version
1316
fixInstructions: brew install gh
@@ -172,6 +175,27 @@ internal:
172175
echo "🚢 Please check the associated CI build to ensure the process completed".
173176
finalize:
174177
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
175199
- name: "notifications"
176200
cmd: |
177201
set -eu
@@ -254,6 +278,25 @@ promoteToPublic:
254278
echo "🚢 Please check the associated CI build to ensure the process completed".
255279
finalize:
256280
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
257300
- name: git:tag
258301
cmd: |
259302
set -eu
@@ -289,3 +332,19 @@ promoteToPublic:
289332
cat << EOF | buildkite-agent annotate --style info
290333
Promoted release is **publicly available** through a git tag at [\`{{version}}\`](https://github.com/sourcegraph/deploy-sourcegraph-k8s/tree/{{version}}).
291334
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

Comments
 (0)