2 # Licensed to the Apache Software Foundation (ASF) under one or more
3 # contributor license agreements. See the NOTICE file distributed with
4 # this work for additional information regarding copyright ownership.
5 # The ASF licenses this file to You under the Apache License, Version 2.0
6 # (the "License"); you may not use this file except in compliance with
7 # the License. You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
18 # This script is meant to help with the creation of Apache-compliant
19 # release candidates, as well as finalizing releases by using said candidates.
21 # Creation of a release candidate includes:
22 # 1) Creating a source package (a snapshot of the repository)
23 # 2) Creating a Pythonic sdist (generated docs, examples, etc., but no tests etc.)
24 # 3) Creating a Pythonic bdist (Wheel; binary distribution)
25 # 4) Publishing these packages on to https://dist.apache.org/repos/dist/dev/incubator/ariatosca/
26 # 5) Publishing the sdist and bdist packages on test-PyPI (https://test.pypi.org/)
28 # Finalization of a release includes:
29 # 1) Copying of the source, sdist and bdist packages from /dist/dev to /dist/release
30 # (i.e. from https://dist.apache.org/repos/dist/dev/incubator/ariatosca/
31 # to https://dist.apache.org/repos/dist/release/incubator/ariatosca/)
32 # 2) Publishing the sdist and bdist packages on PyPI (https://pypi.org)
33 # 3) Tagging the git repository for the release version
35 # Read more about Apache release rules and regulations at:
36 # 1) https://www.apache.org/dev/#releases
37 # 2) https://www.apache.org/legal/release-policy.html
38 # 3) https://www.apache.org/dev/release-distribution.html
39 # 4) https://www.apache.org/dev/release-publishing.html
40 # 5) https://www.apache.org/dev/release-signing.html
41 # 6) http://incubator.apache.org/incubation/Incubation_Policy.html#Releases
42 # 7) http://incubator.apache.org/guides/releasemanagement.html
48 function create_apache_release_candidate {
49 if [ "$#" -lt 1 ]; then
50 echo "Must provide git branch for release candidate" >&2
55 local OPTIONAL_ARIATOSCA_DIST_DEV_PATH=$2
57 ARIA_DIR=$(_get_aria_dir)
60 git checkout ${GIT_BRANCH}
61 local VERSION=$(cat VERSION)
63 echo "Creating Apache release candidate for version ${VERSION}..."
66 _create_source_package ${GIT_BRANCH} ${VERSION}
67 _create_sdist_and_bdist_packages
68 _publish_to_apache_dev ${VERSION} ${OPTIONAL_ARIATOSCA_DIST_DEV_PATH}
75 function finalize_apache_release {
76 if [ "$#" -ne 1 ]; then
77 echo "Must provide git branch for release tagging" >&2
83 ARIA_DIR=$(_get_aria_dir)
86 git checkout ${GIT_BRANCH}
87 local VERSION=$(cat VERSION)
89 read -p "Enter 'Yes' to confirm release finalization for version ${VERSION}: " yn
91 Yes ) echo "Finalizing Apache release...";;
92 * ) git checkout -; return;;
95 _publish_to_apache_release ${VERSION}
97 _create_git_tag ${VERSION}
103 function _get_aria_dir {
104 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
105 ARIA_DIR="$(dirname "${SCRIPT_DIR}")"
110 function _create_source_package {
113 local INCUBATING_ARCHIVE_CONTENT_DIR=apache-ariatosca-${VERSION}-incubating # e.g. apache-ariatosca-0.1.0-incubating
114 local INCUBATING_ARCHIVE=${INCUBATING_ARCHIVE_CONTENT_DIR}.tar.gz # e.g. apache-ariatosca-0.1.0-incubating.tar.gz
115 local SOURCE_PACKAGE_DIR="source"
117 echo "Creating source package..."
118 mkdir -p dist/${SOURCE_PACKAGE_DIR}
119 pushd dist/${SOURCE_PACKAGE_DIR}
120 # re-cloning repository, to ensure repo snapshot is clean and not environment-dependent
121 wget https://github.com/apache/incubator-ariatosca/archive/${GIT_BRANCH}.zip
122 unzip ${GIT_BRANCH}.zip > /dev/null
123 mv incubator-ariatosca-${GIT_BRANCH} ${INCUBATING_ARCHIVE_CONTENT_DIR}
124 tar -czvf ${INCUBATING_ARCHIVE} ${INCUBATING_ARCHIVE_CONTENT_DIR} > /dev/null
125 rm -rf ${INCUBATING_ARCHIVE_CONTENT_DIR}
128 _sign_package ${INCUBATING_ARCHIVE}
132 function _sign_package {
133 local ARCHIVE_NAME=$1
135 echo "Signing archive ${ARCHIVE_NAME}..."
136 gpg --armor --output ${ARCHIVE_NAME}.asc --detach-sig ${ARCHIVE_NAME}
137 gpg --print-md MD5 ${ARCHIVE_NAME} > ${ARCHIVE_NAME}.md5
138 gpg --print-md SHA512 ${ARCHIVE_NAME} > ${ARCHIVE_NAME}.sha
142 function _create_sdist_and_bdist_packages {
143 local SDIST_PACKAGE_DIR="sdist"
144 local BDIST_PACKAGE_DIR="bdist"
146 echo "Creating sdist and bdist packages..."
148 python setup.py sdist -d dist/${SDIST_PACKAGE_DIR} bdist_wheel -d dist/${BDIST_PACKAGE_DIR}
150 # pushing LICENSE and additional files into the binary distribution archive
151 find dist/${BDIST_PACKAGE_DIR} -type f -name '*.whl' -exec zip -u {} LICENSE NOTICE DISCLAIMER \;
153 pushd dist/${SDIST_PACKAGE_DIR}
154 local SDIST_ARCHIVE=$(find . -type f -name "*.tar.gz" -printf '%P\n')
155 _sign_package ${SDIST_ARCHIVE}
158 pushd dist/${BDIST_PACKAGE_DIR}
159 local BDIST_ARCHIVE=$(find . -type f -name "*.whl" -printf '%P\n')
160 _sign_package ${BDIST_ARCHIVE}
165 function _publish_to_test_pypi {
166 echo "Publishing to test PyPI..."
167 _publish_to_pypi https://test.pypi.org/legacy/
171 function _publish_to_apache_dev {
173 local ARIATOSCA_DIST_DEV_PATH=$2
175 local DIST_DIR=$(pwd)/dist
176 local RELEASE_DIR=${VERSION}-incubating # e.g. 0.1.0-incubating
178 echo "Publishing to Apache dist dev..."
179 if [ -z "${ARIATOSCA_DIST_DEV_PATH}" ]; then
180 local TMP_DIR=$(mktemp -d)
181 echo "Checking out ARIA dist dev to ${TMP_DIR}"
183 svn co https://dist.apache.org/repos/dist/dev/incubator/ariatosca/
185 pushd ${TMP_DIR}/ariatosca
187 pushd ${ARIATOSCA_DIST_DEV_PATH}
192 mv dist/ ${RELEASE_DIR}/
193 svn add ${RELEASE_DIR}
194 svn commit -m "ARIA ${VERSION} release candidate"
199 function _publish_to_real_pypi {
200 echo "Publishing to PyPI..."
201 _publish_to_pypi https://upload.pypi.org/legacy/
205 function _publish_to_pypi {
206 local REPOSITORY_URL=$1
211 local SDIST_ARCHIVE=$(find . -type f -name "*.tar.gz" -printf '%P\n')
212 twine upload --repository-url ${REPOSITORY_URL} ${SDIST_ARCHIVE} ${SDIST_ARCHIVE}.asc
216 local BDIST_ARCHIVE=$(find . -type f -name "*.whl" -printf '%P\n')
217 twine upload --repository-url ${REPOSITORY_URL} ${BDIST_ARCHIVE} ${BDIST_ARCHIVE}.asc
224 function _publish_to_apache_release {
226 local RELEASE_DIR=${VERSION}-incubating # e.g. 0.1.0-incubating
228 echo "Publishing to Apache dist..."
230 local TMP_DIR=$(mktemp -d)
231 echo "Checking out ARIA dist dev to ${TMP_DIR}"
234 svn co https://dist.apache.org/repos/dist/dev/incubator/ariatosca/ ariatosca-dev
235 svn co https://dist.apache.org/repos/dist/release/incubator/ariatosca/ ariatosca-release
236 cp -r ariatosca-dev/${RELEASE_DIR} ariatosca-release
238 pushd ariatosca-release
239 svn add ${RELEASE_DIR}
240 # TODO: remove older releases?
241 svn commit -m "ARIA ${VERSION} release"
247 function _create_git_tag {
250 echo "Creating git tag ${VERSION}"
251 git tag -a ${VERSION} -m "ARIA ${VERSION}"
252 git push --tags origin
257 command pushd "$@" > /dev/null
263 command popd "$@" > /dev/null
268 if [ "$#" -ne 2 ]; then
269 echo "Usage: $0 {candidate,package} <git-branch>" >&2
276 if [ "${OPERATION}" == "candidate" ]; then
277 create_apache_release_candidate ${GIT_BRANCH}
278 elif [ "${OPERATION}" == "package" ]; then
279 finalize_apache_release ${GIT_BRANCH}
281 echo "First parameter must be either 'candidate' or 'package'" >&2