From d285dd716e91456351c30ed98a43df5bbc7fd65a Mon Sep 17 00:00:00 2001 From: Carlos Eduardo Arango Gutierrez Date: Thu, 25 Jan 2024 17:12:26 +0100 Subject: [PATCH] Build multiple go versions Signed-off-by: Carlos Eduardo Arango Gutierrez --- .github/workflows/images.yaml | 28 +++++++++++++--------------- README.md | 2 +- images/devel/Dockerfile | 2 +- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/.github/workflows/images.yaml b/.github/workflows/images.yaml index 419ad7c6..e613a1e6 100644 --- a/.github/workflows/images.yaml +++ b/.github/workflows/images.yaml @@ -31,9 +31,11 @@ on: jobs: build: runs-on: ubuntu-latest + strategy: + matrix: + go-version: ["1.21","1.20","1.19"] steps: - uses: actions/checkout@v4 - - name: Calculate build vars id: vars run: | @@ -47,30 +49,26 @@ jobs: else echo "PUSH_ON_BUILD=true" >> $GITHUB_ENV fi - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Login to GitHub Container Registry uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Build image env: - GOLANG_VERSION: "1.21.6" + GOLANG_VERSION: ${{ matrix.go-version }} run: | - docker build --build-arg GOLANG_VERSION=${GOLANG_VERSION} \ - -f ./images/devel/Dockerfile \ - --tag ghcr.io/${LOWERCASE_REPO_OWNER}/k8s-test-infra:${COMMIT_SHORT_SHA} \ - . - push: - needs: build - runs-on: ubuntu-latest - if: github.event_name == 'push' && github.ref == 'refs/heads/main' - steps: + docker build --build-arg GOLANG_VERSION=${GOLANG_VERSION} \ + -f ./images/devel/Dockerfile \ + --tag ghcr.io/${LOWERCASE_REPO_OWNER}/k8s-test-infra:devel-go${GOLANG_VERSION} \ + . - name: Push image + env: + GOLANG_VERSION: ${{ matrix.go-version }} run: | - docker push ghcr.io/${LOWERCASE_REPO_OWNER}/k8s-test-infra:${COMMIT_SHORT_SHA} + if [[ "${PUSH_ON_BUILD}" == "true" ]]; then + docker push ghcr.io/${LOWERCASE_REPO_OWNER}/k8s-test-infra:devel-go${GOLANG_VERSION} + fi diff --git a/README.md b/README.md index 8e534a37..8b2c26b8 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# k8s-ci-artifacts \ No newline at end of file +# k8s-test-infra \ No newline at end of file diff --git a/images/devel/Dockerfile b/images/devel/Dockerfile index d30f76c0..d1e74c6e 100644 --- a/images/devel/Dockerfile +++ b/images/devel/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -ARG GOLANG_VERSION=x.x.x +ARG GOLANG_VERSION=x.x FROM golang:${GOLANG_VERSION} RUN go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.52.0 \