Skip to content

Commit

Permalink
feat(ci): Build Relay for Linux ARM
Browse files Browse the repository at this point in the history
  • Loading branch information
iker-barriocanal committed Aug 7, 2023
1 parent de48625 commit ce90e9c
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
runner = "qemu-aarch64"
35 changes: 32 additions & 3 deletions .github/workflows/build_binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ name: Binary Release Build
on:
push:
branches:
- release/**
# - release/** # testing

env:
CARGO_TERM_COLOR: always

jobs:
linux:
name: Linux
linux_x86:
name: Linux x86
runs-on: ubuntu-latest

steps:
Expand Down Expand Up @@ -38,6 +38,35 @@ jobs:
name: ${{ github.sha }}
path: target/x86_64-unknown-linux-gnu/release/relay-Linux-x86_64*

linux_arm:
name: Linux ARM
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Build in Docker
run: |
# Get the latest stable rust toolchain version available
TOOLCHAIN=$(curl -s 'https://static.rust-lang.org/dist/channel-rust-stable.toml' | awk '/\[pkg.rust\]/ {getline;print;}' | sed -r 's/^version = "([0-9.]+) .*/\1/')
scripts/docker-build-linux.sh "$TOOLCHAIN"
env:
BUILD_ARCH: aarch64
RELAY_FEATURES:

- name: Bundle Debug File
run: |
cd target/aarch64-unknown-linux-gnu/release/
zip relay-Linux-aarch64-debug.zip relay.debug
mv relay relay-Linux-aarch64
- uses: actions/upload-artifact@v3
with:
name: ${{ github.sha }}
path: target/aarch64-unknown-linux-gnu/release/relay-Linux-aarch64*

macos:
name: macOS
runs-on: macos-11
Expand Down
14 changes: 12 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,25 @@ RUN yum -y update \
llvm-toolset-7.0-clang-devel \
&& yum clean all \
&& rm -rf /var/cache/yum \
&& ln -s /usr/bin/cmake3 /usr/bin/cmake
&& ln -s /usr/bin/cmake3 /usr/bin/cmake \
&& if [ ${BUILD_ARCH} == "aarch64" ]; then \
yum -y install curl dnf ca-certificates gcc-aarch64-linux-gnu qemu-user \
&& dnf --forcearch aarch64 --release 7 install -y glibc glibc-devel --installroot "/usr/aarch64-linux-gnu/sys-root/" \
&& curl -L -s https://www.centos.org/keys/RPM-GPG-KEY-CentOS-7-aarch64 > /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7-aarch64 \
&& cat /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7-aarch64 >> /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7 \
&& ln -s "/usr/aarch64-linux-gnu/sys-root/lib64/libgcc_s.so.1" "/usr/aarch64-linux-gnu/sys-root/lib64/libgcc_s.so" \
# NOTE(iker): work-around to create a cmake toolchain file for arch-specific builds, since only objcopy is needed.
&& rm -rf "/usr/bin/objcopy" && ln -s "/usr/bin/aarch64-linux-gnu-objcopy" "/usr/bin/objcopy" ; \
fi

ENV RUSTUP_HOME=/usr/local/rustup \
CARGO_HOME=/usr/local/cargo \
PATH=/usr/local/cargo/bin:$PATH

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
| sh -s -- -y --profile minimal --default-toolchain=${RUST_TOOLCHAIN_VERSION} \
&& echo -e '[registries.crates-io]\nprotocol = "sparse"\n[net]\ngit-fetch-with-cli = true' > $CARGO_HOME/config
&& echo -e '[registries.crates-io]\nprotocol = "sparse"\n[net]\ngit-fetch-with-cli = true' > $CARGO_HOME/config \
&& rustup target add aarch64-unknown-linux-gnu

COPY --from=sentry-cli /bin/sentry-cli /bin/sentry-cli

Expand Down
4 changes: 3 additions & 1 deletion scripts/docker-build-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ set -eux

TOOLCHAIN=$1

if [ "${BUILD_ARCH}" = "x86_64" ]; then
if [ "${BUILD_ARCH}" = "aarch64" ]; then
DOCKER_ARCH="amd64"
elif [ "${BUILD_ARCH}" = "x86_64" ]; then
DOCKER_ARCH="amd64"
elif [ "${BUILD_ARCH}" = "i686" ]; then
DOCKER_ARCH="i386"
Expand Down

0 comments on commit ce90e9c

Please sign in to comment.