ci: build interop Docker image for pushes to master, and for releases (#4035)

* ci: build interop Docker image for pushes to master, and tag releases

* use self-hosted runner to build Docker image

* Apply suggestions from code review

Co-authored-by: Piotr Galar <piotr.galar@gmail.com>

* Update .github/workflows/build-interop-docker.yml

Co-authored-by: Piotr Galar <piotr.galar@gmail.com>

* build the correct commit

* Update .github/workflows/build-interop-docker.yml

---------

Co-authored-by: Piotr Galar <piotr.galar@gmail.com>
This commit is contained in:
Marten Seemann 2023-08-21 09:48:03 +07:00 committed by GitHub
parent fe3c4f271d
commit f689a5d023
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 9 deletions

View file

@ -1,11 +1,14 @@
name: Build interop Docker image name: Build interop Docker image
on: on:
push: push:
branches: [ interop ] branches:
- master
tags:
- 'v*'
jobs: jobs:
interop: interop:
runs-on: ubuntu-latest runs-on: ${{ fromJSON(vars['DOCKER_RUNNER_UBUNTU'] || '"ubuntu-latest"') }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: Set up QEMU - name: Set up QEMU
@ -19,9 +22,23 @@ jobs:
with: with:
username: ${{ secrets.DOCKER_USERNAME }} username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }} password: ${{ secrets.DOCKER_PASSWORD }}
- name: set tag name
id: tag
# Tagged releases won't be picked up by the interop runner automatically,
# but they can be useful when debugging regressions.
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
echo "tag=${GITHUB_REF#refs/tags/}" | tee -a $GITHUB_OUTPUT;
echo "gitref=${GITHUB_REF#refs/tags/}" | tee -a $GITHUB_OUTPUT;
else
echo 'tag=latest' | tee -a $GITHUB_OUTPUT;
echo 'gitref=${{ github.sha }}' | tee -a $GITHUB_OUTPUT;
fi
- uses: docker/build-push-action@v4 - uses: docker/build-push-action@v4
with: with:
context: "{{defaultContext}}:interop" context: "{{defaultContext}}:interop"
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
push: true push: true
tags: martenseemann/quic-go-interop:latest build-args: |
GITREF=${{ steps.tag.outputs.gitref }}
tags: martenseemann/quic-go-interop:${{ steps.tag.outputs.tag }}

View file

@ -5,7 +5,7 @@ RUN echo "TARGETPLATFORM: ${TARGETPLATFORM}"
RUN apt-get update && apt-get install -y wget tar git RUN apt-get update && apt-get install -y wget tar git
ENV GOVERSION=1.20.2 ENV GOVERSION=1.20.7
RUN platform=$(echo ${TARGETPLATFORM} | tr '/' '-') && \ RUN platform=$(echo ${TARGETPLATFORM} | tr '/' '-') && \
filename="go${GOVERSION}.${platform}.tar.gz" && \ filename="go${GOVERSION}.${platform}.tar.gz" && \
@ -18,14 +18,15 @@ ENV PATH="/go/bin:${PATH}"
# build with --build-arg CACHEBUST=$(date +%s) # build with --build-arg CACHEBUST=$(date +%s)
ARG CACHEBUST=1 ARG CACHEBUST=1
RUN git clone https://github.com/quic-go/quic-go && \ # build other branches / commits / tags using --build-arg GITREF="<git reference>"
cd quic-go && \ ARG GITREF="master"
git fetch origin interop && git checkout -t origin/interop && \
go get ./...
RUN git clone https://github.com/quic-go/quic-go
WORKDIR /quic-go WORKDIR /quic-go
RUN git checkout ${GITREF}
RUN go get ./...
RUN git rev-parse HEAD > commit.txt RUN git rev-parse HEAD | tee commit.txt
RUN go build -o server -ldflags="-X github.com/quic-go/quic-go/qlog.quicGoVersion=$(git describe --always --long --dirty)" interop/server/main.go RUN go build -o server -ldflags="-X github.com/quic-go/quic-go/qlog.quicGoVersion=$(git describe --always --long --dirty)" interop/server/main.go
RUN go build -o client -ldflags="-X github.com/quic-go/quic-go/qlog.quicGoVersion=$(git describe --always --long --dirty)" interop/client/main.go RUN go build -o client -ldflags="-X github.com/quic-go/quic-go/qlog.quicGoVersion=$(git describe --always --long --dirty)" interop/client/main.go