Initial commit
This commit is contained in:
77
action.yml
Normal file
77
action.yml
Normal file
@@ -0,0 +1,77 @@
|
||||
name: "Build Rust Projects with Cross"
|
||||
author: "Dave Rolsky <autarch@urth.org>"
|
||||
branding:
|
||||
icon: home
|
||||
color: gray-dark
|
||||
description: |
|
||||
This action lets you easily install and use cross
|
||||
(https://github.com/cross-rs/cross) to compile your Rust projects. It will
|
||||
compile with cargo if the host and target platforms allow, so it's a drop-in
|
||||
replacement for running `cargo build` in your Actions.
|
||||
inputs:
|
||||
target:
|
||||
description: The target platform
|
||||
required: true
|
||||
GITHUB_TOKEN:
|
||||
description: |
|
||||
A GitHub token, available in the secrets.GITHUB_TOKEN context variable.
|
||||
default: ${{ github.token }}
|
||||
args:
|
||||
description: |
|
||||
The arguments to be passed to cross or cargo when building, as a
|
||||
space-separated string.
|
||||
default: ""
|
||||
strip:
|
||||
description: Strip the compiled binary
|
||||
default: false
|
||||
runs:
|
||||
using: composite
|
||||
steps:
|
||||
- name: Add this action's path to PATH
|
||||
shell: bash
|
||||
run: echo "${{ github.action_path }}" >> $GITHUB_PATH
|
||||
- name: Determine whether we need to cross-compile
|
||||
id: determine-cross-compile
|
||||
shell: bash
|
||||
run: set-cross-compile.sh ${{ inputs.target }}
|
||||
- name: Install toolchain if not cross-compiling
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
with:
|
||||
targets: ${{ matrix.platform.target }}
|
||||
if: ${{ steps.determine-cross-compile.outputs.needs-cross == 'false' }}
|
||||
- name: Install cross if cross-compiling (*nix)
|
||||
shell: bash
|
||||
run: install-cross-nix.sh
|
||||
if: ${{ steps.determine-cross-compile.outputs.needs-cross == 'true' && runner.os != 'Windows' }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
|
||||
- name: Install cross if cross-compiling (Windows)
|
||||
shell: powershell
|
||||
run: install-cross-windows.ps1
|
||||
if: ${{ steps.determine-cross-compile.outputs.needs-cross == 'true' && runner.os == 'Windows' }}
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
|
||||
- name: Set build command
|
||||
id: set-build-command
|
||||
shell: bash
|
||||
run: set-build-command.sh
|
||||
- name: Build binary (*nix)
|
||||
shell: bash
|
||||
run: |
|
||||
${{ steps.set-build-command.outputs.build-command }} build ${{ inputs.args }} --target ${{ inputs.target }}
|
||||
if: ${{ runner.os != 'Windows' }}
|
||||
# We want to run in Powershell on Windows to make sure we compile in a
|
||||
# native Windows environment. Some things won't compile properly under
|
||||
# msys, notably OpenSSL, which is compiled locally when using the
|
||||
# `openssl` crate with the `vendored` feature.
|
||||
- name: Build binary (Windows)
|
||||
shell: powershell
|
||||
run: |
|
||||
& ${{ steps.set-build-command.outputs.build-command }} build ${{ inputs.args }} --target ${{ inputs.target }}
|
||||
if: ${{ runner.os == 'Windows' }}
|
||||
- name: Strip binary
|
||||
shell: bash
|
||||
run: |
|
||||
strip target/${{ matrix.platform.target }}/release/${{ matrix.platform.bin }}
|
||||
# strip doesn't work with cross-arch binaries on Linux or Windows.
|
||||
if: ${{ inputs.strip == 'true' && steps.determine-cross-compile.outputs.needs-cross == 'false' && inputs.target != 'aarch64-pc-windows-msvc' }}
|
||||
Reference in New Issue
Block a user