Skip to content

Commit f1441a4

Browse files
committed
chore: update release workflow to support ARM64 builds on Ubuntu
1 parent f21499f commit f1441a4

File tree

3 files changed

+146
-38
lines changed

3 files changed

+146
-38
lines changed

.github/workflows/release.yml

Lines changed: 91 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,21 @@ jobs:
1212
strategy:
1313
matrix:
1414
include:
15-
# - os: ubuntu-latest
16-
# target: x86_64-unknown-linux-gnu
17-
# asset_name: linux-amd64
1815
- os: windows-latest
1916
target: x86_64-pc-windows-msvc
2017
asset_name: windows-amd64
21-
# - os: macos-latest
22-
# target: aarch64-apple-darwin
23-
# asset_name: darwin-arm64
24-
# - os: macos-latest
25-
# target: x86_64-apple-darwin
26-
# asset_name: darwin-amd64
18+
- os: ubuntu-latest
19+
target: x86_64-unknown-linux-gnu
20+
asset_name: linux-amd64
21+
- os: ubuntu-latest
22+
target: aarch64-unknown-linux-gnu
23+
asset_name: linux-arm64
24+
- os: macos-latest
25+
target: aarch64-apple-darwin
26+
asset_name: darwin-arm64
27+
- os: macos-latest
28+
target: x86_64-apple-darwin
29+
asset_name: darwin-amd64
2730
fail-fast: false
2831

2932
runs-on: ${{ matrix.os }}
@@ -44,12 +47,24 @@ jobs:
4447
submodules: recursive
4548
path: slipstream-rust
4649

50+
- name: Set up QEMU
51+
if: runner.os == 'Linux' && matrix.target == 'aarch64-unknown-linux-gnu'
52+
uses: docker/setup-qemu-action@v3
53+
54+
- name: Set up Docker Buildx
55+
if: runner.os == 'Linux' && matrix.target == 'aarch64-unknown-linux-gnu'
56+
uses: docker/setup-buildx-action@v3
57+
with:
58+
platforms: linux/arm64,linux/amd64
59+
4760
- name: Install Rust
61+
if: runner.os != 'Linux' || matrix.target != 'aarch64-unknown-linux-gnu'
4862
uses: dtolnay/rust-toolchain@stable
4963
with:
5064
targets: ${{ matrix.target }}
5165

