--- /dev/null
+#!/bin/bash
+
+APIKEY=""
+DISTROS="jessie stretch"
+COMPONENT="main"
+BASE_URL="https://artifactory.foobar/artifactory"
+REPO="foobar"
+REPO_URL="${BASE_URL}/${REPO}"
+
+function help {
+ cat <<EOF
+ ${0} mypackage.deb
+
+ This script will upload your Debian package to artifactory and rebuild
+ the index.
+EOF
+
+ exit 1
+}
+
+function build_dist_list {
+ local debdist
+ for x in ${DISTROS}; do
+ debdist="${debdist}deb.distribution=${x};"
+ done
+ echo ${debdist}
+}
+
+if [ -z "${1}" ]; then
+ echo "ERROR: no deb package provided"
+ help
+fi
+
+PKG="${1}"
+ARCH="$(dpkg -I ${PKG} | grep Architecture | cut -d' ' -f 3)"
+SHA="$(sha256sum ${PKG} | cut -d' ' -f 1)"
+DIST="$(build_dist_list)"
+
+echo "PKGNAME: ${PKG}"
+echo "SHA: ${SHA}"
+echo "DIST: ${DIST}"
+echo "ARCHITECTURE: ${ARCH}"
+
+# upload with curl
+curl -s "${REPO_URL}/${PKG};${DIST}deb.component=${COMPONENT};deb.architecture=${ARCH}" -T ${PKG} -H"X-Checksum-Sha256:${SHA}" -H"X-JFrog-Art-Api:${APIKEY}"
+ret="$?"
+
+if [ "$ret" != "0" ]; then
+ echo "ERROR: Uploading your package ${pkg} to ${REPO_URL} failed - aborting"
+ exit 1
+fi
+printf "\n"
+
+# rebuild the index
+curl -s -X POST "${BASE_URL}/api/deb/reindex/${REPO}" -H"X-JFrog-Art-Api:${APIKEY}"
+ret="$?"
+
+if [ "$ret" != "0" ]; then
+ echo "ERROR: Rebuild package index for ${REPO} failed - aborting"
+ exit 1
+fi
+printf "\n"