Giter VIP home page Giter VIP logo

actions-rust-cross's Introduction

GitHub Action to Cross Compile Rust Projects

This action lets you easily cross-compile Rust projects using cross.

Here's a simplified example from the test and release workflow for my tool ubi:

jobs:
  release:
    name: Release - ${{ matrix.platform.release_for }}
    strategy:
      matrix:
        platform:
          - os_name: Windows-x86_64
            os: windows-latest
            target: x86_64-pc-windows-msvc
            skip_tests: true
          - os_name: macOS-x86_64
            os: macOS-latest
            target: x86_64-apple-darwin

            # more targets here ...

    runs-on: ${{ matrix.platform.os }}
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Build binary
        uses: houseabsolute/actions-rust-cross@v0
        with:
          command: ${{ matrix.platform.command }}
          target: ${{ matrix.platform.target }}
          args: "--locked --release"
          strip: true
      - name: Publish artifacts and release
        uses: houseabsolute/actions-rust-release@v0
        with:
          binary-name: ubi
          target: ${{ matrix.platform.target }}
        if: matrix.toolchain == 'stable'

Input Parameters

This action takes the following parameters:

Key Type Required? Description
command string (one of build, test, or both) no The command(s) to run. The default is build. Running the test command will fail with *BSD targets and non-x86 Windows.
target string yes The target triple to compile for. This should be one of the targets found by running rustup target list.
working-directory string no The working directory in which to run the cargo or cross commands. Defaults to the current directory (.).
toolchain string (one of stable, beta, or nightly) no The Rust toolchain version to install. The default is stable.
GITHUB_TOKEN string no Defaults to the value of ${{ github.token }}.
args string no A string-separated list of arguments to be passed to cross build, like --release --locked.
strip boolean (true or false) no If this is true, then the resulting binaries will be stripped if possible. This is only possible for binaries which weren't cross-compiled.
cross-version string no This can be used to set the version of cross to use. If specified, it should be a specific cross release tag (like v0.2.3) or a git ref (commit hash, HEAD, etc.). If this is not set then the latest released version will always be used. If this is set to a git ref then the version corresponding to that ref will be installed.

How it Works

Under the hood, this action will compile your binaries with either cargo or cross, depending on the host machine and target. For Linux builds, it will always use cross except for builds targeting an x86 architecture like x86_64 or i686.

On Windows and macOS, it's possible to compile for all supported targets out of the box, so cross will not be used on those platforms.

If it needs to install cross, it will install the latest version by downloading a release using my tool ubi. This is much faster than using cargo to build cross.

When compiling on Windows, it will do so in a Powershell environment, which can matter in some corner cases, like compiling the openssl crate with the vendored feature.

Finally, it will run strip to strip the binaries if the strip parameter is true. This is only possible for builds that are not done via cross. In addition, Windows builds for aarch64 cannot be stripped either.

Caching Rust Compilation Output

You can use the Swatinem/rust-cache action with this one seamlessly, whether or not a specific build target needs cross. There is no special configuration that you need for this. It just works.

actions-rust-cross's People

Contributors

autarch avatar aaronvg avatar hms5232 avatar

Stargazers

 avatar Justin Cichra avatar  avatar J Wong avatar Kyrylo Riabov avatar D. Bohdan avatar Matteo Pietro Dazzi avatar Xinyu Bao avatar Enes Genç avatar David E. Wheeler avatar  avatar Julie avatar Anastasios Andronidis avatar Bo Jeanes avatar Marcos Antonio Lopes avatar Leon Ding avatar Jonathan Kelley avatar Roland Rodriguez avatar jasper avatar Wassim Metallaoui avatar newt :D avatar Juan J. Jimenez-Anca avatar Marcos Lima avatar Melody avatar Shom Bandopadhaya avatar Théo Crevon avatar Matthew Tylee Atkinson avatar Aan avatar Alexander Korolev avatar Michael Henderson avatar Enix Yu avatar Tyler Nickerson avatar Ujjwal Panda avatar Miles Cranmer avatar Windy avatar Micah avatar Leonid Vygovskiy avatar  avatar gandli avatar Turbidsoul avatar Ruslan Mstoi avatar  avatar Sjur N Moshagen avatar Peter M. Stahl avatar Zander Hill avatar SilentE avatar Philippe avatar ./ed1th avatar David Población Criado avatar Sandalots avatar d1onys1us avatar Amr Hassan avatar Nghia avatar Benjamin Kane avatar  avatar Jonathan Chan Kwan Yin avatar Himadri Bhattacharjee avatar josemanuelp avatar Ali Somay avatar  avatar Todd Martin avatar 莯凛 avatar 觉·白 avatar Max Pfeil avatar Dave Kozma avatar Akiomi KAMAKURA avatar  avatar Alexander Gelzer avatar jade avatar  avatar  avatar  avatar Arvid Gerstmann avatar vrashkov avatar Busticated avatar  avatar  avatar realfresh avatar Gustash avatar Michael Seele avatar Hubert Gruszecki avatar Nicholas Young avatar Jose Quintana avatar Yanzai avatar  avatar Josh Fisher avatar Kiran Shila avatar Nick Mazuk avatar Michael Salaverry avatar Sameer Puri avatar Phones avatar sulaimangari avatar Vasco Fernandes avatar Chen Asraf avatar Ringo Hoffmann avatar Andrejs Agejevs avatar Colin Woodbury avatar Glen De Cauwsemaecker avatar  avatar Travis Paul avatar

