Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support manifest path override #32

Merged
merged 6 commits into from
Oct 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Currently, this action is basically intended to be used in combination with an a
| leading_dir | false | Whether to create the leading directory in the archive or not | Boolean | `false` |
| build_tool | false | Tool to build binaries (cargo or cross, see [cross-compilation example](#example-workflow-cross-compilation) for more) | String | |
| ref | false | Fully-formed tag ref for this release (see [action.yml](action.yml) for more) | String | |
| manifest_path | false | Path to Cargo.toml | String | `Cargo.toml` |

[^1]: Required one of `token` input option or `GITHUB_TOKEN` environment variable.

Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ inputs:
description: Whether to disable cargo build default features
required: false
default: 'false'
manifest_path:
description: Override cargo manifest path
required: false
tar:
description: On which platform to distribute the `.tar.gz` file (all, unix, windows, or none)
required: false
Expand Down
19 changes: 14 additions & 5 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -181,11 +181,7 @@ if [[ -n "${strip:-}" ]]; then
fi

build_options=("--release")
target_dir="target/release"
if [[ -n "${INPUT_TARGET:-}" ]]; then
target_dir="target/${target}/release"
build_options+=("--target" "${target}")
fi
target_dir=""
bins=()
for bin_name in "${bin_names[@]}"; do
bins+=("${bin_name}${exe:-}")
Expand All @@ -197,6 +193,19 @@ fi
if [[ -n "${no_default_features}" ]]; then
build_options+=("--no-default-features")
fi
manifest_path="${INPUT_MANIFEST_PATH:-}"
if [[ -n "${manifest_path}" ]]; then
build_options+=("--manifest-path" "${manifest_path}")
target_dir=$(cargo metadata --format-version=1 --no-deps --manifest-path "${manifest_path}" | jq -r '."target_directory"')
else
target_dir=$(cargo metadata --format-version=1 --no-deps | jq -r '."target_directory"')
fi
if [[ -n "${INPUT_TARGET:-}" ]]; then
build_options+=("--target" "${target}")
target_dir="${target_dir}/${target}/release"
else
target_dir="${target_dir}/release"
fi

case "${build_tool}" in
cargo) cargo build "${build_options[@]}" ;;
Expand Down