Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3d44c27

Browse files
committed
Add logrun to lib.sh
1 parent faf9c32 commit 3d44c27

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

.github/workflows/release.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ jobs:
5555
# Necessary for Docker manifest
5656
DOCKER_CLI_EXPERIMENTAL: "enabled"
5757
steps:
58-
- name: Prevent non-dry-run releases on branches
59-
if: ${{ github.action_ref != 'main' && !inputs.dry_run }}
58+
- name: Check release on main (or dry-run)
59+
if: ${{ github.ref_name != 'main' && !inputs.dry_run }}
6060
run: |
61-
echo "Release not allowed on ${{ github.action_ref }}, use dry-run."
61+
echo "Release not allowed on ${{ github.ref_name }}, use dry-run."
6262
exit 1
6363
6464
- uses: actions/checkout@v3

scripts/lib.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,18 @@ maybedryrun() {
131131
log "DRYRUN: $*"
132132
else
133133
shift
134-
log $ "$@"
135-
"$@"
134+
logrun "$@"
136135
fi
137136
}
138137

138+
# logrun prints the given program and flags, and then executes it.
139+
#
140+
# Usage: logrun gh release create ...
141+
logrun() {
142+
log $ "$*"
143+
"$@"
144+
}
145+
139146
# log prints a message to stderr.
140147
log() {
141148
echo "$*" 1>&2

scripts/release.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,7 @@ else
167167
fi
168168

169169
log
170-
# Use maybedryrun to echo the command.
171-
maybedryrun 0 gh workflow run release.yaml \
170+
logrun gh workflow run release.yaml \
172171
--ref "$branch" \
173172
-F increment="$increment" \
174173
"${args[@]}"

0 commit comments

Comments
 (0)