houseabsolute / actions-rust-cross

GitHub Action to compile Rust with cross
Apache License 2.0
101 stars 9 forks source link

Pack multiple files #10

Closed jb-alvarado closed 8 months ago

jb-alvarado commented 8 months ago

Hello, is it possible to run multiple commands on one platform and release all results?

At the moment I have this run command:

run: |
    sudo apt update && sudo apt install -y musl-tools musl-dev

    cargo install cargo-deb
    cargo install cargo-generate-rpm

    cargo build --release --target=x86_64-unknown-linux-musl

    cp ./target/x86_64-unknown-linux-musl/release/mybin .
    tar -czvf "release/mybin-${{github.ref_name}}_x86_64-unknown-linux-musl.tar.gz" assets LICENSE README.md mybin

    cargo deb --target=x86_64-unknown-linux-musl -o release/mybin${{github.ref_name}}-1_amd64.deb
    cargo generate-rpm --target=x86_64-unknown-linux-musl -o release/mybin-${{github.ref_name}}-1.x86_64.rpm

But I would like to cross compile that for different platforms.

Full action I have here, which I would like to migrate to your cross compile action to support more architectures.

autarch commented 8 months ago

Hi, @jb-alvarado, I don't know that this action needs to be changed for you to use it. I'm not even sure it would work at all. The way the action works is that it will run cross build or cross test instead of cargo, depending on the target platform. What cross does is run a Docker image containing QEMU to emulate the target architecture.

But I don't think there's any reason you would need to run cargo deb or cargo generate-rpm inside that Docker image. I'm not even sure you can do that. Looking at the cargo-deb docs, it has a section on cross-compilation at https://github.com/kornelski/cargo-deb#cross-compilation. It looks like you can run cross build (which this action will do) and then run cargo deb --target=XXX --no-build. I think you can just do this in a separate step on the ubuntu-latest os. I would imagine cargo generate-rpm should work similarly.

jb-alvarado commented 8 months ago

Thank you @autarch, for your explanations! I will see if I get it to work with your hints