From 470c0bad9da39b902bc1db620c8be6ce5872b8ec Mon Sep 17 00:00:00 2001 From: Taiki Endo Date: Sun, 14 May 2023 07:17:15 +0900 Subject: [PATCH] Touch up PR 44 --- CHANGELOG.md | 2 ++ README.md | 1 + main.sh | 26 +++++++++----------------- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4dc2d9f..64aa8a0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ Note: In this file, do not use the hard wrap in the middle of a sentence for com ## [Unreleased] +- Add `profile` input option to allow specifying custom profiles. ([#44](https://github.com/taiki-e/upload-rust-binary-action/pull/44), thanks @afnanenayet) + ## [1.13.0] - 2023-03-22 - Switch to composite action ([#42](https://github.com/taiki-e/upload-rust-binary-action/pull/42)) diff --git a/README.md b/README.md index 8e471697..c9fd51cd 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ Currently, this action is basically intended to be used in combination with an a | 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` | +| profile | false | The cargo profile to build. This defaults to the release profile. | String | `release` | [^1]: Required one of `token` input option or `GITHUB_TOKEN` environment variable. diff --git a/main.sh b/main.sh index 50354c4f..d555c9bb 100755 --- a/main.sh +++ b/main.sh @@ -168,28 +168,20 @@ case "${OSTYPE}" in esac input_profile=${INPUT_PROFILE:-release} - -declare -a build_options=() - -if [[ -n "${input_profile}" ]]; then - build_options+=("--profile" "${input_profile}") -else - build_options+=("--release") -fi +case "${input_profile}" in + release) build_options=("--release") ;; + *) build_options=("--profile" "${input_profile}") ;; +esac # There are some special profiles that correspond to different target directory # names. If we don't hit one of those conditionals then we just use the profile # name. # See: https://doc.rust-lang.org/nightly/cargo/reference/profiles.html#custom-profiles -profile_directory=${input_profile} - -if [[ ${input_profile} = "bench" ]]; then - profile_directory="release" -elif [[ ${input_profile} = "dev" ]]; then - profile_directory="debug" -elif [[ ${input_profile} = "test" ]]; then - profile_directory="debug" -fi +case "${input_profile}" in + bench) profile_directory="release" ;; + dev | test) profile_directory="debug" ;; + *) profile_directory=${input_profile} ;; +esac bins=() for bin_name in "${bin_names[@]}"; do