Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e35168ee8f | ||
|
|
9e709706e7 | ||
|
|
294bb6a7fe | ||
|
|
99d882779c | ||
|
|
9a3029eecb | ||
|
|
ede19eddfb | ||
|
|
e021eb0bd0 | ||
|
|
2092d69e17 | ||
|
|
d5709df172 |
10
.github/workflows/test.yml
vendored
10
.github/workflows/test.yml
vendored
@@ -243,6 +243,16 @@ jobs:
|
||||
target: ${{ matrix.platform.target }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
if: ${{ matrix.platform.can_test }}
|
||||
- name: Run test command with args
|
||||
uses: ./
|
||||
with:
|
||||
command: test
|
||||
cross-version: ${{ matrix.platform.cross-version }}
|
||||
cache-cross-binary: ${{ matrix.platform.cache-cross-binary }}
|
||||
target: ${{ matrix.platform.target }}
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
args: "-- --ignored"
|
||||
if: ${{ matrix.platform.can_test }}
|
||||
- name: Run build command
|
||||
uses: ./
|
||||
with:
|
||||
|
||||
10
Changes.md
10
Changes.md
@@ -1,3 +1,13 @@
|
||||
## 0.0.16 - 2024-11-17
|
||||
|
||||
- Arguments passed in the `args` parameter are now always last when executing `cargo`. This lets you
|
||||
pass arguments to test binaries like `-- --something`. First reported by @mateocabanal (Mateo
|
||||
Cabanal) as GH #12 and fully fixed by @donatello (Aditya Manthramurthy) in GH #30.
|
||||
|
||||
## 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`
|
||||
|
||||
56
README.md
56
README.md
@@ -3,40 +3,44 @@
|
||||
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:
|
||||
release:
|
||||
name: Release - ${{ matrix.platform.release_for }}
|
||||
name: Release - ${{ matrix.platform.os-name }}
|
||||
strategy:
|
||||
matrix:
|
||||
platform:
|
||||
- release_for: FreeBSD-x86_64
|
||||
os: ubuntu-20.04
|
||||
- os-name: FreeBSD-x86_64
|
||||
runs-on: ubuntu-20.04
|
||||
target: x86_64-unknown-freebsd
|
||||
bin: precious
|
||||
name: precious-FreeBSD-x86_64.tar.gz
|
||||
command: build
|
||||
skip_tests: true
|
||||
|
||||
- release_for: Windows-x86_64
|
||||
os: windows-latest
|
||||
- os-name: Linux-x86_64
|
||||
runs-on: ubuntu-20.04
|
||||
target: x86_64-unknown-linux-musl
|
||||
|
||||
- os-name: Linux-aarch64
|
||||
runs-on: ubuntu-20.04
|
||||
target: aarch64-unknown-linux-musl
|
||||
|
||||
- os-name: Linux-riscv64
|
||||
runs-on: ubuntu-20.04
|
||||
target: riscv64gc-unknown-linux-gnu
|
||||
|
||||
- os-name: Windows-x86_64
|
||||
runs-on: windows-latest
|
||||
target: x86_64-pc-windows-msvc
|
||||
bin: precious.exe
|
||||
name: precious-Windows-x86_64.zip
|
||||
command: both
|
||||
|
||||
- release_for: macOS-x86_64
|
||||
os: macOS-latest
|
||||
- os-name: macOS-x86_64
|
||||
runs-on: 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 }}
|
||||
runs-on: ${{ matrix.platform.runs-on }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
@@ -47,10 +51,18 @@ 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:
|
||||
executable-name: ubi
|
||||
target: ${{ matrix.platform.target }}
|
||||
```
|
||||
|
||||
Note that for Linux or BSD targets, you should always set the `runs-on` key to an x86-64
|
||||
architecture runner. If you want to do native ARM compilation, for example using
|
||||
`ubuntu-latest-arm`, then there's no point in using this action. This action is only tested on
|
||||
Ubuntu x86-64, Windows, and macOS runners.
|
||||
|
||||
## Input Parameters
|
||||
|
||||
This action takes the following parameters:
|
||||
|
||||
24
action.yml
24
action.yml
@@ -62,31 +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: contains(inputs.target, 'musl')
|
||||
if: steps.determine-cross-compile.outputs.needs-cross != 'true' && contains(inputs.target, 'musl')
|
||||
- name: Set build command
|
||||
id: set-build-command
|
||||
shell: bash
|
||||
@@ -95,8 +95,8 @@ runs:
|
||||
working-directory: ${{ inputs.working-directory }}
|
||||
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' }}
|
||||
${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} test --target ${{ inputs.target }} ${{ inputs.args }}
|
||||
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
|
||||
@@ -105,23 +105,23 @@ runs:
|
||||
working-directory: ${{ inputs.working-directory }}
|
||||
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' }}
|
||||
& ${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} test --target ${{ inputs.target }} ${{ inputs.args }}
|
||||
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'
|
||||
|
||||
@@ -8,4 +8,10 @@ mod test {
|
||||
fn test_something() {
|
||||
assert_eq!(1, 1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore]
|
||||
fn test_something_ignored() {
|
||||
assert_eq!(2, 2);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user