Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit e24226a

Browse files
authored
Publish images from patch release branches (#63379)
We currently don't publish images from the new-style patch release branches like `5.4.5099`, as this is all performed using the new release tooling. In order to improve the release process, we (Security) would like to run a daily scan of the current set of images built from the patch release branch. Currently we only scan images built from `main`, but these slowly diverge from the patch release branch in the 2 week window between a monthly release and the patch release. To give a specific example, we currently have no easy/automated way to scan images from the `5.4.5099` branch that a release will be cut from this afternoon until the release team run the internal release process. This PR updates the pipeline so that whenever a new commit is pushed to the patch release branch, it will publish a new set of images and include the tag `<branch>-insiders`. Currently just pushing to us.gcr.io, but equally could push to dockerhub. Example of the jobfile for a matching branch after this PR: `bazel --bazelrc=/tmp/aspect-generated.bazelrc --bazelrc=.aspect/bazelrc/ci.sourcegraph.bazelrc run //cmd/batcheshelper:candidate_push --stamp --workspace_status_command=./dev/bazel_stamp_vars.sh -- --tag dc43864 --tag dc438648b0cc_2024-06-20 --tag dc438648b0cc_279230 --tag will/5.4.9999-insiders --repository us.gcr.io/sourcegraph-dev/batcheshelper && echo -e '<tr><td>batcheshelper</td><td><code>us.gcr.io/sourcegraph-dev</code></td><td><code>dc438648b0cc</code>, <code>dc438648b0cc_2024-06-20</code>, <code>dc438648b0cc_279230</code>, <code>will/5.4.9999-insiders</code></td></tr>' >>./annotations/pushed_images.md` [Example buildkite run](https://buildkite.com/sourcegraph/sourcegraph/builds/279230#_) where the pattern was updated to match this branch, and pushing non-candidate images was disabled. This resolves one part of [SEC-1734](https://linear.app/sourcegraph/issue/SEC-1734/scan-images-from-patch-release-branches) <!-- 💡 To write a useful PR description, make sure that your description covers: - WHAT this PR is changing: - How was it PREVIOUSLY. - How it will be from NOW on. - WHY this PR is needed. - CONTEXT, i.e. to which initiative, project or RFC it belongs. The structure of the description doesn't matter as much as covering these points, so use your best judgement based on your context. Learn how to write good pull request description: https://www.notion.so/sourcegraph/Write-a-good-pull-request-description-610a7fd3e613496eb76f450db5a49b6e?pvs=4 --> ## Test plan - Manual testing of buildkite pipeline <!-- All pull requests REQUIRE a test plan: https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles --> ## Changelog <!-- 1. Ensure your pull request title is formatted as: $type($domain): $what 2. Add bullet list items for each additional detail you want to cover (see example below) 3. You can edit this after the pull request was merged, as long as release shipping it hasn't been promoted to the public. 4. For more information, please see this how-to https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c? Audience: TS/CSE > Customers > Teammates (in that order). Cheat sheet: $type = chore|fix|feat $domain: source|search|ci|release|plg|cody|local|... --> <!-- Example: Title: fix(search): parse quotes with the appropriate context Changelog section: ## Changelog - When a quote is used with regexp pattern type, then ... - Refactored underlying code. -->
1 parent 2958abc commit e24226a

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

dev/ci/push_all.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ echo "~~~ :aspect: :stethoscope: Agent Health check"
66
/etc/aspect/workflows/bin/agent_health_check
77

88
aspectRC="/tmp/aspect-generated.bazelrc"
9-
rosetta bazelrc > "$aspectRC"
9+
rosetta bazelrc >"$aspectRC"
1010
bazelrc=(--bazelrc="$aspectRC" --bazelrc=.aspect/bazelrc/ci.sourcegraph.bazelrc)
1111

1212
function preview_tags() {
@@ -77,7 +77,7 @@ prod_registries=(
7777
)
7878

7979
if [ -n "${ADDITIONAL_PROD_REGISTRIES}" ]; then
80-
IFS=' ' read -r -a registries <<< "$ADDITIONAL_PROD_REGISTRIES"
80+
IFS=' ' read -r -a registries <<<"$ADDITIONAL_PROD_REGISTRIES"
8181
prod_registries+=("${registries[@]}")
8282
fi
8383

@@ -104,7 +104,7 @@ elif [[ "$BUILDKITE_BRANCH" =~ ^main$ ]] || [[ "$BUILDKITE_BRANCH" =~ ^docker-im
104104
dev_tags+=("insiders")
105105
prod_tags+=("insiders")
106106
push_prod=true
107-
elif [[ "$BUILDKITE_BRANCH" =~ ^main-dry-run/.* ]]; then
107+
elif [[ "$BUILDKITE_BRANCH" =~ ^main-dry-run/.* ]]; then
108108
# We only push on internal registries on a main-dry-run.
109109
dev_tags+=("insiders")
110110
prod_tags+=("insiders")
@@ -119,6 +119,10 @@ elif [[ "$BUILDKITE_BRANCH" =~ ^[0-9]+\.[0-9]+$ ]]; then
119119
# format introduced by https://github.com/sourcegraph/sourcegraph/pull/48050
120120
# by release branch deployments.
121121
push_prod=true
122+
elif [[ "$BUILDKITE_BRANCH" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
123+
# Patch release builds only need to be pushed to internal registries.
124+
push_prod=false
125+
dev_tags+=("$BUILDKITE_BRANCH-insiders")
122126
elif [[ "$BUILDKITE_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(\-rc\.[0-9]+)?$ ]]; then
123127
# ok: v5.1.0
124128
# ok: v5.1.0-rc.5
@@ -141,11 +145,10 @@ if [ -n "$CANDIDATE_ONLY" ]; then
141145
push_prod=false
142146
fi
143147

144-
145148
# Posting the preamble for image pushes.
146-
echo -e "### ${BUILDKITE_LABEL}" > ./annotations/pushed_images.md
149+
echo -e "### ${BUILDKITE_LABEL}" >./annotations/pushed_images.md
147150
echo -e "<details><summary>Click to expand table</summary><table>\n" >>./annotations/pushed_images.md
148-
echo -e "<tr><th>Name</th><th>Registry</th><th>Tags</th></tr>\n" >> ./annotations/pushed_images.md
151+
echo -e "<tr><th>Name</th><th>Registry</th><th>Tags</th></tr>\n" >>./annotations/pushed_images.md
149152

150153
preview_tags "${dev_registries[*]}" "${dev_tags[*]}"
151154
if $push_prod; then

dev/ci/runtype/runtype.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ const (
2323

2424
// Release branches
2525

26-
TaggedRelease // semver-tagged release
27-
ReleaseBranch // release branch build
28-
BextReleaseBranch // browser extension release build
29-
VsceReleaseBranch // vs code extension release build
26+
TaggedRelease // semver-tagged release
27+
ReleaseBranch // release branch build
28+
PatchReleaseBranch // patch release branch build
29+
BextReleaseBranch // browser extension release build
30+
VsceReleaseBranch // vs code extension release build
3031

3132
InternalRelease // Internal release
3233
PromoteRelease // Public release
@@ -138,6 +139,11 @@ func (t RunType) Matcher() *RunTypeMatcher {
138139
Branch: `^[0-9]+\.[0-9]+$`,
139140
BranchRegexp: true,
140141
}
142+
case PatchReleaseBranch:
143+
return &RunTypeMatcher{
144+
Branch: `^[0-9]+\.[0-9]+\.[0-9]+$`,
145+
BranchRegexp: true,
146+
}
141147
case BextReleaseBranch:
142148
return &RunTypeMatcher{
143149
Branch: "bext/release",

0 commit comments

Comments
 (0)