diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 000000000..312b59474 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,84 @@ +# Build and push verilator docker image when tags are pushed to the repository. +# The following secrets must be configured in the github repository: +# DOCKER_HUB_NAMESPACE: docker hub namespace. +# DOCKER_HUB_USER: user name for logging into docker hub +# DOCKER_HUB_ACCESS_TOKEN: docker hub access token. +name: Build Verilator Container + +on: + push: + tags: [ 'v*' ] + workflow_dispatch: + inputs: + manual_tag: + description: 'Git tag to use for image build' + required: true + type: string + add_latest_tag: + description: 'Tag workflow_dispatch docker image as "latest"' + required: true + type: boolean + default: false + +jobs: + + build: + + runs-on: ubuntu-22.04 + + strategy: + matrix: + contexts: + - "ci/docker/run:verilator" + # - "ci/docker/buildenv:verilator-buildenv" + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Extract context variables + run: | + echo "${{ matrix.contexts }}" | sed -r 's/(.*):.*/build_context=\1/' >> "$GITHUB_ENV" + echo "${{ matrix.contexts }}" | sed -r 's/.*:(.*)/image_name=\1/' >> "$GITHUB_ENV" + echo "git_tag=${GITHUB_REF#refs/*/}" >> "$GITHUB_ENV" + + - name: Use manual tag + if: ${{ inputs.manual_tag }} + run: | + echo "git_tag=${{ inputs.manual_tag }}" >> "$GITHUB_ENV" + + - name: Docker meta + id: docker_meta + uses: docker/metadata-action@v4 + with: + images: | + ${{ secrets.DOCKER_HUB_NAMESPACE }}/${{ env.image_name }} + tags: | + type=match,pattern=(v.*),group=1,enable=${{ startsWith(github.ref, 'refs/tags/v') }} + type=raw,value=${{ inputs.manual_tag }},enable=${{ inputs.manual_tag != '' }} + type=raw,value=latest,enable=${{ inputs.add_latest_tag == true }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + with: + buildkitd-flags: --debug + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_HUB_USER }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + + - name: Build and Push to Docker + uses: docker/build-push-action@v4 + if: startsWith(github.ref, 'refs/tags/v') + with: + context: ${{ env.build_context }} + build-args: SOURCE_COMMIT=${{ env.git_tag }} + platforms: linux/arm64,linux/amd64 + push: ${{ !env.ACT && startsWith(github.ref, 'refs/tags/v') }} + tags: ${{ steps.docker_meta.outputs.tags }} + labels: ${{ steps.docker_meta.outputs.labels }} diff --git a/README.rst b/README.rst index 8e8e57bb8..e45c73fb9 100644 --- a/README.rst +++ b/README.rst @@ -13,6 +13,8 @@ :target: https://codecov.io/gh/verilator/verilator .. image:: https://github.com/verilator/verilator/workflows/build/badge.svg :target: https://github.com/verilator/verilator/actions?query=workflow%3Abuild +.. image:: https://img.shields.io/docker/pulls/verilator/verilator + :target: https://hub.docker.com/r/verilator/verilator Welcome to Verilator diff --git a/ci/docker/run/Dockerfile b/ci/docker/run/Dockerfile index fa5c98519..24128ccc9 100644 --- a/ci/docker/run/Dockerfile +++ b/ci/docker/run/Dockerfile @@ -19,10 +19,16 @@ RUN apt-get update \ ccache \ flex \ git \ + help2man \ + libfl2 \ libfl-dev \ libgoogle-perftools-dev \ + numactl \ perl \ + perl-doc \ python3 \ + zlib1g \ + zlib1g-dev \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* @@ -39,7 +45,7 @@ RUN git clone "${REPO}" verilator && \ git checkout "${SOURCE_COMMIT}" && \ autoconf && \ ./configure && \ - make -j "$(nproc)" && \ + make && \ make install && \ cd .. && \ rm -r verilator diff --git a/docs/CONTRIBUTORS b/docs/CONTRIBUTORS index 85fcb791f..35cdff8d7 100644 --- a/docs/CONTRIBUTORS +++ b/docs/CONTRIBUTORS @@ -72,6 +72,7 @@ Joey Liu John Coiner John Demme Jonathan Drolet +Jose Loyola Joseph Nwabueze Josep Sans Josh Redford