Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/support-multi-arch-releases #18

Merged
merged 4 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[build]
target = "x86_64-unknown-linux-musl"
target = "x86_64-unknown-linux-musl"
84 changes: 75 additions & 9 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,97 @@ env:
SQLX_OFFLINE: "true"

jobs:
unit-tests:
runs-on: ubuntu-latest
unit-tests-darwin:
runs-on: macos-latest
strategy:
matrix:
arch: [x86_64, aarch64]
steps:
- name: Ensure musl installed
run: sudo apt-get install -y musl-dev musl-tools musl && rustup target add x86_64-unknown-linux-musl
run: rustup target add ${{ matrix.arch }}-apple-darwin

- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2

- name: Run unit tests
run: cargo test --target ${{ matrix.arch }}-apple-darwin

unit-tests-linux:
runs-on: ubuntu-latest
strategy:
matrix:
arch: [x86_64, aarch64]
steps:
- name: Ensure toolchain installed
run: sudo apt-get install -y musl-dev musl-tools musl gcc-aarch64-linux-gnu llvm clang qemu-user && rustup target add ${{ matrix.arch }}-unknown-linux-musl

- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2

- name: Set up environment variables
run: |
if [ "${{ matrix.arch }}" == "aarch64" ]; then
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS=-Clink-self-contained=yes -Clinker=rust-lld" >> $GITHUB_ENV
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is required due to ring dependency

briansmith/ring#1414

I'm not using clang as suggested by someone in the mr. Reused what exists in the ring build scripts to get musl to work on aarch64

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2024-05-23 at 18 50 10

echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUNNER=qemu-aarch64 -L /usr/aarch64-linux-gnu" >> $GITHUB_ENV
echo "TARGET_CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
echo "TARGET_AR=aarch64-linux-gnu-ar" >> $GITHUB_ENV
fi

- name: Run unit tests
run: cargo test
run: cargo test --target ${{ matrix.arch }}-unknown-linux-musl

build-release-darwin:
runs-on: macos-latest
strategy:
matrix:
arch: [x86_64, aarch64]
if: github.ref == 'refs/heads/main'
steps:
- name: Ensure toolchain installed
run: rustup target add ${{ matrix.arch }}-apple-darwin

- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4

build-release:
- name: Build final release binary
run: cargo build --release --target ${{ matrix.arch }}-apple-darwin --verbose

- name: Upload artifact
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4
with:
name: iam-assumer-darwin-${{ matrix.arch }}
path: target/${{ matrix.arch }}-apple-darwin/release/iam-assumer

build-release-linux:
runs-on: ubuntu-latest
strategy:
matrix:
arch: [x86_64, aarch64]
if: github.ref == 'refs/heads/main'

steps:
- name: Ensure musl installed
run: sudo apt-get install -y musl-dev musl-tools musl && rustup target add x86_64-unknown-linux-musl
run: sudo apt-get install -y musl-dev musl-tools musl gcc-aarch64-linux-gnu llvm clang qemu-user && rustup target add ${{ matrix.arch }}-unknown-linux-musl

- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4

- name: Set up environment variables
run: |
if [ "${{ matrix.arch }}" == "aarch64" ]; then
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUSTFLAGS=-Clink-self-contained=yes -Clinker=rust-lld" >> $GITHUB_ENV
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_RUNNER=qemu-aarch64 -L /usr/aarch64-linux-gnu" >> $GITHUB_ENV
echo "TARGET_CC=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
echo "TARGET_AR=aarch64-linux-gnu-ar" >> $GITHUB_ENV
fi


- name: Build final release binary
run: cargo build --release --verbose
run: cargo build --release --target ${{ matrix.arch }}-unknown-linux-musl --verbose

- name: Upload artifact
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4
with:
name: iam-assumer
path: target/x86_64-unknown-linux-musl/release/iam-assumer
name: iam-assumer-linux-${{ matrix.arch }}
path: target/${{ matrix.arch }}-unknown-linux-musl/release/iam-assumer