Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d788e00f15 | ||
|
|
356ca41f7d | ||
|
|
91d78d9182 | ||
|
|
30e7adeceb |
19
Changes.md
19
Changes.md
@@ -1,3 +1,22 @@
|
||||
## 0.0.7 - 2023-04-21
|
||||
|
||||
- The toolchain argument was (probably) not being respected with cross builds,
|
||||
though it's hard to be sure since none of the output from past CI runs I've
|
||||
looked at it includes the toolchain version in the output. But now the
|
||||
toolchain version is explicitly passed to all `cargo` and `cross` commands.
|
||||
|
||||
## 0.0.6 - 2023-04-21
|
||||
|
||||
- When the `strip` parameter was true, stripping binaries could fail if there
|
||||
were both `target/*/debug` and `target/*/release` directories present and
|
||||
the `debug` directory didn't have a binary. Now it will strip all binaries
|
||||
it finds under `target`.
|
||||
|
||||
## 0.0.5 - 2023-03-19
|
||||
|
||||
- Fix use of `dtolnay/rust-toolchain` action to allow passing a `toolchain`
|
||||
input.
|
||||
|
||||
## 0.0.4 - 2023-03-19
|
||||
|
||||
- Added a new `toolchain` parameter to allow selecting a Rust toolchain other
|
||||
|
||||
15
README.md
15
README.md
@@ -55,13 +55,14 @@ jobs:
|
||||
|
||||
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 fails with \*BSD targets, non-x86 Windows, and macOS ARM. |
|
||||
| `target` | string | yes | The target triple to compile for. This should be one of the targets listed by running `rustup target list`. |
|
||||
| `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 binary will be stripped if possible. This is only possible for binaries which weren't cross-compiled. |
|
||||
| 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 fails with \*BSD targets, non-x86 Windows, and macOS ARM. |
|
||||
| `target` | string | yes | The target triple to compile for. This should be one of the targets listed by running `rustup target list`. |
|
||||
| `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 binary will be stripped if possible. This is only possible for binaries which weren't cross-compiled. |
|
||||
|
||||
## How it Works
|
||||
|
||||
|
||||
11
action.yml
11
action.yml
@@ -40,11 +40,10 @@ runs:
|
||||
shell: bash
|
||||
run: set-cross-compile.sh ${{ inputs.target }}
|
||||
- name: Install toolchain if not cross-compiling
|
||||
uses: dtolnay/rust-toolchain@stable
|
||||
uses: dtolnay/rust-toolchain@master
|
||||
with:
|
||||
targets: ${{ inputs.target }}
|
||||
toolchain: ${{ inputs.toolchain }}
|
||||
if: ${{ steps.determine-cross-compile.outputs.needs-cross == 'false' }}
|
||||
- name: Install cross if cross-compiling (*nix)
|
||||
shell: bash
|
||||
run: install-cross-nix.sh
|
||||
@@ -64,7 +63,7 @@ runs:
|
||||
- name: Run tests (*nix)
|
||||
shell: bash
|
||||
run: |
|
||||
${{ steps.set-build-command.outputs.build-command }} test ${{ inputs.args }} --target ${{ inputs.target }}
|
||||
${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} test ${{ inputs.args }} --target ${{ inputs.target }}
|
||||
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
|
||||
@@ -73,17 +72,17 @@ runs:
|
||||
- name: Run tests (Windows)
|
||||
shell: powershell
|
||||
run: |
|
||||
& ${{ steps.set-build-command.outputs.build-command }} test ${{ inputs.args }} --target ${{ inputs.target }}
|
||||
& ${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} test ${{ inputs.args }} --target ${{ inputs.target }}
|
||||
if: ${{ inputs.command != 'build' && runner.os == 'Windows' }}
|
||||
- name: Build binary (*nix)
|
||||
shell: bash
|
||||
run: |
|
||||
${{ steps.set-build-command.outputs.build-command }} build ${{ inputs.args }} --target ${{ inputs.target }}
|
||||
${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} build ${{ inputs.args }} --target ${{ inputs.target }}
|
||||
if: ${{ inputs.command != 'test' && runner.os != 'Windows' }}
|
||||
- name: Build binary (Windows)
|
||||
shell: powershell
|
||||
run: |
|
||||
& ${{ steps.set-build-command.outputs.build-command }} build ${{ inputs.args }} --target ${{ inputs.target }}
|
||||
& ${{ steps.set-build-command.outputs.build-command }} +${{inputs.toolchain}} build ${{ inputs.args }} --target ${{ inputs.target }}
|
||||
if: ${{ inputs.command != 'test' && runner.os == 'Windows' }}
|
||||
- name: Strip binary
|
||||
shell: bash
|
||||
|
||||
@@ -2,32 +2,32 @@ set -e
|
||||
set -x
|
||||
|
||||
TARGET=$1
|
||||
stripped=""
|
||||
|
||||
strip_binary () {
|
||||
if [[ $( uname -s ) =~ "Darwin" ]]; then
|
||||
EXE=$( find "$1" -maxdepth 1 -type f -perm +111 )
|
||||
else
|
||||
EXE=$( find "$1" -maxdepth 1 -type f -executable )
|
||||
fi
|
||||
|
||||
if [ -z "$EXE" ]; then
|
||||
echo "Could not find a binary to strip in $1"
|
||||
else
|
||||
strip "$EXE"
|
||||
stripped="$EXE"
|
||||
fi
|
||||
}
|
||||
|
||||
DIR=""
|
||||
for type in debug release; do
|
||||
if [ -d "target/$TARGET/$type" ]; then
|
||||
DIR="target/$TARGET/$type"
|
||||
break
|
||||
strip_binary "target/$TARGET/$type"
|
||||
elif [ -d "target/$type" ]; then
|
||||
DIR="target/$type"
|
||||
break
|
||||
strip_binary "target/$type"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "$DIR" ]; then
|
||||
echo "Could not find directory with binary in it under target/"
|
||||
if [ -z "$stripped" ]; then
|
||||
echo "No binaries were stripped"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $( uname -s ) =~ "Darwin" ]]; then
|
||||
EXE=$( find "$DIR" -maxdepth 1 -type f -perm +111 )
|
||||
else
|
||||
EXE=$( find "$DIR" -maxdepth 1 -type f -executable )
|
||||
fi
|
||||
|
||||
if [ -z "$EXE" ]; then
|
||||
echo "Could not find a binary to strip in $DIR"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
strip "$EXE"
|
||||
|
||||
Reference in New Issue
Block a user