diff --git a/.buildkite/hooks/pre-command b/.buildkite/hooks/pre-command index 012acec51..cbdcbd37c 100755 --- a/.buildkite/hooks/pre-command +++ b/.buildkite/hooks/pre-command @@ -26,6 +26,5 @@ fi trap remove_pidfile EXIT echo $$ > "$PIDFILE" - echo "Installing asdf dependencies as defined in '${WORKDIR}/.tool-versions':" asdf install diff --git a/.buildkite/pipeline.yaml b/.buildkite/pipeline.yaml index fee5e8152..58e49433c 100644 --- a/.buildkite/pipeline.yaml +++ b/.buildkite/pipeline.yaml @@ -36,8 +36,18 @@ steps: agents: { queue: "standard" } soft_fail: true - - label: "Release: test" - if: "build.branch =~ /^wip_/" + # Please keep in mind that the release manifest uses specific branch names when creating releases. + # Therefore, if you update them, or if you decide to change how we detect what kind of build we're dealing + # with, please update this file as well. + - label: "(internal) Release: test" + if: build.branch =~ /^internal\/release-.*/ + plugins: + - ssh://git@github.com/sourcegraph/sg-buildkite-plugin.git#main: ~ + command: | + sg release run test --workdir=. --config-from-commit + + - label: "(promote) Release: test" + if: build.branch =~ /^promote\/release-.*/ plugins: - ssh://git@github.com/sourcegraph/sg-buildkite-plugin.git#main: ~ command: | @@ -45,16 +55,18 @@ steps: - wait - - label: "Release: finalize" - if: "build.branch =~ /^wip_/" + - label: "(internal) Release: finalize" + if: build.branch =~ /^internal\/release-.*/ plugins: - ssh://git@github.com/sourcegraph/sg-buildkite-plugin.git#main: ~ command: | sg release run internal finalize --workdir=. --config-from-commit - - label: "Promote to public: finalize" - if: build.message =~ /^promote_release/ && build.branch =~ /^wip_release/ + + - label: "(promote) Release: finalize" + if: build.branch =~ /^promote\/release-.*/ plugins: - ssh://git@github.com/sourcegraph/sg-buildkite-plugin.git#main: ~ command: | sg release run promote-to-public finalize --workdir=. --config-from-commit + diff --git a/.tool-versions b/.tool-versions index 479b5702e..0577dd159 100644 --- a/.tool-versions +++ b/.tool-versions @@ -2,4 +2,5 @@ nodejs 16.7.0 yarn 1.22.4 shellcheck 0.7.1 golang 1.19.8 +github-cli 2.46.0 python system diff --git a/README.md b/README.md index 8ad00b364..8c06bb455 100644 --- a/README.md +++ b/README.md @@ -34,3 +34,11 @@ We've made our deployment configurations open source to better serve our custome What if your organization wants a multi-machine deployment without using Kubernetes? What if you use a different container management platform, for example? Anyone using a container management platform other than Kubernetes (Netflix's [Titus](https://netflix.github.io/titus/), Apache's [Mesos](http://mesos.apache.org/documentation/latest/docker-containerizer/), etc.) can use our [Pure-Docker Sourcegraph cluster deployment reference](./pure-docker/README.md) to deploy Sourcegraph. + +--- + +### Contributing + +#### Releasing + +Please see the [documentation](https://go/releases). diff --git a/release.yaml b/release.yaml index 5749de1f5..60c99c0fe 100644 --- a/release.yaml +++ b/release.yaml @@ -5,7 +5,7 @@ meta: - "@sourcegraph/release" repository: "github.com/sourcegraph/deploy-sourcegraph-docker" inputs: - releaseId: server + - releaseId: server requirements: - name: "go" cmd: "which go" @@ -14,116 +14,187 @@ requirements: cmd: "which gh" fixInstructions: "install GitHub cli" internal: + # Please keep in mind that the CI pipeline uses the branch names defined below when creating releases. + # Therefore, if you update them, or if you decide to change how we detect what kind of build we're dealing + # with, please update this file as well. create: steps: patch: - name: docker(compose):tags cmd: | - set -e + set -eu registry=us-central1-docker.pkg.dev/sourcegraph-ci/rfc795-internal sg ops update-images --registry ${registry} --kind compose --pin-tag {{tag}} docker-compose/ - name: docker(shell):tags cmd: | - set -e + set -eu registry=us-central1-docker.pkg.dev/sourcegraph-ci/rfc795-internal sg ops update-images --registry ${registry} --kind shell --pin-tag {{tag}} pure-docker/ - name: "git:branch" cmd: | - branch="wip_{{version}}" + set -eu + branch="internal/release-{{version}}" git switch -c "${branch}" git commit -am 'release_patch: {{version}}' -m '{{config}}' git push origin ${branch} - - name: "gh" + - name: "github:pr" cmd: | - gh pr create -f -t "PRETEND RELEASE WIP: release_patch: build {{version}}" --body "Test plan: automated release PR, CI will perform additional checks" + gh pr create \ + --fill \ + --draft \ + --title "(internal) release_patch: build {{version}}" \ + --body "Test plan: automated release PR, CI will perform additional checks" + echo "🚢 Please check the associated CI build to ensure the process completed". minor: - name: docker(compose):tags cmd: | - set -e + set -eu registry=us-central1-docker.pkg.dev/sourcegraph-ci/rfc795-internal sg ops update-images --registry ${registry} --kind compose --pin-tag {{tag}} docker-compose/ - name: docker(shell):tags cmd: | - set -e + set -eu registry=us-central1-docker.pkg.dev/sourcegraph-ci/rfc795-internal sg ops update-images --registry ${registry} --kind shell --pin-tag {{tag}} pure-docker/ - name: "git:branch" cmd: | - branch="wip_{{version}}" + set -eu + branch="internal/release-{{version}}" git switch -c "${branch}" git commit -am 'release_minor: {{version}}' -m '{{config}}' git push origin ${branch} - - name: "gh" + - name: "github:pr" cmd: | - gh pr create -f -t "PRETEND RELEASE WIP: release_minor: build {{version}}" --body "Test plan: automated release PR, CI will perform additional checks" + gh pr create \ + --fill \ + --draft \ + --title "(internal) release_minor: build {{version}}" \ + --body "Test plan: automated release PR, CI will perform additional checks" + echo "🚢 Please check the associated CI build to ensure the process completed". major: - name: docker(compose):tags cmd: | - set -e + set -eu registry=us-central1-docker.pkg.dev/sourcegraph-ci/rfc795-internal sg ops update-images --registry ${registry} --kind compose --pin-tag {{tag}} docker-compose/ - name: docker(shell):tags cmd: | - set -e + set -eu registry=us-central1-docker.pkg.dev/sourcegraph-ci/rfc795-internal sg ops update-images --registry ${registry} --kind shell --pin-tag {{tag}} pure-docker/ - name: "git:branch" cmd: | - branch="wip_{{version}}" + set -eu + branch="internal/release-{{version}}" git switch -c "${branch}" git commit -am 'release_major: {{version}}' -m '{{config}}' git push origin ${branch} - - name: "gh" + - name: "github:pr" cmd: | - gh pr create -f -t "PRETEND RELEASE WIP: release_major: build {{version}}" --body "Test plan: automated release PR, CI will perform additional checks" + gh pr create \ + --fill \ + --draft \ + --title "(internal) release_major: build {{version}}" \ + --body "Test plan: automated release PR, CI will perform additional checks" + echo "🚢 Please check the associated CI build to ensure the process completed". 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 - + set -eu + + branch="internal/release-{{version}}" + + # Post a comment on the PR. + cat << EOF | gh pr comment "$branch" --body-file - + - :green_circle: Internal release is ready for promotion! + - :warning: Do not close/merge that pull request or delete the associated branch if you intend to promote it. + EOF + + # Post an annotation. + cat << EOF | buildkite-agent annotate --style info + Internal release is ready for promotion under the branch [\`$branch\`](https://github.com/sourcegraph/deploy-sourcegraph-docker/tree/$branch). + EOF test: steps: - - name: "foo" + - name: "Placeholder" cmd: | echo "Test" promoteToPublic: create: steps: + - name: "git" + cmd: | + set -eu + branch="internal/release-{{version}}" + git fetch origin "${branch}" + git switch "${branch}" - name: docker(compose):tags cmd: | - set -e + set -eu registry=us-central1-docker.pkg.dev/sourcegraph-ci/rfc795-public sg ops update-images --registry ${registry} --kind compose --pin-tag {{tag}} docker-compose/ - name: docker(shell):tags cmd: | - set -e + set -eu registry=us-central1-docker.pkg.dev/sourcegraph-ci/rfc795-public sg ops update-images --registry ${registry} --kind shell --pin-tag {{tag}} pure-docker/ - name: "git:branch" cmd: | - branch="promote-release_{{version}}" + set -eu + branch="promote/release-{{version}}" git switch -c "${branch}" git commit -am 'promote-release: {{version}}' -m '{{config}}' git push origin "${branch}" - - name: "gh" + - name: "github:pr" cmd: | - set -e - branch="wip_release-{{version}}" + set -eu + internal_branch="internal/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" + git fetch origin "${internal_branch}" + gh pr create \ + --fill \ + --draft \ + --base "$internal_branch" \ + --title "(promote) release: build {{version}}" \ + --body "Test plan: automated release PR, CI will perform additional checks" + echo "🚢 Please check the associated CI build to ensure the process completed". finalize: steps: - name: git:tag cmd: | - set -e - branch="wip_release-{{version}}" - git checkout "${branch}" - git tag wip_{{version}} - git push origin ${branch} --tags + set -eu + + # Branches + internal_branch="internal/release-{{version}}" + promote_branch="promote/release-{{version}}" + release_branch="release-{{version}}" + + # Create the final branch holding the tagged commit + git checkout "${promote_branch}" + git switch -c "${release_branch}" + + git tag {{version}} + git push origin ${release_branch} --tags + + # Web URL to the tag + tag_url="https://github.com/sourcegraph/deploy-sourcegraph-docker/tree/{{version}}" + + # Annotate PRs + cat << EOF | gh pr comment "$internal_branch" --body-file - + - :green_circle: Release has been promoted, see tag: $tag_url. + - :no_entry: Do not under any circumstance delete the branch holding the tagged commit (i.e. \`$release_branch\`). + - :arrow_right: You can safely close that PR and delete its a associated branch. + EOF + + cat << EOF | gh pr comment "$promote_branch" --body-file - + - :green_circle: Release has been promoted, see tag: $tag_url. + - :no_entry: Do not under any circumstance delete the branch holding the tagged commit (i.e. \`$release_branch\`). + - :arrow_right: You can safely close that PR and delete its a associated branch. + EOF + + # Annotate build + cat << EOF | buildkite-agent annotate --style info + Promoted release is **publicly available** through a git tag at [\`{{version}}\`](https://github.com/sourcegraph/deploy-sourcegraph-docker/tree/{{version}}). + EOF