Skip to content

Commit 4d8f228

Browse files
burmudarjhchabran
andauthored
rfc795: add release manifest (#965)
* initial manifest * update manifest - similar flow to k8s and helm - update buildkite pipeline * update release manifest to use sg ops update-images instead * use newer ruby * Revert "use newer ruby" This reverts commit d65eef9. * pre-command: write pid file * Include a test-plan in the automated PRs * Homogeize wip branch prefix --------- Co-authored-by: Jean-Hadrien Chabran <[email protected]>
1 parent ab267a5 commit 4d8f228

File tree

3 files changed

+180
-1
lines changed

3 files changed

+180
-1
lines changed

.buildkite/hooks/pre-command

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,31 @@
11
#!/usr/bin/env bash
2-
2+
# this script is executed by multiple buildkite agents running on one node, so we write the pid to a file
3+
# if the pidfile exists we know another process is executing so we don't need to install anything
4+
#
5+
# A more robust approach would be to use a lock file, but that would require some more work
36
set -eu
47
pushd "$(dirname "${BASH_SOURCE[0]}")"/../..
58

69
WORKDIR=$(pwd)
10+
PIDFILE=/var/lock/dobackup.pid
11+
12+
remove_pidfile()
13+
{
14+
rm -f "$PIDFILE"
15+
}
16+
17+
another_instance()
18+
{
19+
echo "There is another instance running, skipping"
20+
exit 0
21+
}
22+
23+
if [ -f "$PIDFILE" ]; then
24+
kill -0 "$(cat $PIDFILE)" && another_instance
25+
fi
26+
trap remove_pidfile EXIT
27+
echo $$ > "$PIDFILE"
28+
729

830
echo "Installing asdf dependencies as defined in '${WORKDIR}/.tool-versions':"
931
asdf install

.buildkite/pipeline.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,31 @@ steps:
3535
label: ":lock: security - checkov"
3636
agents: { queue: "standard" }
3737
soft_fail: true
38+
39+
- label: "Release: test"
40+
if: "build.branch =~ /^wip_/"
41+
command: |
42+
wget https://storage.googleapis.com/buildkite_public_assets/sg-rfc795.tar.gz
43+
tar zxf sg-rfc795.tar.gz
44+
chmod +x ./sg-rfc795
45+
46+
./sg-rfc795 release run test --workdir=. --config-from-commit
47+
48+
- wait
49+
50+
- label: "Release: finalize"
51+
if: "build.branch =~ /^wip_/"
52+
command: |
53+
wget https://storage.googleapis.com/buildkite_public_assets/sg-rfc795.tar.gz
54+
tar zxf sg-rfc795.tar.gz
55+
chmod +x ./sg-rfc795
56+
57+
./sg-rfc795 release run internal finalize --workdir=. --config-from-commit
58+
- label: "Promote to public: finalize"
59+
if: build.message =~ /^promote_release/ && build.branch =~ /^wip_release/
60+
command: |
61+
wget https://storage.googleapis.com/buildkite_public_assets/sg-rfc795.tar.gz
62+
tar zxf sg-rfc795.tar.gz
63+
chmod +x ./sg-rfc795
64+
65+
./sg-rfc795 release run promote-to-public finalize --workdir=. --config-from-commit

release.yaml

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
---
2+
meta:
3+
productName: "deploy-sourcegraph-docker"
4+
owners:
5+
- "@sourcegraph/release"
6+
repository: "github.com/sourcegraph/deploy-sourcegraph-docker"
7+
inputs:
8+
releaseId: server
9+
requirements:
10+
- name: "go"
11+
cmd: "which go"
12+
fixInstructions: "install golang"
13+
- name: "GitHub cli exists"
14+
cmd: "which gh"
15+
fixInstructions: "install GitHub cli"
16+
internal:
17+
create:
18+
steps:
19+
patch:
20+
- name: docker(compose):tags
21+
cmd: |
22+
set -e
23+
registry=us-central1-docker.pkg.dev/sourcegraph-ci/rfc795-internal
24+
sg-rfc ops update-images --registry ${registry} --kind compose --pin-tag {{tag}} docker-compose/
25+
- name: docker(shell):tags
26+
cmd: |
27+
set -e
28+
registry=us-central1-docker.pkg.dev/sourcegraph-ci/rfc795-internal
29+
sg-rfc ops update-images --registry ${registry} --kind shell --pin-tag {{tag}} pure-docker/
30+
- name: "git:branch"
31+
cmd: |
32+
branch="wip_{{version}}"
33+
git switch -c "${branch}"
34+
git commit -am 'release_patch: {{version}}' -m '{{config}}'
35+
git push origin ${branch}
36+
- name: "gh"
37+
cmd: |
38+
gh pr create -f -t "PRETEND RELEASE WIP: release_patch: build {{version}}" --body "Test plan: automated release PR, CI will perform additional checks"
39+
minor:
40+
- name: docker(compose):tags
41+
cmd: |
42+
set -e
43+
registry=us-central1-docker.pkg.dev/sourcegraph-ci/rfc795-internal
44+
sg-rfc ops update-images --registry ${registry} --kind compose --pin-tag {{tag}} docker-compose/
45+
- name: docker(shell):tags
46+
cmd: |
47+
set -e
48+
registry=us-central1-docker.pkg.dev/sourcegraph-ci/rfc795-internal
49+
sg-rfc ops update-images --registry ${registry} --kind shell --pin-tag {{tag}} pure-docker/
50+
- name: "git:branch"
51+
cmd: |
52+
branch="wip_{{version}}"
53+
git switch -c "${branch}"
54+
git commit -am 'release_minor: {{version}}' -m '{{config}}'
55+
git push origin ${branch}
56+
- name: "gh"
57+
cmd: |
58+
gh pr create -f -t "PRETEND RELEASE WIP: release_minor: build {{version}}" --body "Test plan: automated release PR, CI will perform additional checks"
59+
major:
60+
- name: docker(compose):tags
61+
cmd: |
62+
set -e
63+
registry=us-central1-docker.pkg.dev/sourcegraph-ci/rfc795-internal
64+
sg-rfc ops update-images --registry ${registry} --kind compose --pin-tag {{tag}} docker-compose/
65+
- name: docker(shell):tags
66+
cmd: |
67+
set -e
68+
registry=us-central1-docker.pkg.dev/sourcegraph-ci/rfc795-internal
69+
sg-rfc ops update-images --registry ${registry} --kind shell --pin-tag {{tag}} pure-docker/
70+
- name: "git:branch"
71+
cmd: |
72+
branch="wip_{{version}}"
73+
git switch -c "${branch}"
74+
git commit -am 'release_major: {{version}}' -m '{{config}}'
75+
git push origin ${branch}
76+
- name: "gh"
77+
cmd: |
78+
gh pr create -f -t "PRETEND RELEASE WIP: release_major: build {{version}}" --body "Test plan: automated release PR, CI will perform additional checks"
79+
finalize:
80+
steps:
81+
- name: "git:finalize"
82+
cmd: |
83+
set -e
84+
branch="wip_release-{{version}}"
85+
git switch -c "${branch}"
86+
echo "pushing branch ${branch}"
87+
git push origin "${branch}"
88+
git checkout -
89+
test:
90+
steps:
91+
- name: "foo"
92+
cmd: |
93+
echo "Test"
94+
95+
promoteToPublic:
96+
create:
97+
steps:
98+
- name: docker(compose):tags
99+
cmd: |
100+
set -e
101+
registry=us-central1-docker.pkg.dev/sourcegraph-ci/rfc795-public
102+
sg-rfc ops update-images --registry ${registry} --kind compose --pin-tag {{tag}} docker-compose/
103+
- name: docker(shell):tags
104+
cmd: |
105+
set -e
106+
registry=us-central1-docker.pkg.dev/sourcegraph-ci/rfc795-public
107+
sg-rfc ops update-images --registry ${registry} --kind shell --pin-tag {{tag}} pure-docker/
108+
- name: "git:branch"
109+
cmd: |
110+
branch="promote-release_{{version}}"
111+
git switch -c "${branch}"
112+
git commit -am 'promote-release: {{version}}' -m '{{config}}'
113+
git push origin "${branch}"
114+
- name: "gh"
115+
cmd: |
116+
set -e
117+
branch="wip_release-{{version}}"
118+
# we need to fetch from origin just in case this branch doesn't exist locally, so that the PR can find the base
119+
git fetch origin "${branch}"
120+
gh pr create -f -t "PRETEND PROMOTE RELEASE - release: build {{version}}" --base "${branch}" --body "Test plan: automated release PR, CI will perform additional checks"
121+
finalize:
122+
steps:
123+
- name: git:tag
124+
cmd: |
125+
set -e
126+
branch="wip_release-{{version}}"
127+
git checkout "${branch}"
128+
git tag wip_{{version}}
129+
git push origin ${branch} --tags

0 commit comments

Comments
 (0)