From 4e044f3ca32a4f7c426b91a95b79c5d4daa6d491 Mon Sep 17 00:00:00 2001 From: David Herberth Date: Fri, 15 Mar 2024 12:22:47 +0100 Subject: [PATCH] docker image, more platforms --- .github/workflows/ci.yml | 50 +++++++++++++++++++++++++++++++++------- Cross.toml | 7 +----- 2 files changed, 43 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c0d9e2461f..86ea3e7dc6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -183,10 +183,22 @@ jobs: timeout-minutes: 30 strategy: matrix: - target: [aarch64-unknown-linux-gnu] + platform: + - target: aarch64-unknown-linux-gnu + docker: linux/arm64 + - target: x86_64-unknown-linux-gnu + docker: linux/amd64 + image: + - name: relay + features: "processing,crash-handler" name: Build Docker Image runs-on: ubuntu-latest + + if: "!startsWith(github.ref, 'refs/heads/release-library/')" + + env: + DOCKER_IMAGE: "ghcr.io/getsentry/${{ matrix.image.name }}:${{ github.event.pull_request.head.sha || github.sha }}" steps: - uses: actions/checkout@v4 @@ -198,18 +210,40 @@ jobs: - uses: swatinem/rust-cache@v2 with: key: ${{ github.job }}-${{ matrix.arch }} - - name: Get Cross + - name: Install Cross run: cargo install cross + - name: Compile run: | export PATH="/home/runner/.cargo/bin/:$PATH" - cross build --all-features --release --target "${{ matrix.target }}" + cross build --release --features "${{ matrix.image.features }}" --target "${{ matrix.platform.target }}" - - name: Archive Binary - uses: actions/upload-artifact@v4 - with: - name: "relay-${{ matrix.target }}" - path: "target/${{ matrix.target }}/release/relay" + # - name: Archive Binary + # uses: actions/upload-artifact@v4 + # with: + # name: "relay-${{ matrix.target }}" + # path: "target/${{ matrix.target }}/release/relay" + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Push to ghcr.io + # Do not run this on forks as they do not have access to secrets + if: "!github.event.pull_request.head.repo.fork && github.actor != 'dependabot[bot]'" + run: | + set -euxo pipefail + docker login --username '${{ github.actor }}' --password '${{ secrets.GITHUB_TOKEN }}' ghcr.io + + cp "target/${{ matrix.target }}/release/relay" ./relay-bin + + docker buildx build \ + --platform "${{ matrix.platform.docker }}" \ + --tag "${DOCKER_IMAGE}" \ + --file Dockerfile.release + + docker push "${DOCKER_IMAGE}" # build: # timeout-minutes: 30 diff --git a/Cross.toml b/Cross.toml index e73c6eaa19..357d1f8407 100644 --- a/Cross.toml +++ b/Cross.toml @@ -1,9 +1,4 @@ [build] pre-build = [ - # "dpkg --add-architecture $CROSS_DEB_ARCH", - # "apt-get update && apt-get --assume-yes install -f -o Dpkg::Options::=\"--force-overwrite\" libclang-dev:$CROSS_DEB_ARCH" - "printf \"deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-12 main\" |sudo tee /etc/apt/sources.list.d/llvm-toolchain-xenial-12.list", - "wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key |sudo apt-key add -", - # "apt-get update && apt-cache search clang && apt-get --assume-yes install libclang-5.0-dev clang-3.8" - "apt-get update && apt-cache search clang && apt-get --assume-yes install llvm-12" + "apt-get update && apt-get --assume-yes install libclang-5.0-dev clang-3.8" ]