@@ -117,6 +117,40 @@ jobs:
117117 key : ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
118118 restore-keys : |
119119 ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
120+ - name : Validate Go version
121+ run : |
122+ GO_VERSION_STR=$(docker run --rm tykio/golang-cross:${{ matrix.golang_cross }} go version 2>&1 || true)
123+ if [[ ! "$GO_VERSION_STR" =~ go[0-9]+ ]]; then
124+ echo "::warning::Could not determine Go version from container: $GO_VERSION_STR"
125+ exit 1
126+ fi
127+ GO_VERSION=$(echo "$GO_VERSION_STR" | awk '{print $3}' | sed 's/^go//')
128+ echo "Go version in container: $GO_VERSION"
129+ MINOR_VERSION=$(echo "$GO_VERSION" | cut -d. -f1,2)
130+ echo "Minor version: $MINOR_VERSION"
131+
132+ # Fetch latest patches
133+ LATEST_PATCH_STR=$(curl -s 'https://go.dev/dl/?mode=json&include=all' || true)
134+ if [ -z "$LATEST_PATCH_STR" ]; then
135+ echo "::warning::Could not fetch Go releases from API. Skipping validation."
136+ exit 0
137+ fi
138+ LATEST_PATCH=$(echo "$LATEST_PATCH_STR" | jq -r --arg minor "go${MINOR_VERSION}" '.[] | select(.stable == true and (.version | startswith($minor + ".") or . == $minor)) | .version' | head -n 1 | sed 's/^go//')
139+
140+ if [ -n "$LATEST_PATCH" ]; then
141+ echo "Latest patch version for Go $MINOR_VERSION is $LATEST_PATCH"
142+ if [ "$GO_VERSION" != "$LATEST_PATCH" ]; then
143+ echo "::error::Go version validation failed!"
144+ echo "Used version: $GO_VERSION (in tykio/golang-cross:${{ matrix.golang_cross }})"
145+ echo "Latest patch: $LATEST_PATCH"
146+ echo "Please update the buildenv Go version to the latest patch version."
147+ exit 1
148+ else
149+ echo "Go version is up to date: $GO_VERSION"
150+ fi
151+ else
152+ echo "::warning::Could not determine latest patch version for Go $MINOR_VERSION from API. Skipping validation."
153+ fi
120154 - name : Build
121155 env :
122156 NFPM_PASSPHRASE : ${{ secrets.SIGNING_KEY_PASSPHRASE }}
@@ -127,7 +161,7 @@ jobs:
127161 ci/bin/unlock-agent.sh
128162 git config --global url."https://x-access-token:${{ steps.app-token.outputs.token }}@github.com/".insteadOf "https://github.com/"
129163 git config --global --add safe.directory /go/src/github.com/TykTechnologies/tyk-identity-broker
130- goreleaser release --clean -f ${{ matrix.goreleaser }} ${{ !startsWith(github.ref, 'refs/tags/') && ' --snapshot --skip=sign,docker' || '--skip=docker' }}' | tee /tmp/build.sh
164+ goreleaser release --timeout 120m -- clean -f ${{ matrix.goreleaser }} ${{ !startsWith(github.ref, 'refs/tags/') && ' --snapshot --skip=sign,docker' || '--skip=docker' }}' | tee /tmp/build.sh
131165 chmod +x /tmp/build.sh
132166 docker run --rm --privileged -e GITHUB_TOKEN=${{ github.token }} \
133167 -e GOPRIVATE=github.com/TykTechnologies \
@@ -187,10 +221,39 @@ jobs:
187221 echo "Inspecting layer compression for tag: $TAG"
188222
189223 docker buildx imagetools inspect --raw -- "$TAG" > manifest.json
190- if grep -q "tar+zstd" manifest.json; then
191- echo "::error::Image contains zstd-compressed layers! This is incompatible with legacy registries."
192- cat manifest.json | grep mediaType
193- exit 1
224+
225+ # Extract child digests (excluding attestation manifests) if it's a multi-arch manifest list / index
226+ DIGESTS=$(jq -r '.manifests[] | select((.platform.architecture // "") != "unknown" and (.annotations["vnd.docker.reference.type"] // "") != "attestation-manifest") | .digest' manifest.json 2>/dev/null || true)
227+
228+ verify_manifest() {
229+ local file=$1
230+ # Check if any layer does NOT end in gzip/tar+gzip/tar.gzip
231+ local invalid_layers
232+ invalid_layers=$(jq -r '.layers[].mediaType' "$file" | grep -v 'tar+gzip' | grep -v 'tar.gzip' || true)
233+ if [ -n "$invalid_layers" ]; then
234+ echo "::error::Found layers that are not gzip-compressed:"
235+ echo "$invalid_layers"
236+ exit 1
237+ fi
238+ # Also verify we found at least one layer
239+ local layer_count
240+ layer_count=$(jq '.layers | length' "$file" 2>/dev/null || echo 0)
241+ if [ "$layer_count" -eq 0 ]; then
242+ echo "::error::No layers found in manifest!"
243+ exit 1
244+ fi
245+ }
246+
247+ if [ -n "$DIGESTS" ]; then
248+ echo "Multi-arch image list detected. Checking each platform manifest..."
249+ for digest in $DIGESTS; do
250+ echo "Inspecting child platform manifest: $digest"
251+ docker buildx imagetools inspect --raw -- "$TAG@$digest" > child_manifest.json
252+ verify_manifest child_manifest.json
253+ done
254+ else
255+ echo "Single-arch manifest detected. Checking manifest..."
256+ verify_manifest manifest.json
194257 fi
195258 echo "Success: All layers are uniformly compressed using gzip."
196259 - name : Docker metadata for std tag push
@@ -234,10 +297,39 @@ jobs:
234297 echo "Inspecting layer compression for tag: $TAG"
235298
236299 docker buildx imagetools inspect --raw -- "$TAG" > manifest.json
237- if grep -q "tar+zstd" manifest.json; then
238- echo "::error::Image contains zstd-compressed layers! This is incompatible with legacy registries."
239- cat manifest.json | grep mediaType
240- exit 1
300+
301+ # Extract child digests (excluding attestation manifests) if it's a multi-arch manifest list / index
302+ DIGESTS=$(jq -r '.manifests[] | select((.platform.architecture // "") != "unknown" and (.annotations["vnd.docker.reference.type"] // "") != "attestation-manifest") | .digest' manifest.json 2>/dev/null || true)
303+
304+ verify_manifest() {
305+ local file=$1
306+ # Check if any layer does NOT end in gzip/tar+gzip/tar.gzip
307+ local invalid_layers
308+ invalid_layers=$(jq -r '.layers[].mediaType' "$file" | grep -v 'tar+gzip' | grep -v 'tar.gzip' || true)
309+ if [ -n "$invalid_layers" ]; then
310+ echo "::error::Found layers that are not gzip-compressed:"
311+ echo "$invalid_layers"
312+ exit 1
313+ fi
314+ # Also verify we found at least one layer
315+ local layer_count
316+ layer_count=$(jq '.layers | length' "$file" 2>/dev/null || echo 0)
317+ if [ "$layer_count" -eq 0 ]; then
318+ echo "::error::No layers found in manifest!"
319+ exit 1
320+ fi
321+ }
322+
323+ if [ -n "$DIGESTS" ]; then
324+ echo "Multi-arch image list detected. Checking each platform manifest..."
325+ for digest in $DIGESTS; do
326+ echo "Inspecting child platform manifest: $digest"
327+ docker buildx imagetools inspect --raw -- "$TAG@$digest" > child_manifest.json
328+ verify_manifest child_manifest.json
329+ done
330+ else
331+ echo "Single-arch manifest detected. Checking manifest..."
332+ verify_manifest manifest.json
241333 fi
242334 echo "Success: All layers are uniformly compressed using gzip."
243335 - name : save deb
@@ -301,113 +393,20 @@ jobs:
301393 outputs :
302394 deb : ${{ steps.params.outputs.deb }}
303395 rpm : ${{ steps.params.outputs.rpm }}
396+ rpm_amd64 : ${{ steps.params.outputs.rpm_amd64 }}
304397 steps :
305- - name : set params
398+ - name : Set distro matrix
399+ uses : TykTechnologies/github-actions/.github/actions/tests/distro-matrix@production
306400 id : params
307- shell : bash
308- env :
309- # startsWith covers pull_request_target too
310- BASE_REF : ${{startsWith(github.event_name, 'pull_request') && github.base_ref || github.ref_name}}
311- run : |
312- set -eo pipefail
313- curl -s --retry 5 --retry-delay 10 --fail-with-body "http://tui.internal.dev.tyk.technology/v2/$VARIATION/tyk-identity-broker/$BASE_REF/${{ github.event_name}}/api/Distros.gho" | tee -a "$GITHUB_OUTPUT"
314- if ! [[ $VARIATION =~ prod ]];then
315- echo "::warning file=.github/workflows/release.yml,line=24,col=1,endColumn=8::Using test variation"
316- fi
317- upgrade-deb :
318- services :
319- httpbin.org :
320- image : kennethreitz/httpbin
321- runs-on : ${{ vars.DEFAULT_RUNNER }}
322- needs :
323- - test-controller-distros
324- strategy :
325- fail-fast : true
326- matrix :
327- arch :
328- - amd64
329- - arm64
330- distro : ${{ fromJson(needs.test-controller-distros.outputs.deb) }}
331- steps :
332- - uses : actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
333- with :
334- fetch-depth : 1
335- sparse-checkout : ci
336- - uses : actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
337- with :
338- name : deb
339- - uses : docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3
340- - uses : docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
341- - name : generate dockerfile
342- run : |
343- echo 'FROM ${{ matrix.distro }}
344- ARG TARGETARCH
345- COPY tyk-identity-broker*_${TARGETARCH}.deb /tyk-identity-broker.deb
346- RUN apt-get update && apt-get install -y curl
347- # TODO(security): curl|bash - consider fetching script and verifying checksum before execution
348- RUN curl -fsSL https://packagecloud.io/install/repositories/tyk/tyk-identity-broker/script.deb.sh | bash || echo "Repository setup failed, but continuing" # SECURITY: accepted risk, see TODO above
349- RUN apt-get install -y tyk-identity-broker=1.1.0 || echo "Previous version not found, testing fresh install"
350- RUN dpkg -i /tyk-identity-broker.deb
351-
352- ' | tee Dockerfile
353- - name : install on ${{ matrix.distro }}
354- uses : docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6
355- with :
356- context : " ."
357- platforms : linux/${{ matrix.arch }}
358- build-args : |
359- RHELARCH=${{ startsWith(matrix.arch, 'arm64') && 'aarch64' || 'x86_64' }}
360- cache-from : type=gha
361- cache-to : type=gha,mode=max
362- file : Dockerfile
363- push : false
364- upgrade-rpm :
365- services :
366- httpbin.org :
367- image : kennethreitz/httpbin
368- runs-on : ${{ vars.DEFAULT_RUNNER }}
401+ upgrade-tests :
369402 needs :
370403 - test-controller-distros
371- strategy :
372- fail-fast : true
373- matrix :
374- arch :
375- - amd64
376- - arm64
377- distro : ${{ fromJson(needs.test-controller-distros.outputs.rpm) }}
378- steps :
379- - uses : actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
380- with :
381- fetch-depth : 1
382- sparse-checkout : ci
383- - uses : actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
384- with :
385- name : rpm
386- - uses : docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3
387- - uses : docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
388- - name : generate dockerfile
389- run : |
390- echo 'FROM ${{ matrix.distro }}
391- ARG RHELARCH
392- COPY tyk-identity-broker*.${RHELARCH}.rpm /tyk-identity-broker.rpm
393- RUN command -v curl || yum install -y curl
394- RUN command -v useradd || yum install -y shadow-utils
395- # TODO(security): curl|bash - consider fetching script and verifying checksum before execution
396- RUN curl -fsSL https://packagecloud.io/install/repositories/tyk/tyk-identity-broker/script.rpm.sh | bash || echo "Repository setup failed, but continuing" # SECURITY: accepted risk, see TODO above
397- RUN yum install -y tyk-identity-broker-1.1.0-1 || echo "Previous version not found, testing fresh install"
398- RUN curl https://keyserver.tyk.io/tyk.io.rpm.signing.key.2020 -o tyk-identity-broker.key && rpm --import tyk-identity-broker.key
399- RUN rpm --checksig /tyk-identity-broker.rpm
400- RUN rpm -Uvh --force /tyk-identity-broker.rpm
401-
402- ' | tee Dockerfile
403- - name : install on ${{ matrix.distro }}
404- uses : docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6
405- with :
406- context : " ."
407- platforms : linux/${{ matrix.arch }}
408- build-args : |
409- RHELARCH=${{ startsWith(matrix.arch, 'arm64') && 'aarch64' || 'x86_64' }}
410- cache-from : type=gha
411- cache-to : type=gha,mode=max
412- file : Dockerfile
413- push : false
404+ uses : TykTechnologies/github-actions/.github/workflows/upgrade-tests.yml@production
405+ with :
406+ deb : ${{ needs.test-controller-distros.outputs.deb }}
407+ rpm : ${{ needs.test-controller-distros.outputs.rpm }}
408+ rpm_amd64 : ${{ needs.test-controller-distros.outputs.rpm_amd64 }}
409+ package_name : tyk-identity-broker
410+ upgrade_repo : tyk-identity-broker
411+ runs_on : ${{ vars.DEFAULT_RUNNER }}
412+ run_gateway_tests : false
0 commit comments