Watchers

 avatar James Cloos avatar  avatar

actions-rust-cross's Issues

Action overwrites `GITHUB_PATH`, making other installed tools unaccessible

Trying to use this action in my pipeline, and currently, the action overwrites GITHUB_PATH, thus making other installed tools unusable, such as protoc in my case.

 thread 'main' panicked at 'Could not find `protoc` installation and this build crate cannot proceed without
      this knowledge. If `protoc` is installed and this crate had trouble finding
      it, you can set the `PROTOC` environment variable with the specific path to your
      installed `protoc` binary.If you're on debian, try `apt-get install protobuf-compiler` or download it from https://github.com/protocolbuffers/protobuf/releases

https://github.com/houseabsolute/actions-rust-cross/blob/9a602122c2f4df61140216897231df93c0922a22/action.yml#LL29C12-L29C60

Build fails when multiple binaries are specified

I have a Cargo.toml which specifies multiple binaries:

[[bin]]
name = "tcp_client_server"
path = "src/tcp_client_server.rs"

[[bin]]
name = "udp_client"
path = "src/udp_client.rs"

For some reason, strip command fails with error No such file when building for x86_64_unknown_linux-musl, but success without issue for armv7-unknown-linux-musleabihf:

Run strip-binary.sh x86_64-unknown-linux-musl
  strip-binary.sh x86_64-unknown-linux-musl
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    CARGO_INCREMENTAL: 0
    CARGO_TERM_COLOR: always
++ TARGET=x86_64-unknown-linux-musl
++ stripped=
++ for type in debug release
++ '[' -d target/x86_64-unknown-linux-musl/debug ']'
++ '[' -d target/debug ']'
++ for type in debug release
++ '[' -d target/x86_64-unknown-linux-musl/release ']'
++ strip_binary target/x86_64-unknown-linux-musl/release
+++ uname -s
++ [[ Linux =~ Darwin ]]
+++ find target/x86_64-unknown-linux-musl/release -maxdepth 1 -type f -executable
++ EXE='target/x86_64-unknown-linux-musl/release/tcp_client_server
target/x86_64-unknown-linux-musl/release/udp_client'
++ '[' -z 'target/x86_64-unknown-linux-musl/release/tcp_client_server
target/x86_64-unknown-linux-musl/release/udp_client' ']'
++ strip 'target/x86_64-unknown-linux-musl/release/tcp_client_server
target/x86_64-unknown-linux-musl/release/udp_client'
strip: 'target/x86_64-unknown-linux-musl/release/tcp_client_server
target/x86_64-unknown-linux-musl/release/udp_client': No such file        # Says `udp_client` binary does not exist
Error: Process completed with exit code 1.

My ci.yaml file.

jobs:
  build:
    name: ${{ matrix.platform.target_device }} with rust ${{ matrix.toolchain }}
    runs-on: ${{ matrix.platform.os }}
    strategy:
      fail-fast: false
      matrix:
        platform:
          - target_device: Raspberry PI
            os: ubuntu-20.04
            target: armv7-unknown-linux-musleabihf
            suffix: armv7hf
          - target_device: Linux x64
            os: ubuntu-20.04
            target: x86_64-unknown-linux-musl
            suffix: x86_64
        toolchain:
          - stable
    steps:
      - uses: actions/checkout@v3
      - name: Build binary
        uses: houseabsolute/actions-rust-cross@v0
        with:
          command: "build"
          target: ${{ matrix.platform.target }}
          toolchain: ${{ matrix.toolchain }}
          args: "--locked --release --bins"
          strip: true

