name: Build Rust on: workflow_call: jobs: windows-bins: runs-on: windows-latest env: RUSTFLAGS: -C target-feature=+crt-static steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Setup Job Environment uses: ./.github/actions/job-setup with: rust-cache: true - name: Install Dependencies run: | rustup component add rust-src --toolchain nightly-x86_64-pc-windows-msvc - name: Build Rust Binaries run: cargo +nightly build --target i686-win7-windows-msvc --features windows --release -Z build-std="core,alloc,std,panic_abort" -p velopack_bins - name: Upload Rust Build Artifacts uses: actions/upload-artifact@v4 with: name: rust-windows-bins path: | target\i686-win7-windows-msvc\release\*.exe target\i686-win7-windows-msvc\release\*.pdb retention-days: 1 windows: runs-on: windows-latest strategy: fail-fast: false matrix: target: [x86, x64, arm64] include: - target: x86 rust_flags: --release -Z build-std="core,alloc,std,panic_abort" rust_target: i686-win7-windows-msvc - target: x64 rust_flags: --release -Z build-std="core,alloc,std,panic_abort" rust_target: x86_64-win7-windows-msvc - target: arm64 rust_flags: --release rust_target: aarch64-pc-windows-msvc env: RUSTFLAGS: -C target-feature=+crt-static steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Setup Job Environment uses: ./.github/actions/job-setup with: rust-cache: true - name: Install Dependencies run: | rustup component add rust-src --toolchain nightly-x86_64-pc-windows-msvc rustup target add aarch64-pc-windows-msvc --toolchain nightly-x86_64-pc-windows-msvc - name: Build Rust (${{ matrix.target }}) run: | cargo +nightly build --target ${{ matrix.rust_target }} ${{ matrix.rust_flags }} -p velopack_nodeffi -p velopack_libc move target\${{ matrix.rust_target }}\release\velopack_nodeffi.dll target\velopack_nodeffi_win_${{ matrix.target }}_msvc.node move target\${{ matrix.rust_target }}\release\velopack_libc.dll target\velopack_libc_win_${{ matrix.target }}_msvc.dll move target\${{ matrix.rust_target }}\release\velopack_libc.dll.lib target\velopack_libc_win_${{ matrix.target }}_msvc.dll.lib move target\${{ matrix.rust_target }}\release\velopack_libc.lib target\velopack_libc_win_${{ matrix.target }}_msvc.lib - name: Upload Rust Build Artifacts uses: actions/upload-artifact@v4 with: name: rust-windows-libs-${{ matrix.target }} path: | target\*.node target\*.dll target\*.lib retention-days: 1 - name: Cancel workflow if failed uses: andymckay/cancel-action@0.5 if: ${{ failure() }} linux-bins: strategy: fail-fast: false matrix: target: [x64, arm64] include: - target: x64 rust_target: x86_64-unknown-linux-musl - target: arm64 rust_target: aarch64-unknown-linux-musl runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Setup Job Environment uses: ./.github/actions/job-setup - name: Install Dependencies run: | curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash cargo binstall cross mkdir ./artifacts - name: Build Rust Binaries (${{ matrix.target }}) run: | cross build --release --target ${{ matrix.rust_target }} -p velopack_bins ldd ./target/${{ matrix.rust_target }}/release/update || true cp ./target/${{ matrix.rust_target }}/release/update ./artifacts/UpdateNix_${{ matrix.target }} - name: Upload Rust Build Artifacts uses: actions/upload-artifact@v4 with: name: rust-ubuntu-bins-${{ matrix.target }} path: | artifacts/UpdateNix_${{ matrix.target }} retention-days: 1 # - name: Cancel workflow if failed # uses: andymckay/cancel-action@0.5 # if: ${{ failure() }} linux: strategy: fail-fast: false matrix: target: [x64, arm64] include: - target: x64 rust_target: x86_64-unknown-linux-gnu - target: arm64 rust_target: aarch64-unknown-linux-gnu runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Setup Job Environment uses: ./.github/actions/job-setup - name: Install Dependencies run: | rustup target add aarch64-unknown-linux-gnu sudo apt update sudo apt install -y g++-aarch64-linux-gnu gcc-aarch64-linux-gnu mkdir ./artifacts - name: Build Rust (${{ matrix.target }}) env: CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc run: | cargo build --release --target ${{ matrix.rust_target }} -p velopack_nodeffi -p velopack_libc cp ./target/${{ matrix.rust_target }}/release/libvelopack_nodeffi.so ./artifacts/velopack_nodeffi_linux_${{ matrix.target }}_gnu.node cp ./target/${{ matrix.rust_target }}/release/libvelopack_libc.so ./artifacts/velopack_libc_linux_${{ matrix.target }}_gnu.so cp ./target/${{ matrix.rust_target }}/release/libvelopack_libc.a ./artifacts/velopack_libc_linux_${{ matrix.target }}_gnu.a - name: Upload Rust Build Artifacts uses: actions/upload-artifact@v4 with: name: rust-ubuntu-libs-${{ matrix.target }} path: | artifacts/*.so artifacts/*.node artifacts/*.a retention-days: 1 # - name: Cancel workflow if failed # uses: andymckay/cancel-action@0.5 # if: ${{ failure() }} macos: runs-on: macos-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Setup Job Environment uses: ./.github/actions/job-setup with: rust-cache: true - name: Install Dependencies run: | rustup target add x86_64-apple-darwin - name: Build Rust (x64) run: | cargo build --release --target x86_64-apple-darwin otool -L ./target/x86_64-apple-darwin/release/update - name: Build Rust (arm64) run: | cargo build --release --target aarch64-apple-darwin otool -L ./target/aarch64-apple-darwin/release/update - name: Create Universal Binary run: | lipo -create -output ./target/UpdateMac ./target/x86_64-apple-darwin/release/update ./target/aarch64-apple-darwin/release/update file ./target/UpdateMac lipo -create -output ./target/velopack_nodeffi_osx.node ./target/x86_64-apple-darwin/release/libvelopack_nodeffi.dylib ./target/aarch64-apple-darwin/release/libvelopack_nodeffi.dylib file ./target/velopack_nodeffi_osx.node lipo -create -output ./target/velopack_libc_osx.dylib ./target/x86_64-apple-darwin/release/libvelopack_libc.dylib ./target/aarch64-apple-darwin/release/libvelopack_libc.dylib file ./target/velopack_libc_osx.dylib cp ./target/x86_64-apple-darwin/release/libvelopack_libc.a ./target/velopack_libc_osx_x64_gnu.a cp ./target/aarch64-apple-darwin/release/libvelopack_libc.a ./target/velopack_libc_osx_arm64_gnu.a - name: Upload Rust Build Artifacts uses: actions/upload-artifact@v4 with: name: rust-macos path: | target/UpdateMac target/*.dylib target/*.node target/*.a retention-days: 1 - name: Cancel workflow if failed uses: andymckay/cancel-action@0.5 if: ${{ failure() }}