4444 runs-on : ubuntu-22.04
4545 outputs :
4646 version : ${{ steps.set_vars.outputs.version }}
47+ floating_version : ${{ steps.set_vars.outputs.floating_version }}
4748 goreleaser_args : ${{ steps.set_vars.outputs.goreleaser_args }}
4849 needs_release : ${{ steps.set_vars.outputs.needs_release }}
4950 previous_tag : ${{ steps.set_vars.outputs.previous_tag }}
5657 shell : bash
5758 run : |
5859 set -x
59- GIT_SHA=$(git rev-parse --short HEAD)
60+ GIT_SHA=$(git rev-parse --short=12 HEAD)
61+ FLOATING_VERSION=""
6062
6163 find_previous_release_notes_tag() {
6264 local version="$1"
@@ -108,7 +110,10 @@ jobs:
108110 NEEDS_RELEASE=true
109111 GORELEASER_ARGS="--clean --skip=validate --release-notes _output/RELEASE_NOTES.md"
110112 elif [[ $GITHUB_REF == refs/heads/main ]]; then
111- VERSION="$(make --no-print-directory print-ROLLING_MAIN_VERSION)"
113+ # Per-sha version gives parallel main runs non-colliding image tags;
114+ # the floating tag is promoted separately, only by the run that is still HEAD.
115+ FLOATING_VERSION="$(make --no-print-directory print-ROLLING_MAIN_VERSION)"
116+ VERSION="${FLOATING_VERSION}-${GIT_SHA}"
112117 NEEDS_RELEASE=false
113118 GORELEASER_ARGS="--clean --skip=validate"
114119 elif [[ $GITHUB_REF == refs/pull/* ]]; then
@@ -125,6 +130,7 @@ jobs:
125130 # Group redirects to satisfy shellcheck SC2129
126131 {
127132 echo "version=${VERSION}"
133+ echo "floating_version=${FLOATING_VERSION}"
128134 echo "previous_tag=${PREVIOUS_TAG:-}"
129135 echo "needs_release=${NEEDS_RELEASE}"
130136 echo "goreleaser_args=${GORELEASER_ARGS}"
@@ -141,6 +147,20 @@ jobs:
141147 if : ${{ github.event_name != 'pull_request' }}
142148 run : echo "${{ secrets.GITHUB_TOKEN }}" | go tool helm registry login ${{ env.IMAGE_REGISTRY }} -u ${{ github.repository_owner }} --password-stdin
143149
150+ # docker login + buildx are only needed to promote the floating image tags below
151+ # (`docker buildx imagetools create`); gate them on the same condition as that step.
152+ - name : Log into ${{ env.IMAGE_REGISTRY }}
153+ if : ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.setup.outputs.floating_version != '' }}
154+ uses : docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
155+ with :
156+ registry : ${{ env.IMAGE_REGISTRY }}
157+ username : ${{ github.repository_owner }}
158+ password : ${{ secrets.GITHUB_TOKEN }}
159+
160+ - name : Setup Buildx
161+ if : ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.setup.outputs.floating_version != '' }}
162+ uses : docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
163+
144164 - name : Package kgateway charts
145165 run : make package-kgateway-charts
146166 env :
@@ -153,6 +173,40 @@ jobs:
153173 VERSION : ${{ needs.setup.outputs.version }}
154174 IMAGE_REGISTRY : ${{ env.IMAGE_REGISTRY }}
155175
176+ # Promote the floating chart and image tags together, gated on a single origin/main
177+ # HEAD check, so the two artifact tags can never diverge. Doing this in one step (rather
178+ # than promoting images in the goreleaser job and charts here) avoids a race where
179+ # origin/main advances between the two jobs and leaves the floating chart tag behind the
180+ # floating image tag. This job needs [setup, goreleaser], so both the per-sha charts
181+ # (pushed above) and the per-sha images (from goreleaser) already exist by now.
182+ - name : Promote floating chart and image tags if this commit is still main HEAD
183+ if : ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && needs.setup.outputs.floating_version != '' }}
184+ shell : bash
185+ run : |
186+ set -euo pipefail
187+ git fetch origin main --depth=1
188+ HEAD_SHA=$(git rev-parse origin/main)
189+ if [ "${HEAD_SHA}" != "${GITHUB_SHA}" ]; then
190+ echo "origin/main (${HEAD_SHA}) has moved past this commit (${GITHUB_SHA}); skipping floating tag promotion"
191+ exit 0
192+ fi
193+ make release-charts VERSION="${FLOAT}"
194+ for image in kgateway sds envoy-wrapper; do
195+ docker buildx imagetools create \
196+ -t "${REG}/${image}:${FLOAT}" \
197+ "${REG}/${image}:${VERSION}"
198+ for arch in amd64 arm64; do
199+ docker buildx imagetools create \
200+ -t "${REG}/${image}:${FLOAT}-${arch}" \
201+ "${REG}/${image}:${VERSION}-${arch}"
202+ done
203+ done
204+ env :
205+ REG : ${{ env.IMAGE_REGISTRY }}
206+ IMAGE_REGISTRY : ${{ env.IMAGE_REGISTRY }}
207+ VERSION : ${{ needs.setup.outputs.version }}
208+ FLOAT : ${{ needs.setup.outputs.floating_version }}
209+
156210 release-notes :
157211 name : Generate release notes
158212 needs : setup
0 commit comments