I have tried to reproduce this issue locally using the command below, but everything goes well (binary exists as it should). Only when running the build via this repo's GitHub action do I encounter any issues.

cross build --target x86_64-unknown-linux-musl --locked --release --bins

Is this a bug or am I doing something wrong?

Binaries not being built?

Build step using houseabsolute/actions-rust-cross@v0 completes successfully, but only empty build deps examples and incremental folders are generated in the working directory

Did the binaries escape somewhere else?

Example run: https://github.com/deltasiege/godot-rapier-3d/actions/runs/9044423295/job/24853052477

EDIT: Running the same command locally as reported in the example run yields the binaries as expected

cross +stable build --locked --release --target i686-unknown-linux-gnu
...
ls target\i686-unknown-linux-gnu\release\

drwxr-xr-x 1 loki 197121       0 May 12 01:22 ./
drwxr-xr-x 1 loki 197121       0 May 12 01:20 ../
-rw-r--r-- 1 loki 197121       0 May 12 01:20 .cargo-lock
drwxr-xr-x 1 loki 197121       0 May 12 01:20 .fingerprint/
drwxr-xr-x 1 loki 197121       0 May 12 01:20 build/
drwxr-xr-x 1 loki 197121       0 May 12 01:22 deps/
drwxr-xr-x 1 loki 197121       0 May 12 01:20 examples/
drwxr-xr-x 1 loki 197121       0 May 12 01:20 incremental/
-rw-r--r-- 1 loki 197121    1155 May 12 01:22 libgodot_rapier_3d.d
-rw-r--r-- 2 loki 197121 9645240 May 12 01:22 libgodot_rapier_3d.so

Workflow:

# https://github.com/marketplace/actions/build-rust-projects-with-cross
# https://github.com/houseabsolute/precious/blob/master/.github/workflows/ci.yml
name: Release binaries

on:
  workflow_dispatch:
  push:
    paths:
      - "addons/godot-rapier-3d/rust/**"
    tags:
      - "[0-9]+.[0-9]+.[0-9]+" # Regex for a version number such as 0.2.1

defaults:
  run:
    working-directory: addons/godot-rapier-3d/rust

jobs:
  release:
    name: Release - ${{ matrix.release_for }}
    runs-on: ${{ matrix.os }}

    strategy:
      matrix:
        include:
          - release_for: linux-x32-gnu
            os: ubuntu-latest
            target: i686-unknown-linux-gnu
            bin: godot_rapier_3d.linux.release.x86_32.so
            archive: linux-gnu-x86_32.tar.gz

          # - release_for: macos-x64-darwin
          #   os: macos-latest
          #   target: x86_64-apple-darwin
          #   bin: godot_rapier_3d.macos.release.framework
          #   archive: macos-darwin-x86_64.tar.gz

          # - release_for: windows-x64-gnu
          #   os: windows-latest
          #   target: x86_64-pc-windows-gnu
          #   bin: godot_rapier_3d.windows.release.x86_64.dll
          #   archive: windows-gnu-x86_64.zip

    steps:
      - uses: actions/checkout@v4
      - name: Rust toolchain
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}
      - name: Determine version
        shell: bash
        run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
      - name: Build binary
        uses: houseabsolute/actions-rust-cross@v0
        with:
          command: build
          target: ${{ matrix.target }}
          args: "--locked --release"
          strip: true
          working-directory: "addons/godot-rapier-3d/rust"
      - name: List target dir
        shell: bash
        run: |
          ls -la ./target/release
          echo ---
          ls -la ./
          echo ---
          ls -la ../
          echo ---
          ls -la ../../
          echo ---
          ls -la ../../../
          echo ---
          ls -la ../../../../
      - name: Package as archive
        shell: bash
        run: |
          cd target/${{ matrix.target }}/release
          if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
            7z a ../../../godot_rapier_3d-${{ env.VERSION }}-${{ matrix.archive }} ${{ matrix.bin }}
          else
            tar czvf ../../../godot_rapier_3d-${{ env.VERSION }}-${{ matrix.archive }} ${{ matrix.bin }}
          fi
          cd -
      - name: Publish release artifacts
        uses: actions/upload-artifact@v4
        with:
          name: godot_rapier_3d-${{ matrix.os_name }}
          path: "godot_rapier_3d-*"
      - name: Release
        uses: softprops/action-gh-release@v2
        with:
          draft: true
          files: "godot_rapier_3d-*"
          body_path: CHANGES.md

Support test and build workflows

