diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 76431ea..b307772 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,16 +20,23 @@ jobs: steps: - name: Get Go versions id: versions + env: + GO_VERSION: ${{ vars.GO_VERSION }} run: | - VERSIONS=$( - curl -s 'https://go.dev/dl/?mode=json' \ - | jq -r ' - [.[] | select(.stable) | .version] - | group_by(split(".")[0:2] | join(".")) - | map(max_by(ltrimstr("go") | split(".") | map(tonumber)))[] - ' | sed 's/go//' - ) - VERSIONS_ARRAY=$(echo "$VERSIONS" | jq -R -s -c 'split("\n") | map(select(length > 0))') + if [ -n "$GO_VERSION" ]; then + # Repository variable overrides the API — build only that version + VERSIONS_ARRAY=$(jq -cn --arg v "$GO_VERSION" '[$v]') + else + VERSIONS=$( + curl -s 'https://go.dev/dl/?mode=json' \ + | jq -r ' + [.[] | select(.stable) | .version] + | group_by(split(".")[0:2] | join(".")) + | map(max_by(ltrimstr("go") | split(".") | map(tonumber)))[] + ' | sed 's/go//' + ) + VERSIONS_ARRAY=$(echo "$VERSIONS" | jq -R -s -c 'split("\n") | map(select(length > 0))') + fi echo "matrix={\"go-version\":$VERSIONS_ARRAY}" >> $GITHUB_OUTPUT - name: Get latest version diff --git a/Dockerfile b/Dockerfile index bd3a77a..9d5de7f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,6 +29,8 @@ WORKDIR /go FROM ubuntu:24.04@sha256:d1e2e92c075e5ca139d51a140fff46f84315c0fdce203eab2807c7e495eff4f9 +ARG GO_VERSION +LABEL org.opencontainers.image.version="${GO_VERSION}" RUN set -eux && \ apt-get update && \ @@ -43,6 +45,7 @@ RUN set -eux && \ ENV GOPATH=/go ENV PATH=$GOPATH/bin:/usr/local/go/bin:$PATH ENV CGO_ENABLED=0 +ENV GO_VERSION=${GO_VERSION} COPY --from=base /usr/local/go /usr/local/go