Skip to content

Commit c86b837

Browse files
authored
Add dry-run-intended to suppress informational warnings generated by dry-run (#100)
1 parent 31389c3 commit c86b837

File tree

3 files changed

+29
-8
lines changed

3 files changed

+29
-8
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ Currently, this action is basically intended to be used in combination with an a
5555
| manifest-path | | Path to Cargo.toml | String | `Cargo.toml` |
5656
| profile | | The cargo profile to build. This defaults to the release profile. | String | `release` |
5757
| dry-run | | Build and compress binaries, but do not upload them (see [action.yml](action.yml) for more) | Boolean | `false` |
58+
| dry-run-intended | | Suppress informational `dry-run` warnings, keeping the rest | Boolean | `false` |
5859
| codesign | | Sign build products using `codesign` on macOS | String | |
5960
| codesign-prefix | | Prefix for the `codesign` identifier on macOS | String | |
6061
| codesign-options | | Specifies a set of option flags to be embedded in the code signature on macOS. See the `codesign` manpage for details. | String | |

action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ inputs:
9797
9898
Note that some errors are downgraded to warnings in this mode.
9999
required: false
100+
dry-run-intended:
101+
description: >
102+
Suppress informational warnings for `dru-run` keeping the rest
103+
required: false
104+
default: 'false'
100105
dry_run:
101106
description: Alias for 'dry-run'
102107
required: false
@@ -176,6 +181,7 @@ runs:
176181
INPUT_REF: ${{ inputs.ref }}
177182
INPUT_PROFILE: ${{ inputs.profile }}
178183
INPUT_DRY_RUN: ${{ inputs.dry-run || inputs.dry_run }}
184+
INPUT_DRY_RUN_INTENDED: ${{ inputs.dry-run-intended }}
179185
INPUT_CODESIGN: ${{ inputs.codesign }}
180186
INPUT_CODESIGN_PREFIX: ${{ inputs.codesign-prefix || inputs.codesign_prefix }}
181187
INPUT_CODESIGN_OPTIONS: ${{ inputs.codesign-options || inputs.codesign_options }}

main.sh

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,36 @@ case "${dry_run}" in
4444
*) bail "'dry-run' input option must be 'true' or 'false': '${dry_run}'" ;;
4545
esac
4646

47+
dry_run_intended="${INPUT_DRY_RUN_INTENDED:-}"
48+
case "${dry_run_intended}" in
49+
true) dry_run_intended=1 ;;
50+
false) dry_run_intended='' ;;
51+
'') dry_run_intended='' ;;
52+
*) bail "'dry-run-intended' input option must be 'true' or 'false': '${dry_run_intended}'" ;;
53+
esac
54+
4755
token="${INPUT_TOKEN:-"${GITHUB_TOKEN:-}"}"
4856
ref="${INPUT_REF:-"${GITHUB_REF:-}"}"
4957

5058
if [[ -z "${token}" ]]; then
5159
if [[ -n "${dry_run}" ]]; then
52-
# TODO: The warnings are somewhat noisy if we have a lot of build matrix:
53-
# https://github.com/taiki-e/upload-rust-binary-action/pull/55#discussion_r1349880455
54-
warn "neither GITHUB_TOKEN environment variable nor 'token' input option is set (downgraded error to info because action is running in dry-run mode)"
60+
if [[ -z "${dry_run_intended}" ]]; then
61+
# TODO: The warnings are somewhat noisy if we have a lot of build matrix:
62+
# https://github.com/taiki-e/upload-rust-binary-action/pull/55#discussion_r1349880455
63+
warn "neither GITHUB_TOKEN environment variable nor 'token' input option is set (downgraded error to info because action is running in dry-run mode)"
64+
fi
5565
else
5666
bail "neither GITHUB_TOKEN environment variable nor 'token' input option is set"
5767
fi
5868
fi
5969

6070
if [[ "${ref}" != "refs/tags/"* ]]; then
6171
if [[ -n "${dry_run}" ]]; then
62-
# TODO: The warnings are somewhat noisy if we have a lot of build matrix:
63-
# https://github.com/taiki-e/upload-rust-binary-action/pull/55#discussion_r1349880455
64-
warn "tag ref should start with 'refs/tags/': '${ref}'; this action only supports events from tag or release by default; see <https://github.com/taiki-e/create-gh-release-action#supported-events> for more (downgraded error to info because action is running in dry-run mode)"
72+
if [[ -z "${dry_run_intended}" ]]; then
73+
# TODO: The warnings are somewhat noisy if we have a lot of build matrix:
74+
# https://github.com/taiki-e/upload-rust-binary-action/pull/55#discussion_r1349880455
75+
warn "tag ref should start with 'refs/tags/': '${ref}'; this action only supports events from tag or release by default; see <https://github.com/taiki-e/create-gh-release-action#supported-events> for more (downgraded error to info because action is running in dry-run mode)"
76+
fi
6577
ref='refs/tags/dry-run'
6678
else
6779
bail "tag ref should start with 'refs/tags/': '${ref}'; this action only supports events from tag or release by default; see <https://github.com/taiki-e/create-gh-release-action#supported-events> for more"
@@ -562,8 +574,10 @@ for checksum in ${checksums[@]+"${checksums[@]}"}; do
562574
done
563575

564576
if [[ -n "${dry_run}" ]]; then
565-
info "skipped upload because action is running in dry-run mode"
566-
printf "tag: %s ('dry-run' if tag ref is not start with 'refs/tags/')\n" "${tag}"
577+
if [[ -z "${dry_run_intended}" ]]; then
578+
info "skipped upload because action is running in dry-run mode"
579+
printf "tag: %s ('dry-run' if tag ref is not start with 'refs/tags/')\n" "${tag}"
580+
fi
567581
IFS=','
568582
printf 'assets: %s\n' "${final_assets[*]}"
569583
IFS=$'\n\t'

0 commit comments

Comments
 (0)