From 4642d75d90e119c7aa972b442586fd62ac6de2f0 Mon Sep 17 00:00:00 2001 From: Ruben Nijveld Date: Fri, 12 Apr 2024 11:50:07 +0200 Subject: [PATCH] Split up prebuilds, fix executable flag --- .github/workflows/docker-images.yml | 2 +- .github/workflows/docker.yml | 58 +++++++++++++++++++++-------- Dockerfile | 12 +++--- 3 files changed, 50 insertions(+), 22 deletions(-) diff --git a/.github/workflows/docker-images.yml b/.github/workflows/docker-images.yml index 0f857b4..af44a5b 100644 --- a/.github/workflows/docker-images.yml +++ b/.github/workflows/docker-images.yml @@ -14,7 +14,7 @@ jobs: base: uses: "tweedegolf/actions-container-helpers/.github/workflows/container-image.yml@main" with: - artifact: artifact + artifact: artifact-* push: ${{ github.ref == 'refs/heads/main' }} platforms: "linux/amd64,linux/arm64" build-args: | diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index ca9d36d..6ea1b0d 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -4,7 +4,14 @@ on: workflow_call: jobs: - prebuild-binaries: + prebuild-diesel: + strategy: + matrix: + include: + - rust_arch: aarch64-unknown-linux-gnu + docker_arch: arm64 + - rust_arch: x86_64-unknown-linux-gnu + docker_arch: amd64 runs-on: ubuntu-latest steps: - name: Setup Rust toolchain @@ -33,33 +40,52 @@ jobs: "apt-get update && apt-get install --assume-yes libpq-dev:amd64" ] EOF - cross build --release --target aarch64-unknown-linux-gnu --no-default-features --features "postgres, sqlite-bundled" - cross build --release --target x86_64-unknown-linux-gnu --no-default-features --features "postgres, sqlite-bundled" - mv target/aarch64-unknown-linux-gnu target/arm64 - mv target/x86_64-unknown-linux-gnu target/amd64 + cross build --release --target ${{ matrix.rust_arch }} --no-default-features --features "postgres, sqlite-bundled" + mv target/${{ matrix.rust_arch }}/release/diesel target/diesel.${{ matrix.docker_arch }} + + - name: Upload artifacts + uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 + with: + name: artifact-diesel-${{ matrix.rust_arch }} + path: diesel_cli/target/diesel.${{ matrix.docker_arch }} + if-no-files-found: error + + prebuild-cargo-llvm-lines: + strategy: + matrix: + include: + - rust_arch: aarch64-unknown-linux-gnu + docker_arch: arm64 + - rust_arch: x86_64-unknown-linux-gnu + docker_arch: amd64 + runs-on: ubuntu-latest + steps: + - name: Setup Rust toolchain + uses: dtolnay/rust-toolchain@7164405e8653277d57afd42ba081b5aa02a70396 + with: + toolchain: stable + + - name: Install development tools + uses: taiki-e/install-action@f8a64c940979268d3ab5ac99c178e718ed90977d # v2.32.14 + with: + tool: cargo-clone,cross - name: Download and build cargo-llvm-lines run: | cargo clone cargo-llvm-lines cd cargo-llvm-lines - cross build --release --target aarch64-unknown-linux-gnu - cross build --release --target x86_64-unknown-linux-gnu - mv target/aarch64-unknown-linux-gnu target/arm64 - mv target/x86_64-unknown-linux-gnu target/amd64 + cross build --release --target ${{ matrix.rust_arch }} + mv target/${{ matrix.rust_arch }}/release/cargo-llvm-lines target/cargo-llvm-lines.${{ matrix.docker_arch }} - name: Upload artifacts uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 with: - name: artifact - path: | - diesel_cli/target/amd64/release/diesel - diesel_cli/target/arm64/release/diesel - cargo-llvm-lines/target/amd64/release/cargo-llvm-lines - cargo-llvm-lines/target/arm64/release/cargo-llvm-lines + name: artifact-cargo-llvm-lines-${{ matrix.rust_arch }} + path: cargo-llvm-lines/target/cargo-llvm-lines.${{ matrix.docker_arch }} if-no-files-found: error build: - needs: [prebuild-binaries] + needs: [prebuild-diesel, prebuild-cargo-llvm-lines] strategy: matrix: include: diff --git a/Dockerfile b/Dockerfile index 19f7875..e41e6ac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,7 @@ FROM ghcr.io/tweedegolf/debian:bookworm +ARG TARGETARCH + RUN set -eux; \ apt-get update; \ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ @@ -64,11 +66,6 @@ RUN set -eux; \ cargo --version; \ rustc --version; -ARG TARGETARCH - -COPY diesel_cli/target/$TARGETARCH/release/diesel /usr/local/cargo/bin/diesel -COPY cargo-llvm-lines/target/$TARGETARCH/release/cargo-llvm-lines /usr/local/cargo/bin/cargo-llvm-lines - ARG SCCACHE_VERSION ENV SCCACHE_VERSION ${SCCACHE_VERSION} @@ -124,7 +121,12 @@ RUN set -eux; \ rm -rf "/tmp/cargo-binstall-$cargo_binstall_arch.tgz"; \ cargo binstall -V; +COPY diesel.$TARGETARCH /usr/local/cargo/bin/diesel +COPY cargo-llvm-lines.$TARGETARCH /usr/local/cargo/bin/cargo-llvm-lines + RUN set -eux; \ + chmod +x /usr/local/cargo/bin/diesel; \ + chmod +x /usr/local/cargo/bin/cargo-llvm-lines; \ dpkgArch="$(dpkg --print-architecture)"; \ case "${dpkgArch##*-}" in \ amd64) set -- --targets x86_64-unknown-linux-gnu --targets x86_64-unknown-linux-musl ;; \