Right now this action hard codes running the build subcommand, but cross also supports test. This action should allow that as well.

feature request: DinD

My application has some tests that relies on docker to work.
When I run them on a platform that requires cross, Docker is not accessible.
It would be amazing to have docker support by default, as described in the cross documentation

UBI bootstrap script unable to setup cross-rs

I'm trying to build for apple silicone, with the following action config

build:
    name: Build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - name: Build binary
        uses: houseabsolute/actions-rust-cross@v0
        with:
          command: "build"
          target: aarch64-apple-darwin
          toolchain: nightly
          cross-version: "v0.2.5"
          args: "--locked --release"
          strip: true

I'm getting output

...
bootstrap-ubi.sh: ubi has been installed to ..
| bootstrap-ubi.sh: It looks like . is not in your PATH. You may want to add it to use ubi.
| 
| + ./ubi --project cross-rs/cross --matching musl --in . --tag v0.2.5
| [ubi][ERROR] HTTP status client error (401 Unauthorized) for url (https://api.github.com/repos/cross-rs/cross/releases/tags/v0.2.5)

rustup and interfaction with Swatinem/rust-cache

Hi, I am wondering how to use this properly with Swatinem/rust-cache. The README says

## Caching Rust Compilation Output
You can use the [Swatinem/rust-cache](https://github.com/Swatinem/rust-cache) action with this one
seamlessly, whether or not a specific build target needs `cross`. There is no special configuration
that you need for this. It just works.

However, Swatinem/rust-cache README says

selecting a toolchain either by action or manual rustup calls should happen
before the plugin, as the cache uses the current rustc version as its cache key

https://github.com/Swatinem/rust-cache/blob/9bdad043e88c75890e36ad3bbc8d27f0090dd609/README.md?plain=1#L11-L12

I see that houseabsolute/actions-rust-cross calls dtolnay/rust-toolchain@master, which is a wrapper around rustup

uses: dtolnay/rust-toolchain@master
with:
targets: ${{ inputs.target }}
toolchain: ${{ inputs.toolchain }}

So if you have something like

- uses: Swatinem/rust-cache@v2
- uses: houseabsolute/actions-rust-cross@v0
  with:
    taget: x86_64-unknown-linux-musl

What ends up happening is rustup gets executed before Swatinem/rust-cache

`libunwind` error while building for `aarch64-linux-android` using `ubuntu-latest`

Hello!

I was searching for a good cross github action and I came across this fantastic action and when I try to build for Android, this error comes:

error: linking with 'aarch64-linux-android-gcc' failed: exit status: 1 | = note: LC_ALL="C" PATH="/rust/lib/rustlib/x86_64-unknown-linux-gnu/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/android-ndk/bin:/rust/bin" VSLANG="1033" "aarch64-linux-android-gcc" "/tmp/rustcYQ7k2L/symbols.o" "/target/aarch64-linux-android/release/deps/antinuke_test-f6c56bbb2cca27c4.antinuke_test.17a426cc96f3524d-cgu.0.rcgu.o" "-Wl,--as-needed" "-L" "/target/aarch64-linux-android/release/deps" "-L" "/target/release/deps" "-L" "/target/aarch64-linux-android/release/build/ring-6d28ca657858bd9f/out" "-L" "/rust/lib/rustlib/aarch64-linux-android/lib" "-Wl,-Bstatic" "/tmp/rustcYQ7k2L/libring-cfb44b8cfe867d79.rlib" "/rust/lib/rustlib/aarch64-linux-android/lib/libcompiler_builtins-cc66c9e5764dfbe4.rlib" "-Wl,-Bdynamic" "-ldl" "-llog" "-lunwind" "-ldl" "-lm" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/rust/lib/rustlib/aarch64-linux-android/lib" "-o" "/target/aarch64-linux-android/release/deps/antinuke_test-f6c56bbb2cca27c4" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-Wl,--strip-all" "-nodefaultlibs" = note: /android-ndk/bin/../lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: cannot find -lunwind clang90: error: linker command failed with exit code 1 (use -v to see invocation)

Compiled files didn't work

Hi, thanks to provide such a good Github Action

I googled your blog
and copied ci.yml from here: https://github.com/houseabsolute/ubi/blob/master/.github/workflows/ci.yml
then changed

name: Tests and release
on: [push, pull_request]
env:
  CRATE_NAME: mytest
  GITHUB_TOKEN: ${{ github.token }}
  RUST_BACKTRACE: 1
jobs:
  test:
    name: ${{ matrix.platform.os_name }} with rust ${{ matrix.toolchain }}
    runs-on: ${{ matrix.platform.os }}
    strategy:
      fail-fast: false
      matrix:
        platform:
          - os_name: Linux-x86_64
            os: ubuntu-20.04
            target: x86_64-unknown-linux-musl
            bin: mytest
            name: mytest-Linux-x86_64-musl.tar.gz
          - os_name: Windows-x86_64
            os: windows-latest
            target: x86_64-pc-windows-msvc
            bin: mytest.exe
            name: mytest-Windows-x86_64.zip
        toolchain:
          - stable
    steps:
      - uses: actions/checkout@v3
      - name: Cache cargo & target directories
        uses: Swatinem/rust-cache@v2
        with:
          key: "v2"
      - name: Configure Git
        run: |
          git config --global user.email "[email protected]"
          git config --global user.name "Songday"
      - name: Install musl-tools on Linux
        run: sudo apt-get update --yes && sudo apt-get install --yes musl-tools
        if: contains(matrix.platform.name, 'musl')
      - name: Install build-essential on Linux
        run: sudo apt-get install --yes build-essential
        if: contains(matrix.platform.name, 'musl')
      - name: Link g++
        run: sudo ln -s /bin/g++ /bin/musl-g++
        if: contains(matrix.platform.name, 'musl')
      - name: Build binary
        uses: houseabsolute/actions-rust-cross@v0
        with:
          command: "build"
          target: ${{ matrix.platform.target }}
          toolchain: ${{ matrix.toolchain }}
          args: "--release"
          strip: false
      - name: Run tests
        uses: houseabsolute/actions-rust-cross@v0
        with:
          command: "test"
          target: ${{ matrix.platform.target }}
          toolchain: ${{ matrix.toolchain }}
          args: "--release"
        if: ${{ !matrix.platform.skip_tests }}
      - name: Package as archive
        shell: bash
        run: |
          cd target/${{ matrix.platform.target }}/release
          if [[ "${{ matrix.platform.os }}" == "windows-latest" ]]; then
            7z a ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }}
          else
            tar czvf ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }}
          fi
          cd -
        if: matrix.toolchain == 'stable'
      - name: Publish release artifacts
        uses: actions/upload-artifact@v3
        with:
          name: mytest-${{ matrix.platform.os_name }}
          path: "mytest-*"
        if: matrix.toolchain == 'stable'
      - name: Generate SHA-256
        run: shasum -a 256 ${{ matrix.platform.name }}
        if: |
          matrix.toolchain == 'stable' &&
          matrix.platform.os == 'macOS-latest' &&
          ( startsWith( github.ref, 'refs/tags/v' ) ||
            github.ref == 'refs/tags/test-release' )
      - name: Publish GitHub release
        uses: softprops/action-gh-release@v1
        with:
          draft: true
          files: "mytest*"
          body_path: Changes.md
        if: matrix.toolchain == 'stable' && startsWith( github.ref, 'refs/tags/v' )

