Skip to content

Commit

Permalink
Split up prebuilds, fix executable flag
Browse files Browse the repository at this point in the history
  • Loading branch information
rnijveld committed Apr 12, 2024
1 parent ea8c0b6 commit 4642d75
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
58 changes: 42 additions & 16 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
12 changes: 7 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down Expand Up @@ -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}

Expand Down Expand Up @@ -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 ;; \
Expand Down

0 comments on commit 4642d75

Please sign in to comment.