ci: Update fetch-proxy to lookup versions by name (#12322)

We previously relied on knowing the tag structure, but this is brittle if we
change anything in the proxy repo. Instead, we now use the GitHub API to
list all releases, and we match the version by name.
This commit is contained in:
Oliver Gould 2024-03-21 12:58:39 -07:00 committed by GitHub
parent bf6b213495
commit 006f0dd00e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 4 additions and 7 deletions

View File

@ -39,6 +39,7 @@ jobs:
**/Dockerfile*
charts/**
justfile
bin/fetch-proxy
bin/_test-helper.sh
files_ignore: |
.devcontainer/**

View File

@ -19,7 +19,6 @@ COPY bin/fetch-proxy bin/fetch-proxy
COPY bin/scurl bin/scurl
ARG TARGETARCH
ARG LINKERD2_PROXY_REPO="linkerd/linkerd2-proxy"
ARG LINKERD2_PROXY_RELEASE_PREFIX="release/"
ARG LINKERD2_PROXY_VERSION=""
RUN --mount=type=secret,id=github \
export GITHUB_TOKEN_FILE=/run/secrets/github; \

View File

@ -30,7 +30,6 @@ get_extra_options() {
docker_build proxy "${TAG:-$(head_root_tag)}" "$dockerfile" \
--build-arg LINKERD_VERSION="${TAG:-$(head_root_tag)}" \
--build-arg LINKERD2_PROXY_REPO="${LINKERD2_PROXY_REPO:-linkerd/linkerd2-proxy}" \
--build-arg LINKERD2_PROXY_RELEASE_PREFIX="${LINKERD2_PROXY_RELEASE_PREFIX:-release/}" \
--build-arg LINKERD2_PROXY_VERSION="${LINKERD2_PROXY_VERSION:-$(cat .proxy-version)}" \
--secret id=github,env=LINKERD2_PROXY_GITHUB_TOKEN \
$(get_extra_options)

View File

@ -17,7 +17,6 @@ if [ -z "$proxy_repo" ]; then
fi
releases_url=https://api.github.com/repos/"$proxy_repo"/releases
release_prefix="${LINKERD2_PROXY_RELEASE_PREFIX:-release/}"
github_token="${GITHUB_TOKEN:-}"
if [ -z "$github_token" ] && [ -n "${GITHUB_TOKEN_FILE:-}" ] && [ -f "$GITHUB_TOKEN_FILE" ]; then
@ -37,10 +36,9 @@ cd "$builddir"
version=${1:-latest}
arch=${2:-amd64}
tag="${release_prefix}${version}"
release_url="$releases_url"/tags/"$(printf "$tag" | jq -sRr @uri)"
if ! ghcurl "$release_url" > release.json ; then
echo "Failed to fetch $release_url" >&2
if ! ghcurl "$releases_url" | jq '.[] | select(.name == "'"$version"'")' > release.json ; then
echo "Failed to fetch $releases_url" >&2
exit 1
fi