blob: a6a68722896cd96c296196b5d3bb02fa1cb17b06 [file]
#!/usr/bin/env bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
VERSION=${1}
DOWNLOAD=${2:-/tmp/camel-release}
WINGET_CANDIDATE=${3:-}
WINGET_SHA512=${4:-}
mkdir -p ${DOWNLOAD} 2>/dev/null
# The following component contain schema definitions that must be published
RUNDIR=$(cd ${0%/*} && echo $PWD)
DIST_REPO="https://dist.apache.org/repos/dist/release/camel/apache-camel/"
DIST_DEV_REPO="https://dist.apache.org/repos/dist/dev/camel/apache-camel"
if [ -z "${VERSION}" -o ! -d "${DOWNLOAD}" ]
then
echo "Usage: release-distro.sh <camel-version> [temp-directory] [winget-candidate] [winget-sha512]"
exit 1
fi
case "${WINGET_CANDIDATE}" in
*[!0-9]*)
echo "Error: winget-candidate must be a positive integer."
exit 1
;;
esac
if [ -n "${WINGET_CANDIDATE}" ] && [ "${WINGET_CANDIDATE}" -lt 1 ]; then
echo "Error: winget-candidate must be a positive integer."
exit 1
fi
# The candidate number alone cannot prove the right candidate was promoted: every RC directory
# carries its own self-consistent .sha512 and .asc, so exporting rc3 when the vote approved rc4
# passes both checks. The approved digest comes from the vote email and is the only input that
# distinguishes them, so it is mandatory whenever a candidate is promoted.
if [ -n "${WINGET_CANDIDATE}" ]; then
case "${WINGET_SHA512}" in
*[!0-9a-fA-F]* | "")
echo "Error: winget-sha512 (the approved SHA-512 from the vote email) is required with winget-candidate."
exit 1
;;
esac
if [ ${#WINGET_SHA512} -ne 128 ]; then
echo "Error: winget-sha512 must be a 128-character SHA-512 hex digest."
exit 1
fi
fi
echo "################################################################################"
echo " DOWNLOADING DISTRO FROM APACHE REPOSITORY "
echo "################################################################################"
echo "${DOWNLOAD}/${VERSION}"
wget -e robots=off --wait 3 --no-check-certificate \
-r -np "--accept=pom,pom.asc,zip,zip.asc,tar.gz,tar.gz.asc" "--follow-tags=" \
-P "${DOWNLOAD}/${VERSION}" -nH "--cut-dirs=3" "--level=1" "--ignore-length" \
"https://repository.apache.org/content/repositories/releases/org/apache/camel/apache-camel/${VERSION}/"
DOWNLOAD_LOCATION="${DOWNLOAD}/${VERSION}/org/apache/camel/apache-camel/${VERSION}"
# Remove duplicate signature files
rm "${DOWNLOAD_LOCATION}/"*.asc.asc
# Remove the md5 and sha1 check sum files
rm "${DOWNLOAD_LOCATION}/"*.md5
rm "${DOWNLOAD_LOCATION}/"*.sha1
# Create sha512 check sum files
cd "${DOWNLOAD_LOCATION}"
for file in *.pom *.tar.gz *.zip; do
[ -f "${file}" ] && sha512sum "${file}" > "${file}.sha512"
done
if [ -n "${WINGET_CANDIDATE}" ]; then
WINGET_NAME="camel-launcher-${VERSION}-winget-bin.zip"
WINGET_RC_URL="${DIST_DEV_REPO}/${VERSION}-rc${WINGET_CANDIDATE}"
for suffix in "" ".asc" ".sha512"; do
if ! svn export "${WINGET_RC_URL}/${WINGET_NAME}${suffix}" \
"${DOWNLOAD_LOCATION}/${WINGET_NAME}${suffix}"; then
echo "Error: could not export approved WinGet candidate file ${WINGET_NAME}${suffix}."
exit 1
fi
done
ACTUAL_SHA512=$(sha512sum "${WINGET_NAME}" | awk '{print $1}')
if [ "$(echo "${ACTUAL_SHA512}" | tr 'A-Z' 'a-z')" != "$(echo "${WINGET_SHA512}" | tr 'A-Z' 'a-z')" ]; then
echo "Error: exported WinGet candidate does not match the SHA-512 approved in the vote."
echo " approved: ${WINGET_SHA512}"
echo " exported: ${ACTUAL_SHA512} (from ${WINGET_RC_URL})"
echo "Check that rc${WINGET_CANDIDATE} is the candidate the vote actually approved."
exit 1
fi
if ! sha512sum -c "${WINGET_NAME}.sha512"; then
echo "Error: approved WinGet candidate SHA-512 verification failed."
exit 1
fi
if ! gpg --verify "${WINGET_NAME}.asc" "${WINGET_NAME}"; then
echo "Error: approved WinGet candidate signature verification failed."
exit 1
fi
fi
echo "################################################################################"
echo " RESET GROUP PERMISSIONS "
echo "################################################################################"
# Make sure to give appropriate permissions to the camel group
chown -R :camel ${DOWNLOAD}/${VERSION}
chmod -R g+w ${DOWNLOAD}/${VERSION}
echo
echo "################################################################################"
echo " MOVE DISTRO TO OFFICIAL APACHE MIRROR REPO "
echo "################################################################################"
# Move distro to the correct location
mkdir -p ${DOWNLOAD}/dist 2>/dev/null
svn mkdir ${DIST_REPO}/${VERSION} -m "Apache Camel ${VERSION} release distro placeholder."
cd ${DOWNLOAD}/dist; svn co ${DIST_REPO}/${VERSION}
cp ${DOWNLOAD}/${VERSION}/org/apache/camel/apache-camel/${VERSION}/* ${DOWNLOAD}/dist/${VERSION}/
cd "${DOWNLOAD}/dist/${VERSION}/"; svn add *
echo
echo "Distro artifacts prepared for upload, but not yet uploaded. Verify distro then complete upload!"
echo "cd ${DOWNLOAD}/dist/${VERSION}/"
echo "svn status"
echo "svn ci -m \"Apache Camel ${VERSION} released artifacts.\""
echo
echo "Remove previous distro on same branch if necessary"
echo "DONE"