Skip to content

Commit 759cc1b

Browse files
feat: batch change flavour of release.yaml (#1228)
<!-- description here --> testing batch change automated release.yaml without git commands, since batch changes HAS TO handle that for us ### Checklist <!-- Kubernetes and Docker Compose MUST be kept in sync. You should not merge a change here without a corresponding change in the other repository, unless it truly is specific to this repository. If uneeded, add link or explanation of why it is not needed here. --> * [ ] Sister [deploy-sourcegraph](https://github.com/sourcegraph/deploy-sourcegraph) change: * [ ] Sister [customer-replica](https://github.com/sourcegraph/deploy-sourcegraph-docker-customer-replica-1) change (if necessary, for any changes affecting pure-docker or configuration): * [ ] All images have a valid tag and SHA256 sum ### Test plan testing through temporal + batch changes <!-- As part of SOC2/GN-104 and SOC2/GN-105 requirements, all pull requests are REQUIRED to provide a "test plan". A test plan is a loose explanation of what you have done or implemented to test this, as outlined in our Testing principles and guidelines: https://docs.sourcegraph.com/dev/background-information/testing_principles Write your test plan here after the "Test plan" header. -->
1 parent d7ddf22 commit 759cc1b

File tree

1 file changed

+226
-0
lines changed

1 file changed

+226
-0
lines changed

batch-change/release.yaml

Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
meta:
2+
productName: "deploy-sourcegraph-docker"
3+
owners:
4+
- "@sourcegraph/release"
5+
repository: "github.com/sourcegraph/deploy-sourcegraph-docker"
6+
7+
inputs:
8+
- releaseId: server
9+
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"
14+
- name: "GitHub cli exists"
15+
cmd: "which gh"
16+
fixInstructions: "install GitHub cli"
17+
- name: "Docker username"
18+
env: "DOCKER_USERNAME"
19+
- name: "Docker password"
20+
env: "DOCKER_PASSWORD"
21+
- name: "GH auth status"
22+
cmd: "gh auth status"
23+
fixInstructions: "gh auth login"
24+
25+
internal:
26+
# Please keep in mind that the CI pipeline uses the branch names defined below when creating releases.
27+
# Therefore, if you update them, or if you decide to change how we detect what kind of build we're dealing
28+
# with, please update this file as well.
29+
create:
30+
steps:
31+
patch:
32+
- name: docker(compose):tags
33+
cmd: |
34+
set -eu
35+
registry=us-central1-docker.pkg.dev/sourcegraph-ci/rfc795-internal
36+
sg ops update-images --registry ${registry} --kind compose --pin-tag {{inputs.server.tag}} --docker-username $DOCKER_USERNAME --docker-password $DOCKER_PASSWORD ../docker-compose/
37+
- name: docker(shell):tags
38+
cmd: |
39+
set -eu
40+
registry=us-central1-docker.pkg.dev/sourcegraph-ci/rfc795-internal
41+
sg ops update-images --registry ${registry} --kind pure-docker --pin-tag {{inputs.server.tag}} --docker-username $DOCKER_USERNAME --docker-password $DOCKER_PASSWORD ../pure-docker/
42+
minor:
43+
- name: docker(compose):tags
44+
cmd: |
45+
set -eu
46+
registry=us-central1-docker.pkg.dev/sourcegraph-ci/rfc795-internal
47+
sg ops update-images --registry ${registry} --kind compose --pin-tag {{inputs.server.tag}} --docker-username $DOCKER_USERNAME --docker-password $DOCKER_PASSWORD ../docker-compose/
48+
- name: docker(shell):tags
49+
cmd: |
50+
set -eu
51+
registry=us-central1-docker.pkg.dev/sourcegraph-ci/rfc795-internal
52+
sg ops update-images --registry ${registry} --kind pure-docker --pin-tag {{inputs.server.tag}} --docker-username $DOCKER_USERNAME --docker-password $DOCKER_PASSWORD ../pure-docker/
53+
major:
54+
- name: docker(compose):tags
55+
cmd: |
56+
set -eu
57+
registry=us-central1-docker.pkg.dev/sourcegraph-ci/rfc795-internal
58+
sg ops update-images --registry ${registry} --kind compose --pin-tag {{inputs.server.tag}} --docker-username $DOCKER_USERNAME --docker-password $DOCKER_PASSWORD ../docker-compose/
59+
- name: docker(shell):tags
60+
cmd: |
61+
set -eu
62+
registry=us-central1-docker.pkg.dev/sourcegraph-ci/rfc795-internal
63+
sg ops update-images --registry ${registry} --kind pure-docker --pin-tag {{inputs.server.tag}} --docker-username $DOCKER_USERNAME --docker-password $DOCKER_PASSWORD ../pure-docker/
64+
finalize:
65+
steps:
66+
- name: "git:finalize"
67+
cmd: |
68+
set -eu
69+
70+
branch="internal/release-{{version}}"
71+
72+
# Post a comment on the PR.
73+
cat << EOF | gh pr comment "$branch" --body-file -
74+
- :green_circle: Internal release is ready for promotion!
75+
- :warning: Do not close/merge that pull request or delete the associated branch if you intend to promote it.
76+
EOF
77+
78+
# Post an annotation.
79+
cat << EOF | buildkite-agent annotate --style info
80+
Internal release is ready for promotion under the branch [\`$branch\`](https://github.com/sourcegraph/deploy-sourcegraph-docker/tree/$branch).
81+
EOF
82+
83+
- name: 'Register on release registry'
84+
cmd: |
85+
echo "Registering internal deploy-sourcegraph-docker {{version}} release on release registry"
86+
COMMIT_SHA=$(git rev-parse HEAD)
87+
body=$(wget --content-on-error -O- --header="Content-Type: application/json" --header="Authorization: ${RELEASE_REGISTRY_TOKEN}" --post-data '{
88+
"name": "docker",
89+
"version": "{{version}}",
90+
"git_sha": "'${COMMIT_SHA}'"
91+
}' "https://releaseregistry.sourcegraph.com/v1/releases")
92+
exit_code=$?
93+
94+
if [ $exit_code != 0 ]; then
95+
echo "❌ Failed to create release in release registry, got:"
96+
echo "--- raw body ---"
97+
echo $body
98+
echo "--- raw body ---"
99+
exit $exit_code
100+
else
101+
echo "Release created, see:"
102+
echo $body
103+
fi
104+
105+
test:
106+
steps:
107+
- name: "Placeholder"
108+
cmd: |
109+
echo "Test"
110+
111+
promoteToPublic:
112+
create:
113+
steps:
114+
- name: "git"
115+
cmd: |
116+
set -eu
117+
branch="internal/release-{{version}}"
118+
git fetch origin "${branch}"
119+
git switch "${branch}"
120+
- name: docker(compose):tags
121+
cmd: |
122+
set -eu
123+
registry=index.docker.io/sourcegraph
124+
sg ops update-images --registry ${registry} --kind compose --pin-tag {{inputs.server.tag}} --docker-username $DOCKER_USERNAME --docker-password $DOCKER_PASSWORD ../docker-compose/
125+
- name: docker(shell):tags
126+
cmd: |
127+
set -eu
128+
registry=index.docker.io/sourcegraph
129+
sg ops update-images --registry ${registry} --kind pure-docker --pin-tag {{inputs.server.tag}} --docker-username $DOCKER_USERNAME --docker-password $DOCKER_PASSWORD ../pure-docker/
130+
finalize:
131+
steps:
132+
- name: 'Promote on release registry'
133+
cmd: |
134+
echo "Promoting deploy-sourcegraph-docker {{version}} release on release registry"
135+
body=$(wget --content-on-error -O- --header="Content-Type: application/json" --header="Authorization: ${RELEASE_REGISTRY_TOKEN}" --post-data '' "https://releaseregistry.sourcegraph.com/v1/releases/docker/{{version}}/promote")
136+
exit_code=$?
137+
138+
if [ $exit_code != 0 ]; then
139+
echo "❌ Failed to promote release on release registry, got:"
140+
echo "--- raw body ---"
141+
echo $body
142+
echo "--- raw body ---"
143+
exit $exit_code
144+
else
145+
echo "Release promoted, see:"
146+
echo $body
147+
fi
148+
- name: git:tag
149+
cmd: |
150+
set -eu
151+
152+
# Branches
153+
internal_branch="internal/release-{{version}}"
154+
promote_branch="promote/release-{{version}}"
155+
release_branch="release-{{version}}"
156+
157+
# Create the final branch holding the tagged commit
158+
git checkout "${promote_branch}"
159+
git switch -c "${release_branch}"
160+
161+
git tag {{version}}
162+
git push origin ${release_branch} --tags
163+
164+
# Web URL to the tag
165+
tag_url="https://github.com/sourcegraph/deploy-sourcegraph-docker/tree/{{version}}"
166+
167+
# Annotate PRs
168+
cat << EOF | gh pr comment "$internal_branch" --body-file -
169+
- :green_circle: Release has been promoted, see tag: $tag_url.
170+
- :no_entry: Do not under any circumstance delete the branch holding the tagged commit (i.e. \`$release_branch\`).
171+
- :arrow_right: You can safely close that PR and delete its associated branch.
172+
EOF
173+
174+
cat << EOF | gh pr comment "$promote_branch" --body-file -
175+
- :green_circle: Release has been promoted, see tag: $tag_url.
176+
- :no_entry: Do not under any circumstance delete the branch holding the tagged commit (i.e. \`$release_branch\`).
177+
- :arrow_right: You can safely close that PR and delete its associated branch.
178+
EOF
179+
180+
# Annotate build
181+
cat << EOF | buildkite-agent annotate --style info
182+
Promoted release is **publicly available** through a git tag at [\`{{version}}\`](https://github.com/sourcegraph/deploy-sourcegraph-docker/tree/{{version}}).
183+
EOF
184+
185+
- name: "update main with latest version"
186+
cmd: |
187+
set -eu
188+
branch="promote/release-{{version}}-update-main"
189+
echo "Checking out origin/main"
190+
git fetch origin main
191+
git switch main
192+
echo "Creating branch origin/${branch}"
193+
git switch -c "${branch}"
194+
195+
- name: docker(compose):tags
196+
cmd: |
197+
set -eu
198+
registry=index.docker.io/sourcegraph
199+
sg ops update-images --registry ${registry} --kind compose --pin-tag {{inputs.server.tag}} --docker-username $DOCKER_USERNAME --docker-password $DOCKER_PASSWORD ../docker-compose/
200+
201+
- name: docker(shell):tags
202+
cmd: |
203+
set -eu
204+
registry=index.docker.io/sourcegraph
205+
sg ops update-images --registry ${registry} --kind pure-docker --pin-tag {{inputs.server.tag}} --docker-username $DOCKER_USERNAME --docker-password $DOCKER_PASSWORD ../pure-docker/
206+
207+
- name: "git:branch"
208+
cmd: |
209+
set -eu
210+
branch="promote/release-{{version}}-update-main"
211+
git commit -am 'prep update main: {{version}}' -m 'update main with latest release'
212+
git push origin "${branch}"
213+
214+
- name: "github:pr"
215+
cmd: |
216+
set -eu
217+
internal_branch="promote/release-{{version}}-update-main"
218+
# we need to fetch from origin just in case this branch doesn't exist locally, so that the PR can find the base
219+
git fetch origin main
220+
gh pr create \
221+
--fill \
222+
--draft \
223+
--base "main" \
224+
--title "Update main: build {{version}}" \
225+
--body "Test plan: automated release PR, CI will perform additional checks"
226+
echo "🚢 Please check the associated CI build to ensure the process completed"

0 commit comments

Comments
 (0)