But this action compiled Windows binary didn't work on my laptop (exited without any output)
Linux binary didn't work either, when I ran it in console, it exited immediately with a output: Illegal instruction (Core dumped) (I didn't find the dump file
then I compiled one on my own, that worked
(same ructc version and toolchain)

My laptop:

  1. OS is Windows10 HomeEdition
  2. rustc version is 1.71.0
  3. toolchain is: stable-x86_64-pc-windows-msvc

I found file size of these two was different
Github Action created file: 4,480,512 bytes
My laptop created file: 4,401,152 bytes (a bit smaller)

Action fails due to "missing file"

Action log can be seen here: https://github.com/makspll/bevy_mod_scripting/actions/runs/8552685284/job/23434311319?pr=67

the relevant error is:

 error: failed to load manifest for workspace member `/project/crates/bevy_script_api`
Caused by:
  failed to load manifest for dependency `bevy_mod_scripting_lua_derive`
Caused by:
  failed to load manifest for dependency `bevy_mod_scripting`
Caused by:
  failed to read `/bevy_mod_scripting/Cargo.toml`
Caused by:
  No such file or directory (os error 2)
Error: Process completed with exit code 101.

And the workflow looks like this:

jobs:
  check:
    name: Check
    runs-on: ${{ matrix.run_args.os }}
    strategy:
      matrix:
       run_args: [ 
        {os: windows-latest,      lua: lua54,     cross: null}, 
        {os: macOS-latest,        lua: lua54,     cross: null},
        {os: ubuntu-latest,       lua: lua54,     cross: aarch64-unknown-linux-gnu},
        {os: ubuntu-latest,       lua: lua51,     cross: null}, 
        {os: ubuntu-latest,       lua: lua52,     cross: null}, 
        {os: ubuntu-latest,       lua: lua53,     cross: null}, 
        {os: ubuntu-latest,       lua: lua54,     cross: null}, 
        {os: ubuntu-latest,       lua: luajit,    cross: null}, 
        {os: ubuntu-latest,       lua: luajit52,  cross: null}
      ]
    steps:
      - name: Install alsa and udev
        run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev
        if: runner.os == 'linux'
      - uses: actions/checkout@v2
      - uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable
          override: true
      - name: Rust Cache
        uses: Swatinem/[email protected]
      # for x86 builds
      - if: matrix.run_args.cross == null
        uses: actions-rs/cargo@v1
        with:
          command: check
          args: --workspace --features=${{ matrix.run_args.lua }},rhai,teal,lua_script_api,rhai_script_api,rune
      # for non x86 cross-compiled builds
      - if: matrix.run_args.cross != null
        name: Clear space
        run: sudo rm -rf /usr/share/dotnet; sudo rm -rf /opt/ghc; sudo rm -rf "/usr/local/share/boost"; sudo rm -rf "$AGENT_TOOLSDIRECTORY"
      - if: matrix.run_args.cross != null
        uses: houseabsolute/actions-rust-cross@v0
        with:
          command: check
          target: ${{ matrix.run_args.cross }}
          args: --workspace --features=${{ matrix.run_args.lua }},rhai,teal,lua_script_api,rhai_script_api,rune --profile=ephemeral-build

