Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e021eb0bd0 | ||
|
|
2092d69e17 | ||
|
|
d5709df172 | ||
|
|
ad283b2fc6 | ||
|
|
52a0827e28 | ||
|
|
e4e3cc18ae |
10
Changes.md
10
Changes.md
@@ -1,3 +1,13 @@
|
||||
## 0.0.15 - 2024-09-21
|
||||
|
||||
- The `musl` packages are only installed when not cross-compiling.
|
||||
|
||||
## 0.0.14 - 2024-08-25
|
||||
|
||||
- When the given `target` includes the string `musl`, this action will install the `musl-tools`
|
||||
package. This allows crates with C or C++ code to compile properly. Fixes #20. Reported by Matteo
|
||||
Pietro Dazzi (@ilteoood).
|
||||
|
||||
## 0.0.13 - 2024-05-18
|
||||
|
||||
- It's now possible to set `cross-version` to a git ref like a commit hash or `HEAD`. This will
|
||||
|
||||
35
README.md
35
README.md
@@ -3,8 +3,8 @@
|
||||
This action lets you easily cross-compile Rust projects using
|
||||
[cross](https://github.com/cross-rs/cross).
|
||||
|
||||
Here's an example from the release workflow for
|
||||
[my tool `precious`](https://github.com/houseabsolute/precious):
|
||||
Here's a simplified example from the test and release workflow for
|
||||
[my tool `ubi`](https://github.com/houseabsolute/ubi):
|
||||
|
||||
```yaml
|
||||
jobs:
|
||||
@@ -13,28 +13,15 @@ jobs:
|
||||
strategy:
|
||||
matrix:
|
||||
platform:
|
||||
- release_for: FreeBSD-x86_64
|
||||
os: ubuntu-20.04
|
||||
target: x86_64-unknown-freebsd
|
||||
bin: precious
|
||||
name: precious-FreeBSD-x86_64.tar.gz
|
||||
command: build
|
||||
|
||||
- release_for: Windows-x86_64
|
||||
- os_name: Windows-x86_64
|
||||
os: windows-latest
|
||||
target: x86_64-pc-windows-msvc
|
||||
bin: precious.exe
|
||||
name: precious-Windows-x86_64.zip
|
||||
command: both
|
||||
|
||||
- release_for: macOS-x86_64
|
||||
skip_tests: true
|
||||
- os_name: macOS-x86_64
|
||||
os: macOS-latest
|
||||
target: x86_64-apple-darwin
|
||||
bin: precious
|
||||
name: precious-Darwin-x86_64.tar.gz
|
||||
command: both
|
||||
|
||||
# more release targets here ...
|
||||
# more targets here ...
|
||||
|
||||
runs-on: ${{ matrix.platform.os }}
|
||||
steps:
|
||||
@@ -47,8 +34,12 @@ jobs:
|
||||
target: ${{ matrix.platform.target }}
|
||||
args: "--locked --release"
|
||||
strip: true
|
||||
|
||||
# more packaging stuff goes here ...
|
||||
- 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
|
||||
@@ -57,7 +48,7 @@ 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, non-x86 Windows, and macOS ARM. |
|
||||
| `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`. |
|
||||
|
||||
22
action.yml
22
action.yml
@@ -62,27 +62,31 @@ runs:
|
||||
run: determine-cross-version.sh "${{ inputs.cross-version }}"
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
|
||||
if: ${{ steps.determine-cross-compile.outputs.needs-cross == 'true' }}
|
||||
if: steps.determine-cross-compile.outputs.needs-cross == 'true'
|
||||
# We need to access this in both this YAML config and shell scripts. It
|
||||
# doesn't seem like using ${{ env.RUNNER_TEMP }} works in the YAML config.
|
||||
- name: Set directory for installing cross
|
||||
id: set-cross-dir
|
||||
shell: bash
|
||||
run: set-cross-dir.sh
|
||||
if: ${{ steps.determine-cross-compile.outputs.needs-cross == 'true' }}
|
||||
if: steps.determine-cross-compile.outputs.needs-cross == 'true'
|
||||
- name: Cache cross
|
||||
id: cache-cross
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ${{ steps.set-cross-dir.outputs.cross-dir }}/cross
|
||||
key: ${{ runner.os }}-${{ steps.determine-cross-version.outputs.cross-version }}
|
||||
if: ${{ steps.determine-cross-compile.outputs.needs-cross == 'true' && inputs.cache-cross-binary == 'true' }}
|
||||
if: steps.determine-cross-compile.outputs.needs-cross == 'true' && inputs.cache-cross-binary == 'true'
|
||||
- name: Install cross if cross-compiling (*nix)
|
||||
shell: bash
|
||||
run: install-cross-nix.sh ${{ steps.set-cross-dir.outputs.cross-dir }} ${{ steps.determine-cross-version.outputs.cross-version }}
|
||||
if: ${{ steps.determine-cross-compile.outputs.needs-cross == 'true' && steps.cache-cross.outputs.cache-hit != 'true' }}
|
||||
if: steps.determine-cross-compile.outputs.needs-cross == 'true' && steps.cache-cross.outputs.cache-hit != 'true'
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ inputs.GITHUB_TOKEN }}
|
||||
- name: Install musl-tools on Linux if target includes "musl"
|
||||
shell: bash
|
||||
run: sudo apt-get update --yes && sudo apt-get install --yes musl-tools
|
||||
if: steps.determine-cross-compile.outputs.needs-cross != 'true' && contains(inputs.target, 'musl')
|
||||
- name: Set build command
|
||||
id: set-build-command
|
||||
shell: bash
|
||||
@@ -92,7 +96,7 @@ runs:
|
||||
shell: bash
|
||||
run: |
|
||||
${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} test ${{ inputs.args }} --target ${{ inputs.target }}
|
||||
if: ${{ inputs.command != 'build' && runner.os != 'Windows' }}
|
||||
if: inputs.command != 'build' && 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
|
||||
@@ -102,22 +106,22 @@ runs:
|
||||
shell: powershell
|
||||
run: |
|
||||
& ${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} test ${{ inputs.args }} --target ${{ inputs.target }}
|
||||
if: ${{ inputs.command != 'build' && runner.os == 'Windows' }}
|
||||
if: inputs.command != 'build' && runner.os == 'Windows'
|
||||
- name: Build binary (*nix)
|
||||
working-directory: ${{ inputs.working-directory }}
|
||||
shell: bash
|
||||
run: |
|
||||
${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} build ${{ inputs.args }} --target ${{ inputs.target }}
|
||||
if: ${{ inputs.command != 'test' && runner.os != 'Windows' }}
|
||||
if: inputs.command != 'test' && runner.os != 'Windows'
|
||||
- name: Build binary (Windows)
|
||||
working-directory: ${{ inputs.working-directory }}
|
||||
shell: powershell
|
||||
run: |
|
||||
& ${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} build ${{ inputs.args }} --target ${{ inputs.target }}
|
||||
if: ${{ inputs.command != 'test' && runner.os == 'Windows' }}
|
||||
if: inputs.command != 'test' && runner.os == 'Windows'
|
||||
- name: Strip binary
|
||||
working-directory: ${{ inputs.working-directory }}
|
||||
shell: bash
|
||||
run: strip-binary.sh ${{ inputs.target }}
|
||||
# strip doesn't work with cross-arch binaries on Linux or Windows.
|
||||
if: ${{ inputs.command != 'test' && inputs.strip == 'true' && steps.determine-cross-compile.outputs.needs-cross == 'false' && inputs.target != 'aarch64-pc-windows-msvc' }}
|
||||
if: inputs.command != 'test' && inputs.strip == 'true' && steps.determine-cross-compile.outputs.needs-cross == 'false' && inputs.target != 'aarch64-pc-windows-msvc'
|
||||
|
||||
Reference in New Issue
Block a user