Linux #2112
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Linux | |
| on: | |
| push: | |
| branches: ["dev"] | |
| pull_request: | |
| branches: ["dev"] | |
| env: | |
| CARGO_TERM_COLOR: always | |
| SCCACHE_GHA_ENABLED: "on" | |
| RUSTC_WRAPPER: "sccache" | |
| jobs: | |
| Linux: | |
| name: Ubuntu-24.04 | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - name: Rust Toolchain | |
| uses: dtolnay/rust-toolchain@nightly | |
| with: | |
| components: rust-src | |
| - name: Rust Cache | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| cache-all-crates: "true" | |
| cache-workspace-crates: "true" | |
| - name: Run sccache-cache | |
| uses: mozilla-actions/sccache-action@main | |
| - name: Get latest Android NDK version | |
| run: | | |
| latest_ndk=$(curl -fsSL https://developer.android.com/ndk/downloads \ | |
| | sed -n 's/.*Latest Stable Version (\([^)]*\)).*/\1/p') | |
| echo "NDK_VERSION=$latest_ndk" >> $GITHUB_ENV | |
| echo "Latest NDK: $latest_ndk" | |
| - name: Android NDK cache | |
| uses: actions/cache@v5 | |
| with: | |
| path: ~/android-ndk-${{ env.NDK_VERSION }} | |
| key: android-ndk-${{ env.NDK_VERSION }} | |
| restore-keys: android-ndk-${{ env.NDK_VERSION }} | |
| - name: Setup OpenHarmony SDK | |
| uses: openharmony-rs/setup-ohos-sdk@main | |
| with: | |
| version: "6.0.0.1" | |
| - name: Cache openwrt | |
| uses: actions/cache@v5 | |
| with: | |
| path: /home/runner/openwrt | |
| key: openwrt-25.12.0 | |
| restore-keys: openwrt-25.12.0 | |
| - name: Ubuntu apt update and install | |
| run: sudo apt install gcc-powerpc64-linux-gnu crosshurd musl-tools libfuse3-dev -qy | |
| - name: Cache Redoxer | |
| uses: actions/cache@v5 | |
| with: | |
| path: | | |
| ~/.redoxer | |
| ~/.cargo/bin/redoxer | |
| key: redoxer | |
| restore-keys: redoxer | |
| - name: Build Release | |
| run: | | |
| # sudo snap install zig --classic --beta | |
| # pipx install cargo-zigbuild | |
| ver=${NDK_VERSION} | |
| export ANDROID_NDK_HOME=~/android-ndk-$ver | |
| ln -sf "$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64" ndk | |
| if [ ! -d ~/android-ndk-${ver} ]; then | |
| mkdir -p ~/android-ndk-${ver} | |
| echo "Downloading Android NDK..." | |
| curl -fsSLO https://dl.google.com/android/repository/android-ndk-${ver}-linux.zip | |
| echo "Unzipping Android NDK..." | |
| unzip -q android-ndk-${ver}-linux.zip -d ~/ | |
| fi | |
| ln -sf $OHOS_SDK_NATIVE/llvm ohos | |
| ln -sf $OHOS_SDK_NATIVE/sysroot ohos-root | |
| cargo update | |
| set +e -x | |
| if [ ! -f ~/.cargo/bin/redoxer ]; then | |
| cargo install --git https://gitlab.redox-os.org/redox-os/redoxer.git --locked redoxer -q --force | |
| fi | |
| mv .cargo/config.toml .cargo/config.toml.bak | |
| mv .cargo/redox.toml .cargo/config.toml | |
| targets=( | |
| aarch64-unknown-redox | |
| riscv64gc-unknown-redox | |
| x86_64-unknown-redox | |
| ) | |
| for target in ${targets[@]}; do | |
| redoxer env TARGET=$target bash -c " | |
| if [ ! -d ~/.redoxer/toolchain/$target ]; then | |
| redoxer toolchain | |
| fi | |
| time redoxer build -- -q --profile redox -Zbuild-std=std,panic_abort -Zbuild-std-features=optimize_for_size --target $target | |
| " | |
| done | |
| mv .cargo/config.toml .cargo/redox.toml | |
| mv .cargo/config.toml.bak .cargo/config.toml | |
| if [ ! -d /home/runner/openwrt ]; then | |
| mkdir -p /home/runner/openwrt | |
| curl -LsSf https://downloads.openwrt.org/releases/25.12.0/targets/octeon/generic/openwrt-toolchain-25.12.0-octeon-generic_gcc-14.3.0_musl.Linux-x86_64.tar.zst | tar --zstd -xf - -C /home/runner/openwrt | |
| fi | |
| ln -sf /home/runner/openwrt/openwrt-toolchain-25.12.0-octeon-generic_gcc-14.3.0_musl.Linux-x86_64/toolchain-mips64_octeonplus_64_gcc-14.3.0_musl wrt | |
| targets=( | |
| mips64-openwrt-linux-musl | |
| aarch64-unknown-linux-ohos | |
| armv7-unknown-linux-ohos | |
| x86_64-unknown-linux-ohos | |
| riscv64-linux-android | |
| aarch64-linux-android | |
| armv7-linux-androideabi | |
| thumbv7neon-linux-androideabi | |
| x86_64-linux-android | |
| powerpc64-unknown-linux-gnu | |
| ./powerpc64-unknown-linux-musl-elfv1.json | |
| x86_64-unknown-hurd-gnu | |
| ) | |
| for target in ${targets[@]}; do | |
| time cargo s $target | |
| done | |
| find ./target -iname img -type f | xargs ls -hl | |
| lscpu | |
| free -m | |
| - name: Rust Versions | |
| run: rustup -V; cargo -Vv; rustc -Vv | |
| - uses: actions/upload-artifact@v7 | |
| with: | |
| name: build-output | |
| path: | | |
| target/**/img* | |
| !target/**/*.d | |
| if-no-files-found: ignore | |
| - name: Upload binaries to a GitHub release | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| targets=( | |
| riscv64-linux-android | |
| aarch64-linux-android | |
| armv7-linux-androideabi | |
| thumbv7neon-linux-androideabi | |
| x86_64-linux-android | |
| powerpc64-unknown-linux-gnu | |
| powerpc64-unknown-linux-musl-elfv1 | |
| aarch64-unknown-linux-ohos | |
| armv7-unknown-linux-ohos | |
| x86_64-unknown-linux-ohos | |
| mips64-openwrt-linux-musl | |
| x86_64-unknown-hurd-gnu | |
| x86_64-unknown-redox | |
| aarch64-unknown-redox | |
| riscv64gc-unknown-redox | |
| ) | |
| for target in "${targets[@]}"; do | |
| IFS='-' read -r arch vendor os abi rest <<< "$target" | |
| if [[ -n "$abi" ]]; then | |
| if [[ "$vendor" == "openwrt" ]]; then | |
| name="${vendor^}-${arch}-${abi}" | |
| else | |
| if [[ "$abi" == "ohos" ]]; then | |
| name="Android-${arch}-${abi}" | |
| else | |
| name="${os^}-${arch}-${abi}" | |
| fi | |
| fi | |
| else | |
| if [[ "$os" == "androideabi" ]]; then | |
| name="Android-${arch}" | |
| else | |
| name="${os^}-${arch}" | |
| fi | |
| fi | |
| echo "Uploading $name..." | |
| for d in src redox; do | |
| if [ -d "target/$target/$d" ]; then | |
| mv target/$target/$d/img target/$target/$d/$name || true | |
| gh release upload Nightly target/$target/$d/$name --clobber || true | |
| break | |
| fi | |
| done | |
| done |