feature request: install missing musl deps

If I try to use a musl target like aarch64-unknown-linux-musl, the step breaks because no musl deps are not installed.
I expect them to be installed by this action, to have an easier integration

Openssl cross compilation not working

I can't seem to figure out the problem:

error: failed to run custom build command for `openssl-sys v0.9.86`
[366](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:382)

[367](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:383)
Caused by:
[368](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:384)
  process didn't exit successfully: `/home/runner/work/oci-tester/oci-tester/target/release/build/openssl-sys-fb313cace2c4dd0e/build-script-main` (exit status: 101)
[369](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:385)
  --- stdout
[370](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:386)
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_LIB_DIR
[371](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:387)
  X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_LIB_DIR unset
[372](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:388)
  cargo:rerun-if-env-changed=OPENSSL_LIB_DIR
[373](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:389)
  OPENSSL_LIB_DIR unset
[374](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:390)
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_INCLUDE_DIR
[375](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:391)
  X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_INCLUDE_DIR unset
[376](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:392)
  cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR
[377](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:393)
  OPENSSL_INCLUDE_DIR unset
[378](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:394)
  cargo:rerun-if-env-changed=X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR
[379](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:395)
  X86_64_UNKNOWN_LINUX_MUSL_OPENSSL_DIR unset
[380](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:396)
  cargo:rerun-if-env-changed=OPENSSL_DIR
[381](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:397)
  OPENSSL_DIR unset
[382](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:398)
  cargo:rerun-if-env-changed=OPENSSL_NO_PKG_CONFIG
[383](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:399)
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_x86_64-unknown-linux-musl
[384](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:400)
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_x86_64_unknown_linux_musl
[385](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:401)
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_ALLOW_CROSS
[386](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:402)
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS
[387](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:403)
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-musl
[388](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:404)
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_musl
[389](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:405)
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG
[390](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:406)
  cargo:rerun-if-env-changed=PKG_CONFIG
[391](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:407)
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-musl
[392](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:408)
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_musl
[393](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:409)
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
[394](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:410)
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
[395](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:411)
  run pkg_config fail: pkg-config has not been configured to support cross-compilation.
[396](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:412)

[397](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:413)
  Install a sysroot for the target platform and configure it via
[398](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:414)
  PKG_CONFIG_SYSROOT_DIR and PKG_CONFIG_PATH, or install a
[399](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:415)
  cross-compiling wrapper for pkg-config and set it via
[400](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:416)
  PKG_CONFIG environment variable.
[401](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:417)

[402](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:418)
  --- stderr
[403](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:419)
  thread 'main' panicked at '
[404](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:420)

[405](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:421)
  Could not find directory of OpenSSL installation, and this `-sys` crate cannot
[406](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:422)
  proceed without this knowledge. If OpenSSL is installed and this crate had
