Skip to content

Commit

Permalink
rfc795: add release manifest (#965)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
burmudar and jhchabran authored Feb 6, 2024
1 parent ab267a5 commit 4d8f228
Show file tree
Hide file tree
Showing 3 changed files with 180 additions and 1 deletion.
24 changes: 23 additions & 1 deletion .buildkite/hooks/pre-command
Original file line number Diff line number Diff line change
@@ -1,9 +1,31 @@
#!/usr/bin/env bash

# this script is executed by multiple buildkite agents running on one node, so we write the pid to a file
# if the pidfile exists we know another process is executing so we don't need to install anything
#
# A more robust approach would be to use a lock file, but that would require some more work
set -eu
pushd "$(dirname "${BASH_SOURCE[0]}")"/../..

WORKDIR=$(pwd)
PIDFILE=/var/lock/dobackup.pid

remove_pidfile()
{
rm -f "$PIDFILE"
}

another_instance()
{
echo "There is another instance running, skipping"
exit 0
}

if [ -f "$PIDFILE" ]; then
kill -0 "$(cat $PIDFILE)" && another_instance
fi
trap remove_pidfile EXIT
echo $$ > "$PIDFILE"


echo "Installing asdf dependencies as defined in '${WORKDIR}/.tool-versions':"
asdf install
28 changes: 28 additions & 0 deletions .buildkite/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,31 @@ steps:
label: ":lock: security - checkov"
agents: { queue: "standard" }
soft_fail: true

- label: "Release: test"
if: "build.branch =~ /^wip_/"
command: |
wget https://storage.googleapis.com/buildkite_public_assets/sg-rfc795.tar.gz
tar zxf sg-rfc795.tar.gz
chmod +x ./sg-rfc795
./sg-rfc795 release run test --workdir=. --config-from-commit
- wait

- label: "Release: finalize"
if: "build.branch =~ /^wip_/"
command: |
wget https://storage.googleapis.com/buildkite_public_assets/sg-rfc795.tar.gz
tar zxf sg-rfc795.tar.gz
chmod +x ./sg-rfc795
./sg-rfc795 release run internal finalize --workdir=. --config-from-commit
- label: "Promote to public: finalize"
if: build.message =~ /^promote_release/ && build.branch =~ /^wip_release/
command: |
wget https://storage.googleapis.com/buildkite_public_assets/sg-rfc795.tar.gz
tar zxf sg-rfc795.tar.gz
chmod +x ./sg-rfc795
./sg-rfc795 release run promote-to-public finalize --workdir=. --config-from-commit
129 changes: 129 additions & 0 deletions release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
---
meta:
productName: "deploy-sourcegraph-docker"
owners:
- "@sourcegraph/release"
repository: "github.com/sourcegraph/deploy-sourcegraph-docker"
inputs:
releaseId: server
requirements:
- name: "go"
cmd: "which go"
fixInstructions: "install golang"
- name: "GitHub cli exists"
cmd: "which gh"
fixInstructions: "install GitHub cli"
internal:
create:
steps:
patch:
- name: docker(compose):tags
cmd: |
set -e
registry=us-central1-docker.pkg.dev/sourcegraph-ci/rfc795-internal
sg-rfc ops update-images --registry ${registry} --kind compose --pin-tag {{tag}} docker-compose/
- name: docker(shell):tags
cmd: |
set -e
registry=us-central1-docker.pkg.dev/sourcegraph-ci/rfc795-internal
sg-rfc ops update-images --registry ${registry} --kind shell --pin-tag {{tag}} pure-docker/
- name: "git:branch"
cmd: |
branch="wip_{{version}}"
git switch -c "${branch}"
git commit -am 'release_patch: {{version}}' -m '{{config}}'
git push origin ${branch}
- name: "gh"
cmd: |
gh pr create -f -t "PRETEND RELEASE WIP: release_patch: build {{version}}" --body "Test plan: automated release PR, CI will perform additional checks"
minor:
- name: docker(compose):tags
cmd: |
set -e
registry=us-central1-docker.pkg.dev/sourcegraph-ci/rfc795-internal
sg-rfc ops update-images --registry ${registry} --kind compose --pin-tag {{tag}} docker-compose/
- name: docker(shell):tags
cmd: |
set -e
registry=us-central1-docker.pkg.dev/sourcegraph-ci/rfc795-internal
sg-rfc ops update-images --registry ${registry} --kind shell --pin-tag {{tag}} pure-docker/
- name: "git:branch"
cmd: |
branch="wip_{{version}}"
git switch -c "${branch}"
git commit -am 'release_minor: {{version}}' -m '{{config}}'
git push origin ${branch}
- name: "gh"
cmd: |
gh pr create -f -t "PRETEND RELEASE WIP: release_minor: build {{version}}" --body "Test plan: automated release PR, CI will perform additional checks"
major:
- name: docker(compose):tags
cmd: |
set -e
registry=us-central1-docker.pkg.dev/sourcegraph-ci/rfc795-internal
sg-rfc ops update-images --registry ${registry} --kind compose --pin-tag {{tag}} docker-compose/
- name: docker(shell):tags
cmd: |
set -e
registry=us-central1-docker.pkg.dev/sourcegraph-ci/rfc795-internal
sg-rfc ops update-images --registry ${registry} --kind shell --pin-tag {{tag}} pure-docker/
- name: "git:branch"
cmd: |
branch="wip_{{version}}"
git switch -c "${branch}"
git commit -am 'release_major: {{version}}' -m '{{config}}'
git push origin ${branch}
- name: "gh"
cmd: |
gh pr create -f -t "PRETEND RELEASE WIP: release_major: build {{version}}" --body "Test plan: automated release PR, CI will perform additional checks"
finalize:
steps:
- name: "git:finalize"
cmd: |
set -e
branch="wip_release-{{version}}"
git switch -c "${branch}"
echo "pushing branch ${branch}"
git push origin "${branch}"
git checkout -
test:
steps:
- name: "foo"
cmd: |
echo "Test"
promoteToPublic:
create:
steps:
- name: docker(compose):tags
cmd: |
set -e
registry=us-central1-docker.pkg.dev/sourcegraph-ci/rfc795-public
sg-rfc ops update-images --registry ${registry} --kind compose --pin-tag {{tag}} docker-compose/
- name: docker(shell):tags
cmd: |
set -e
registry=us-central1-docker.pkg.dev/sourcegraph-ci/rfc795-public
sg-rfc ops update-images --registry ${registry} --kind shell --pin-tag {{tag}} pure-docker/
- name: "git:branch"
cmd: |
branch="promote-release_{{version}}"
git switch -c "${branch}"
git commit -am 'promote-release: {{version}}' -m '{{config}}'
git push origin "${branch}"
- name: "gh"
cmd: |
set -e
branch="wip_release-{{version}}"
# we need to fetch from origin just in case this branch doesn't exist locally, so that the PR can find the base
git fetch origin "${branch}"
gh pr create -f -t "PRETEND PROMOTE RELEASE - release: build {{version}}" --base "${branch}" --body "Test plan: automated release PR, CI will perform additional checks"
finalize:
steps:
- name: git:tag
cmd: |
set -e
branch="wip_release-{{version}}"
git checkout "${branch}"
git tag wip_{{version}}
git push origin ${branch} --tags

0 comments on commit 4d8f228

Please sign in to comment.