158 lines
4.5 KiB
Bash
Executable File
158 lines
4.5 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Script to generate a release announcement for a project.
|
|
#
|
|
# All Rights Reserved.
|
|
#
|
|
# Licensed 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.
|
|
|
|
set -e
|
|
|
|
if [ $# -lt 1 ]; then
|
|
echo "Usage: $0 path-to-repository [version]"
|
|
echo
|
|
echo "Example: $0 ~/repos/openstack/oslo.rootwrap"
|
|
echo "Example: $0 ~/repos/openstack/oslo.rootwrap 3.0.3"
|
|
exit 2
|
|
fi
|
|
|
|
TOOLSDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
source $TOOLSDIR/functions
|
|
|
|
REPODIR=$(cd $1 && pwd)
|
|
VERSION=$2
|
|
|
|
# The repository directory may be named something other than what the
|
|
# repository is, if we're running under CI or someone has checked it
|
|
# out locally to an alternate name. Use the git remote URL as a source
|
|
# of better information for the real repository name.
|
|
SHORTNAME=$(basename $(cd $REPODIR && git config --get remote.origin.url))
|
|
REPOORGNAME=$(basename $(dirname $(cd $REPODIR && git config --get remote.origin.url)))
|
|
|
|
# Assign a default "from" email address if one is not specified by the
|
|
# user's environment.
|
|
export EMAIL=${EMAIL:-no-reply@openstack.org}
|
|
|
|
if [[ -z "$VIRTUAL_ENV" ]]; then
|
|
(cd $TOOLSDIR && tox -e venv --notest)
|
|
source $TOOLSDIR/.tox/venv/bin/activate
|
|
fi
|
|
|
|
# Make our output directory before we start moving around into
|
|
# temporary directories.
|
|
RELNOTESDIR="$PWD/relnotes"
|
|
mkdir -p $RELNOTESDIR
|
|
|
|
# Set up temporary directory for scratch files
|
|
setup_temp_space announce-$SHORTNAME
|
|
|
|
cd $REPODIR
|
|
|
|
# Determine the most recent tag if we weren't given a value.
|
|
if [[ -z "$VERSION" ]]; then
|
|
VERSION=$(get_last_tag)
|
|
fi
|
|
|
|
# Look for the previous version on the same branch. If the command
|
|
# fails because there are no other tags, we will produce the entire
|
|
# history.
|
|
PREVIOUS_VERSION=$(git describe --abbrev=0 ${VERSION}^ || echo "")
|
|
if [[ "$PREVIOUS_VERSION" = "" ]]; then
|
|
# There was no previous tag, so we're looking for the full history
|
|
# of the project.
|
|
PREVIOUS_VERSION=$(git rev-list --max-parents=0 HEAD)
|
|
first_release="--first-release"
|
|
fi
|
|
|
|
# Extract the tag message by parsing the git show output, which looks
|
|
# something like:
|
|
#
|
|
# tag 2.0.0
|
|
# Tagger: Doug Hellmann <doug@doughellmann.com>
|
|
# Date: Tue Dec 1 21:45:44 2015 +0000
|
|
#
|
|
# python-keystoneclient 2.0.0 release
|
|
#
|
|
# meta:version: 2.0.0
|
|
# meta:series: mitaka
|
|
# meta:release-type: release
|
|
# -----BEGIN PGP SIGNATURE-----
|
|
# Comment: GPGTools - http://gpgtools.org
|
|
#
|
|
# iQEcBAABAgAGBQJWXhUIAAoJEDttBqDEKEN62rMH/ihLAGfw5GxPLmdEpt7gsLJu
|
|
# ...
|
|
#
|
|
TAG_META=$(git show --no-patch "$VERSION" | grep '^meta:' || true)
|
|
if [[ -z "$TAG_META" ]]; then
|
|
echo ERROR: Missing meta lines in $VERSION tag message.
|
|
exit 1
|
|
fi
|
|
|
|
function get_tag_meta {
|
|
typeset fieldname="$1"
|
|
|
|
echo "$TAG_META" | grep "^meta:$fieldname:" | cut -f2 -d' '
|
|
}
|
|
|
|
# The series name is part of the commit message left by release.sh.
|
|
SERIES=$(get_tag_meta series)
|
|
|
|
# The recipient for announcements is part of the commit message left
|
|
# by release.sh.
|
|
ANNOUNCE=$(get_tag_meta announce)
|
|
if [[ ! -z "$ANNOUNCE" ]]; then
|
|
email_to="--email-to $ANNOUNCE"
|
|
fi
|
|
|
|
# Figure out if that series is a stable branch or not.
|
|
if git branch -a | grep -q origin/stable/$SERIES; then
|
|
stable="--stable"
|
|
fi
|
|
|
|
# Set up email tags for the project owner.
|
|
PROJECT_OWNER=${PROJECT_OWNER:-$(get-repo-owner --email-tag $REPOORGNAME/$SHORTNAME || echo "")}
|
|
if [[ "$PROJECT_OWNER" != "" ]]; then
|
|
email_tags="--email-tags ${PROJECT_OWNER}"
|
|
fi
|
|
|
|
# Only include the PyPI link if we are told to.
|
|
INCLUDE_PYPI_LINK=$(get_tag_meta pypi)
|
|
if [[ "$INCLUDE_PYPI_LINK" == "yes" ]]; then
|
|
include_pypi_link="--include-pypi-link"
|
|
fi
|
|
|
|
echo "$PREVIOUS_VERSION to $VERSION on $SERIES"
|
|
|
|
relnotes_file="$RELNOTESDIR/$SHORTNAME-$VERSION"
|
|
|
|
release-notes \
|
|
--email \
|
|
$email_to \
|
|
$email_tags \
|
|
--series $SERIES \
|
|
$stable \
|
|
$first_release \
|
|
. "$PREVIOUS_VERSION" "$VERSION" \
|
|
$include_pypi_link \
|
|
| tee $relnotes_file
|
|
|
|
echo
|
|
echo $relnotes_file
|
|
|
|
echo
|
|
echo "Sending release announcement"
|
|
send-mail -v $relnotes_file || \
|
|
echo "Sending failed, see $relnotes_file for message body"
|
|
|
|
exit 0
|