[407](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:423)
  trouble finding it,  you can set the `OPENSSL_DIR` environment variable for the
[408](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:424)
  compilation process.
[409](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:425)

[410](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:426)
  Make sure you also have the development packages of openssl installed.
[411](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:427)
  For example, `libssl-dev` on Ubuntu or `openssl-devel` on Fedora.
[412](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:428)

[413](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:429)
  If you're in a situation where you think the directory *should* be found
[414](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:430)
  automatically, please open a bug at https://github.com/sfackler/rust-openssl
[415](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:431)
  and include information about your system as well as this message.
[416](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:432)

[417](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:433)
  $HOST = x86_64-unknown-linux-gnu
[418](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:434)
  $TARGET = x86_64-unknown-linux-musl
[419](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:435)
  openssl-sys = 0.9.86
[420](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:436)

[421](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:437)
  ', /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/openssl-sys-0.9.86/build/find_normal.rs:190:5
[422](https://github.com/lswith/oci-tester/actions/runs/4783838997/jobs/8504576386#step:4:438)
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

It seems like I need to set the PKG_CONFIG and the OPENSSL_DIR, but they are already there. Any ideas?

Pack multiple files

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.

Force use of cross instead of cargo?

Is there an option to make it always use cross?

I am trying to compile to x86_64_unknown_linux_musl but my build fails because it is missing the musl-gcc and some other libs necessary to cross-compile with MUSL.

Matrix options must only contain primitive values

https://github.com/passwa11/Certificate-Transparency-Monitor---Rust

name: Rust

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

env:
  CARGO_TERM_COLOR: always
  CRATE_NAME: passwa11
  GITHUB_TOKEN: ${{ github.token }}
  RUST_BACKTRACE: 1

jobs:
  test:
    name: ${{ matrix.platform.os_name }} with rust ${{ matrix.toolchain }}
    runs-on: ${{ matrix.platform.os }}
    strategy:
      fail-fast: false
      matrix:
        platform:
          - os_name: FreeBSD-x86_64
            os: ubuntu-20.04
            target: x86_64-unknown-freebsd
            bin: Certificate-Transparency-Monitor
            name: Certificate-Transparency-Monitor-FreeBSD-x86_64.tar.gz
            skip_tests: true
          - os_name: Linux-x86_64
            os: ubuntu-20.04
            target: x86_64-unknown-linux-musl
            bin: Certificate-Transparency-Monitor
            name: Certificate-Transparency-Monitor-Linux-x86_64-musl.tar.gz
          - os_name: Linux-aarch64
            os: ubuntu-20.04
            target: aarch64-unknown-linux-musl
            bin: Certificate-Transparency-Monitor
            name: Certificate-Transparency-Monitor-Linux-aarch64-musl.tar.gz
          - os_name: Linux-arm
            os: ubuntu-20.04
            target: arm-unknown-linux-musleabi
            bin: Certificate-Transparency-Monitor
            name: Certificate-Transparency-Monitor-Linux-arm-musl.tar.gz
          - os_name: Linux-i686
            os: ubuntu-20.04
            target: i686-unknown-linux-musl
            bin: Certificate-Transparency-Monitor
            name: Certificate-Transparency-Monitor-Linux-i686-musl.tar.gz
            skip_tests: true
          - os_name: Linux-powerpc
            os: ubuntu-20.04
            target: powerpc-unknown-linux-gnu
            bin: Certificate-Transparency-Monitor
            name: Certificate-Transparency-Monitor-Linux-powerpc-gnu.tar.gz
            skip_tests: true
          - os_name: Linux-powerpc64
            os: ubuntu-20.04
            target: powerpc64-unknown-linux-gnu
            bin: Certificate-Transparency-Monitor
            name: Certificate-Transparency-Monitor-Linux-powerpc64-gnu.tar.gz
            skip_tests: true
          - os_name: Linux-powerpc64le
            os: ubuntu-20.04
            target: powerpc64le-unknown-linux-gnu
            bin: Certificate-Transparency-Monitor
            name: Certificate-Transparency-Monitor-Linux-powerpc64le.tar.gz
            skip_tests: true
          - os_name: Linux-riscv64
            os: ubuntu-20.04
            target: riscv64gc-unknown-linux-gnu
            bin: Certificate-Transparency-Monitor
            name: Certificate-Transparency-Monitor-Linux-riscv64gc-gnu.tar.gz
          - os_name: Linux-s390x
            os: ubuntu-20.04
            target: s390x-unknown-linux-gnu
            bin: Certificate-Transparency-Monitor
            name: Certificate-Transparency-Monitor-Linux-s390x-gnu.tar.gz
            skip_tests: true
          - os_name: NetBSD-x86_64
            os: ubuntu-20.04
            target: x86_64-unknown-netbsd
            bin: Certificate-Transparency-Monitor
            name: Certificate-Transparency-Monitor-NetBSD-x86_64.tar.gz
            skip_tests: true
          - os_name: Windows-aarch64
            os: windows-latest
            target: aarch64-pc-windows-msvc
            bin: Certificate-Transparency-Monitor.exe
            name: Certificate-Transparency-Monitor-Windows-aarch64.zip
            skip_tests: true
          - os_name: Windows-i686
            os: windows-latest
            target: i686-pc-windows-msvc
            bin: Certificate-Transparency-Monitor.exe
            name: Certificate-Transparency-Monitor-Windows-i686.zip
            skip_tests: true
          - os_name: Windows-x86_64
            os: windows-latest
            target: x86_64-pc-windows-msvc
            bin: Certificate-Transparency-Monitor.exe
            name: Certificate-Transparency-Monitor-Windows-x86_64.zip
          - os_name: macOS-x86_64
            os: macOS-latest
            target: x86_64-apple-darwin
            bin: Certificate-Transparency-Monitor
            name: Certificate-Transparency-Monitor-Darwin-x86_64.tar.gz
          - os_name: macOS-aarch64
            os: macOS-latest
            target: aarch64-apple-darwin
            bin: Certificate-Transparency-Monitor
            name: Certificate-Transparency-Monitor-Darwin-aarch64.tar.gz
            skip_tests: true
        toolchain:
          - stable
          - beta
          - nightly
    steps:
      - uses: actions/checkout@v4
      - name: Cache cargo & target directories
        uses: Swatinem/rust-cache@v2
      - name: Configure Git
        run: |
          git config --global user.email "[email protected]"
          git config --global user.name "J. Doe"
      - name: Install musl-tools on Linux
        run: sudo apt-get update --yes && sudo apt-get install --yes musl-tools
        if: contains(matrix.platform.name, 'musl')
      - name: Build binary
        uses: houseabsolute/actions-rust-cross@v0
        with:
          command: "build"
          target: ${{ matrix.platform.target }}
          toolchain: ${{ matrix.toolchain }}
          args: "--locked --release"
          strip: true
      - name: Run tests
        uses: houseabsolute/actions-rust-cross@v0
        with:
          command: "test"
          target: ${{ matrix.platform.target }}
          toolchain: ${{ matrix.toolchain }}
          args: "--locked --release"
        if: ${{ !matrix.platform.skip_tests }}
      - name: Package as archive
        shell: bash
        run: |
          cd target/${{ matrix.platform.target }}/release
          if [[ "${{ matrix.platform.os }}" == "windows-latest" ]]; then
            7z a ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }}
          else
            tar czvf ../../../${{ matrix.platform.name }} ${{ matrix.platform.bin }}
          fi
          cd -
        if: |
          matrix.toolchain == 'stable' &&
          ( startsWith( github.ref, 'refs/tags/v' ) ||
            github.ref == 'refs/tags/test-release' )
      - name: Publish release artifacts
        uses: actions/upload-artifact@v4
        with:
          name: Certificate-Transparency-Monitor-${{ matrix.platform.os_name }}
          path: "Certificate-Transparency-Monitor-*"
        if: matrix.toolchain == 'stable' && github.ref == 'refs/tags/test-release'
      - name: Generate SHA-256
        run: shasum -a 256 ${{ matrix.platform.name }}
        if: |
          matrix.toolchain == 'stable' &&
          matrix.platform.os == 'macOS-latest' &&
          ( startsWith( github.ref, 'refs/tags/v' ) ||
            github.ref == 'refs/tags/test-release' )
      - name: Publish GitHub release
        uses: softprops/action-gh-release@v2
        with:
          draft: true
          files: "Certificate-Transparency-Monitor-*"
          # body_path: Changes.md
        if: matrix.toolchain == 'stable' && startsWith( github.ref, 'refs/tags/v' )

error:
Matrix options must only contain primitive values
image

Support caching cross-rs download

Thanks for creating this action, exactly what I needed.

I would like to propose the implementation of the GitHub actions caching mechanism for Rust cross download. This would significantly improve build times by removing the need for redundant downloads across runs.

https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows

I'll try to come up with a solution myself, but I'm probably not knowledgeable enough in GitHub action development.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.