Skip to content

Commit

Permalink
bintray/upload: Add -n dry run option
Browse files Browse the repository at this point in the history
This is mainly useful for testing.
  • Loading branch information
leandro-lucarella-sociomantic committed Jun 8, 2018
1 parent c3ceb1d commit 2969c58
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
28 changes: 21 additions & 7 deletions bin/bintray/upload
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ comp_force=
comp_release=release
comp_prerelease=prerelease
in_docker=true
dry_run=false
arch=


Expand Down Expand Up @@ -84,6 +85,9 @@ Options:
file name)
-N
don't run inside docker (by default this command runs inside docker)
-n
dry run (don't actually run the bintray command and skip most sanity checks,
just print the commands that would be run if all was good)
-h
show this help message and exit
EOT
Expand Down Expand Up @@ -114,17 +118,23 @@ bt()
{
cmd="$1"
shift
# Dummy config to avoid jfrog to stop and ask questions...
jfrog bt config --user=nobody --key=nokey --licenses=nolicense
if ! $dry_run
then
# Dummy config to avoid jfrog to stop and ask questions...
jfrog bt config --user=nobody --key=nokey --licenses=nolicense
fi
echo jfrog bt "$cmd" "$@"
jfrog bt "$cmd" --user="$user" --key="$key" "$@"
if ! $dry_run
then
jfrog bt "$cmd" --user="$user" --key="$key" "$@"
fi
}


# Parse arguments
################################################################################

while getopts t:d:D:u:k:PoC:r:p:a:Nh arg
while getopts t:d:D:u:k:PoC:r:p:a:nNh arg
do
case "$arg" in
t) tag="$OPTARG" ;;
Expand All @@ -138,6 +148,7 @@ do
r) comp_release="$OPTARG" ;;
p) comp_prerelease="$OPTARG" ;;
a) arch="$OPTARG" ;;
n) dry_run=true ;;
N) in_docker=false ;; # This was already parsed, but still
h) usage ; exit 0 ;;
\?) usage_die ;;
Expand All @@ -150,7 +161,7 @@ test "$#" -lt 1 &&
usage_die "You must specify FILE..."
test -z "$tag" &&
usage_die "You must specify -t TAG if \$TRAVIS_TAG is not present!"
test "$(git cat-file -t refs/tags/$tag)" != "tag" &&
test $dry_run = false && test "$(git cat-file -t refs/tags/$tag)" != "tag" &&
usage_die "'$tag' should be a valid git annotated tag!"
echo "$dest" | grep -qv '^.\+/.\+/.\+$' &&
usage_die "Invalid destination, please specify " \
Expand All @@ -173,8 +184,11 @@ test -z "$comp_prerelease" &&
dest="$dest/$tag"

# Check the presence of the jfrog tool
jfrog --help > /dev/null ||
exit $?
if ! $dry_run
then
jfrog --help > /dev/null ||
exit $?
fi


# Create version
Expand Down
4 changes: 4 additions & 0 deletions relnotes/bintray-dry-run.feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### The `bintray upload` command learned a *dry run* option

This is probably mainly only useful for testing.

0 comments on commit 2969c58

Please sign in to comment.