5266
- name: Install cross toolchain
67+
if: runner.os != 'Linux' || matrix.target != 'aarch64-unknown-linux-gnu'
5368
uses: taiki-e/setup-cross-toolchain-action@v1
5469
with:
5570
target: ${{ env.TARGET }}
@@ -63,6 +78,7 @@ jobs:
6378
echo "short_commit=$(git rev-parse --short=7 HEAD)" >> $GITHUB_OUTPUT
6479
6580
- name: Cache Rust dependencies
81+
if: runner.os != 'Linux' || matrix.target != 'aarch64-unknown-linux-gnu'
6682
uses: actions/cache@v4
6783
with:
6884
path: |
@@ -77,10 +93,13 @@ jobs:
7793
${{ runner.os }}-rust-
7894
7995
- name: Install build dependencies (Linux)
80-
if: runner.os == 'Linux'
96+
if: runner.os == 'Linux' && matrix.target != 'aarch64-unknown-linux-gnu'
8197
run: |
8298
sudo apt-get update
83-
sudo apt-get install -y cmake pkg-config libssl-dev gcc g++ perl
99+
sudo apt-get install -y cmake pkg-config gcc g++ perl
100+
if [[ "${{ matrix.target }}" == "x86_64-unknown-linux-gnu" ]]; then
101+
sudo apt-get install -y libssl-dev
102+
fi
84103
85104
- name: Install build dependencies (macOS)
86105
if: runner.os == 'macOS'
@@ -167,8 +186,41 @@ jobs:
167186
echo "OPENSSL_ROOT_DIR=/opt/homebrew/opt/openssl@3" >> $GITHUB_ENV
168187
fi
169188
189+
- name: Build with Docker buildx (Linux ARM64)
190+
if: runner.os == 'Linux' && matrix.target == 'aarch64-unknown-linux-gnu'
191+
run: |
192+
# Create a temporary directory for the build output
193+
mkdir -p docker-build-output
194+
195+
mkdir -p slipstream-rust/target/aarch64-unknown-linux-gnu/release
196+
197+
# Build the image for linux/arm64 and load it using a pipe
198+
# This works around the --load limitation with cross-platform builds
199+
docker buildx build \
200+
--platform linux/arm64 \
201+
--file Dockerfile.arm64 \
202+
--tag slipstream-build:arm64 \
203+
--output type=docker,dest=- \
204+
. | docker load
205+
206+
# Run the container with --platform flag to use QEMU emulation
207+
# Mount slipstream-rust as read-write so build artifacts can be written
208+
docker run --rm \
209+
--platform linux/arm64 \
210+
-v "${{ github.workspace }}/slipstream-rust:/workspace/slipstream-rust" \
211+
-v "${{ github.workspace }}/docker-build-output:/workspace/output" \
212+
slipstream-build:arm64
213+
214+
sudo chown -R $(id -u):$(id -g) slipstream-rust/target/ 2>/dev/null || true
215+
216+
cp docker-build-output/slipstream-client slipstream-rust/target/aarch64-unknown-linux-gnu/release/
217+
cp docker-build-output/slipstream-server slipstream-rust/target/aarch64-unknown-linux-gnu/release/
218+
219+
# Verify binaries exist
220+
ls -lh slipstream-rust/target/aarch64-unknown-linux-gnu/release/
221+
170222
- name: Build picoquic (Linux)
171-
if: runner.os == 'Linux'
223+
if: runner.os == 'Linux' && matrix.target != 'aarch64-unknown-linux-gnu'
172224
working-directory: slipstream-rust
173225
run: |
174226
bash scripts/build_picoquic.sh
@@ -418,6 +470,7 @@ jobs:
418470
fi
419471
420472
- name: Build slipstream binaries
473+
if: runner.os != 'Linux' || matrix.target != 'aarch64-unknown-linux-gnu'
421474
working-directory: slipstream-rust
422475
shell: bash
423476
env:
@@ -499,32 +552,32 @@ jobs:
499552
[ "${{ runner.os }}" != "Windows" ] && chmod +x build_assets/*
500553
echo "Binaries prepared successfully"
501554
502-
# - name: Create release if needed
503-
# shell: bash
504-
# env:
505-
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
506-
# run: |
507-
# TAG="${{ steps.get_commit.outputs.short_commit }}"
508-
# if ! gh release view "$TAG" &>/dev/null; then
509-
# gh release create "$TAG" \
510-
# --title "Release $TAG" \
511-
# --notes "Release for slipstream-rust commit $TAG
512-
513-
# This release contains prebuilt binaries for:
514-
# - Linux (x86_64)
515-
# - Windows (x86_64)
516-
# - macOS (ARM64)
517-
# - macOS (Intel x86_64)"
518-
# fi
519-
520-
# - name: Upload binaries to release
521-
# uses: svenstaro/upload-release-action@v2
522-
# with:
523-
# repo_token: ${{ secrets.GITHUB_TOKEN }}
524-
# file: build_assets/slipstream-*
525-
# file_glob: true
526-
# tag: ${{ steps.get_commit.outputs.short_commit }}
527-
# overwrite: true
555+
- name: Create release if needed
556+
shell: bash
557+
env:
558+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
559+
run: |
560+
TAG="${{ steps.get_commit.outputs.short_commit }}"
561+
if ! gh release view "$TAG" &>/dev/null; then
562+
gh release create "$TAG" \
563+
--title "Release $TAG" \
564+
--notes "Release for slipstream-rust commit $TAG
565+
566+
This release contains prebuilt binaries for:
567+
- Linux (x86_64)
568+
- Windows (x86_64)
569+
- macOS (ARM64)
570+
- macOS (Intel x86_64)"
571+
fi
572+
573+
- name: Upload binaries to release
574+
uses: svenstaro/upload-release-action@v2
575+
with:
576+
repo_token: ${{ secrets.GITHUB_TOKEN }}
577+
file: build_assets/slipstream-*
578+
file_glob: true
579+
tag: ${{ steps.get_commit.outputs.short_commit }}
580+
overwrite: true
528581

529582
- name: Upload artifacts
530583
uses: actions/upload-artifact@v4

Dockerfile.arm64

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
FROM ubuntu:24.04
2+
3+
RUN apt-get update && apt-get install -y \
4+
curl \
5+
cmake \
6+
pkg-config \
7+
gcc \
8+
g++ \
9+
perl \
10+
libssl-dev \
11+
git \
12+
ca-certificates \
13+
&& rm -rf /var/lib/apt/lists/*
14+
15+
ENV RUSTUP_HOME=/usr/local/rustup \
16+
CARGO_HOME=/usr/local/cargo \
17+
PATH=/usr/local/cargo/bin:$PATH
18+
19+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y \
20+
&& rustup target add aarch64-unknown-linux-gnu
21+
22+
WORKDIR /workspace
23+
24+
COPY build-docker.sh /workspace/build-docker.sh
25+
RUN chmod +x /workspace/build-docker.sh
26+
27+
CMD ["/workspace/build-docker.sh"]

build-docker.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
set -e
3+
4+
cd /workspace
5+
6+
if [ ! -d "slipstream-rust" ]; then
7+
echo "ERROR: slipstream-rust directory not found. It should be mounted as a volume."
8+
exit 1
9+
fi
10+
11+
cd slipstream-rust
12+
13+
echo "Building picoquic..."
14+
bash scripts/build_picoquic.sh
15+
16+
export PICOQUIC_DIR=/workspace/slipstream-rust/vendor/picoquic
17+
export PICOQUIC_BUILD_DIR=/workspace/slipstream-rust/.picoquic-build
18+
export PICOQUIC_FETCH_PTLS=ON
19+
export PICOQUIC_AUTO_BUILD=1
20+
21+
echo "Building slipstream binaries..."
22+
cargo build --release --target aarch64-unknown-linux-gnu -p slipstream-client -p slipstream-server
23+
24+
mkdir -p /workspace/output
25+
cp target/aarch64-unknown-linux-gnu/release/slipstream-client /workspace/output/
26+
cp target/aarch64-unknown-linux-gnu/release/slipstream-server /workspace/output/
27+
28+
echo "Build complete! Binaries are in /workspace/output/"

0 commit comments

Comments
 (0)