fornwall / rust-script

Run Rust files and expressions as scripts without any setup or compilation step.
https://rust-script.org
Apache License 2.0
1.2k stars 41 forks source link

Include built binaries in releases #117

Closed urothis closed 11 months ago

urothis commented 11 months ago

As a user, I would like to be able to download prebuilt binaries attached to each release as an artifact.

Current usage:

on:
  push:
    branches: [ main ]
jobs:
  build:
    runs-on: ubuntu-latest
    env:
        CARGO_TERM_COLOR: always
    steps:
      - uses: actions/checkout@v4
      - run: cargo install rust-script
      - run: |
            cat > script.rs <<'EOF'
            #!/usr/bin/env rust-script
            //! ```cargo
            //! [dependencies]
            //! rand = "0.8.0"
            //! ```

            use rand::prelude::*;

            fn main() {
                let x: u64 = random();
                println!("A random number: {}", x);
            }
            EOF
      - run: chmod +x script.rs
      - run: ./script.rs

Ideally, I would like to replace - run: cargo install rust-script with some bash to grab a specific version rust-script binary.

fornwall commented 11 months ago

Does replacing

      - run: cargo install rust-script

with:

      - run: curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
      - run: cargo binstall --no-confirm rust-script

work ok? It uses cargo binstall to download prebuilt binaries from the GitHub release of this project.

urothis commented 11 months ago

That works much faster, much appreciated @fornwall