Highly customizable and easy to use action that builds and uploads Rust crates for any target.
Most of the times you would want to use this action in combination with asimov-platform/release-action, or something similar.
- Highly customizable (working directory, checkout, upload, etc).
- Support for Windows, Linux, and macOS runners.
- Support for cross-compilation.
- Support for cargo-zigbuild.
- Rust toolchain selection (channel, version, etc).
- Automatically installs MinGW if needed.
- Stripping & compressing.
- And more (see Inputs)!
Important
Please note that the strategy I use to select correct package to build is very naive and
probably will not work if you have a workspace. In that case please use
the package-name
input to specify it instead.
Target | Working | Zigbuild |
---|---|---|
x86_64-unknown-linux-gnu |
✅ | - |
aarch64-unknown-linux-gnu |
✅ | - |
x86_64-apple-darwin |
✅ | ✅ |
aarch64-apple-darwin |
✅ | ✅ |
x86_64-pc-windows-gnu |
✅ | - |
x86_64-pc-windows-msvc |
❌ | - |
Target | Working | Zigbuild |
---|---|---|
x86_64-apple-darwin |
✅ | - |
aarch64-apple-darwin |
✅ | - |
Target | Working | Zigbuild |
---|---|---|
x86_64-pc-windows-gnu |
✅ | - |
x86_64-pc-windows-msvc |
✅ | - |
aarch64-pc-windows-msvc |
✅ | - |
- uses: asimov-platform/rust-build-action@v1
with:
# Target to build for.
# Required.
target:
# Name of the output artifact. Must be unique.
# Prefixed with artifact-prefix.
# Required.
artifact-name:
# Prefix for the output artifact name.
# Optional. Defaults to package name.
artifact-prefix:
# Name of the package.
# Optional. Defaults to parsed from Cargo.toml.
package-name:
# Extension for the output binary file.
# Optional. Defaults to empty string.
binary-extension:
# Working directory.
# Optional. Defaults to root.
working-directory:
# Checkout repository?
# Optional. Defaults to true.
checkout:
# Rust toolchain to use.
# Optional. Defaults to stable.
rust-toolchain:
# Use cargo-zigbuild?
# Optional. Defaults to false.
use-zigbuild:
# Extra arguments to pass to cargo build.
# Optional. Defaults to empty string.
extra-build-arguments:
# Strip symbols?
# Optional. Defaults to false.
strip-artifact:
# Compress artifact?
# Optional. Defaults to true.
compress-artifact:
# Upload artifact?
# Optional. Defaults to true.
upload-artifact:
Name | Description | Example |
---|---|---|
artifact-path |
Path to the output artifact. | output/my-crate-windows-x64.zip |
artifact-id |
GitHub ID of an Artifact, can be used by the REST API. | 1234 |
artifact-url |
URL to download an Artifact. Can be used in many scenarios such as linking to artifacts in issues or pull requests. Users must be logged-in in order for this URL to work. This URL is valid as long as the artifact has not expired or the artifact, run or repository have not been deleted | https://github.com/example-org/example-repo/actions/runs/1/artifacts/1234 |
steps:
- uses: AsimovPlatform/build-rust-action@v1
with:
target: x86_64-unknown-linux-gnu
artifact-name: linux-x64
strip-artifact: true
compress-artifact: true
rust-toolchain: stable
steps:
- uses: AsimovPlatform/build-rust-action@v1
with:
target: aarch64-apple-darwin
artifact-name: macos-arm64
compress-artifact: true
rust-toolchain: 1.81.0
steps:
- uses: AsimovPlatform/build-rust-action@v1
with:
target: x86_64-pc-windows-gnu
artifact-name: windows-x64
binary-extension: .exe
compress-artifact: true
rust-toolchain: nightly
extra-build-arguments: --features foo,bar