diff --git a/Changes.md b/Changes.md index 8659c20..226f85c 100644 --- a/Changes.md +++ b/Changes.md @@ -1,3 +1,8 @@ +## 0.0.13 + +- It's now possible to set `cross-version` to a git ref like a commit hash or `HEAD`. This will + install `cross` from its git repo. + ## 0.0.12 - 2024-02-25 - Bumped the version of `actions/cache` used in this action to v4. The v3 version uses Node 16, diff --git a/README.md b/README.md index cb0f9e1..2bf3308 100644 --- a/README.md +++ b/README.md @@ -55,16 +55,16 @@ 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 fail 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 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`. | -| `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 binaries will be stripped if possible. This is only possible for binaries which weren't cross-compiled. | -| `cross-version` | string | no | This can be used to set the version of `cross` to use. If specified, it should be a specific `cross` release tag. If this is not set then the latest version will always be used. | +| 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. | +| `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`. | +| `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 binaries will be stripped if possible. This is only possible for binaries which weren't cross-compiled. | +| `cross-version` | string | no | This can be used to set the version of `cross` to use. If specified, it should be a specific `cross` release tag (like `v0.2.3`) or a git ref (commit hash, `HEAD`, etc.). If this is not set then the latest released version will always be used. If this is set to a git ref then the version corresponding to that ref will be installed. | ## How it Works diff --git a/install-cross-nix.sh b/install-cross-nix.sh index cabd99c..2f73c01 100755 --- a/install-cross-nix.sh +++ b/install-cross-nix.sh @@ -1,3 +1,5 @@ +#!/bin/bash + set -e set -x set -o pipefail @@ -5,12 +7,19 @@ set -o pipefail CROSS_DIR="$1" VERSION="$2" +cd "$CROSS_DIR" + +if [[ -n "$VERSION" ]] && ! [[ "$VERSION" =~ ^v ]]; then + cargo install cross --git https://github.com/cross-rs/cross --rev "$VERSION" + mv "$HOME/.cargo/bin/cross" . + exit 0 +fi + VERSION_ARGS="" if [ -n "$VERSION" ]; then VERSION_ARGS="--tag $VERSION" fi -cd "$CROSS_DIR" export TARGET=. curl --silent --location \ https://raw.githubusercontent.com/houseabsolute/ubi/master/bootstrap/bootstrap-ubi.sh |