blob: c08c88529ec036989032869198da7a21dcf6ac35 [file] [log] [blame]
#!/bin/bash
# This script should be run after using `./build-artifact` to create rpms
# and debs. It will checksum and sign the artifacts and produce tarballs
# suitable for upload and explosion in a bintray repository.
set -o errexit
set -o nounset
set -o pipefail
ROOT_DIR=$(git rev-parse --show-toplevel)
cd "${ROOT_DIR}"
declare -A DIST_DIRS=(
["ubuntu-trusty"]="${ROOT_DIR}/artifacts/aurora-ubuntu-trusty/dist"
["debian-jessie"]="${ROOT_DIR}/artifacts/aurora-debian-jessie/dist"
["centos-7"]="${ROOT_DIR}/artifacts/aurora-centos-7/dist/rpmbuild/RPMS/x86_64"
)
function oses() {
echo "${!DIST_DIRS[@]}"
}
function dist_dir() {
local os="$1"
echo "${DIST_DIRS["${os}"]}"
}
function sign_artifacts() {
local os="$1"
local dist_dir="$2"
local stage_dir="$3"
find "${dist_dir}" -maxdepth 1 -type f | while read file; do
local name=$(basename "${file}")
# Sign the tarball.
gpg --armor --output "${stage_dir}/${name}.asc" --detach-sig "${file}"
# Create the checksums
gpg --print-md MD5 "${file}" > "${stage_dir}/${name}.md5"
shasum "${file}" > "${stage_dir}/${name}.sha"
done
}
function zip_artifacts() {
local os="$1"
local dist_dir="$2"
local stage_dir="$3"
rm -rf "${stage_dir}/${os}" && mkdir -p "${stage_dir}/${os}"
find "${dist_dir}" "${stage_dir}" -maxdepth 1 -type f | while read file; do
ln -s ${file} "${stage_dir}/${os}/$(basename ${file})"
done
local tarball="$(dirname ${dist_dir})/upload.tar"
tar -chf "${tarball}" -C "${stage_dir}" "${os}"
echo "${tarball}"
}
for os in $(oses); do
dist_dir="$(dist_dir ${os})"
if [[ -d "${dist_dir}" ]]; then
stage_dir="${dist_dir}/.stage"
rm -rf "${stage_dir}" && mkdir -p "${stage_dir}"
echo "Signing artifacts for ${os}..."
sign_artifacts "${os}" "${dist_dir}" "${stage_dir}"
archive="$(zip_artifacts "${os}" "${dist_dir}" "${stage_dir}")"
echo "Created archive for ${os} artifacts at ${archive}."
else
echo "Skipping artifacts for ${os} (not found built under ${dist_dir})."
fi
done
echo "All artifacts prepared for upload to bintray."