File size: 5,756 Bytes
f0f4f2b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#!/bin/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.
#

#
# Generate a release-candidate and a text file containing the release
# announcement email.
#

set -e

usage () {
    echo "usage: $0 [-k <key_id>] [-g <git_remote>] -v <version_num> -r <rc_num>"
    echo "  -v      Version number of release"
    echo "  -r      Release candidate number"
    echo "  -k      Specify signing key. Defaults to \"GPG default key\""
    echo "  -g      Specify Git remote name. Defaults to \"apache\""
    echo "  -d      Turn on DEBUG output"
    exit 1
}

# Default repository remote name
remote="apache"

while getopts "v:r:k:g:d" opt; do
  case "${opt}" in
    v)
      version="${OPTARG}"
      ;;
    r)
      rc="${OPTARG}"
      ;;
    k)
      keyid="${OPTARG}"
      ;;
    g)
      remote="${OPTARG}"
      ;;
    d)
      set -x
      ;;
    *)
      usage
      ;;
  esac
done

shift $((OPTIND-1))

if [ -z "$version" ] || [ -z "$rc" ]; then
  echo "You must specify the version and RC numbers using the -v and -r switches"
  usage
fi

if ! git ls-remote --exit-code "$remote" >/dev/null 2>&1 ; then
  echo "The target remote git repository, ${remote}, is not configured in git. Please pass a valid value for the remote git repository to target via the -g switch"
  usage
fi

scriptdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
projectdir="$(dirname "$scriptdir")"
tmpdir=$projectdir/tmp

if [ -d $tmpdir ]; then
  echo "Cannot run: $tmpdir already exists"
  exit 1
fi

tag="apache-iceberg-$version"
tagrc="${tag}-rc${rc}"

echo "Preparing source for $tagrc"

echo "Creating release candidate tag: $tagrc..."
set_version_hash=`git rev-list HEAD 2> /dev/null | head -n 1 `
git tag -am "Apache Iceberg $version" $tagrc $set_version_hash

echo "Pushing $tagrc to $remote..."
git push $remote $tagrc

release_hash=`git rev-list $tagrc 2> /dev/null | head -n 1 `

if [ -z "$release_hash" ]; then
  echo "Cannot continue: unknown Git tag: $tag"
  exit
fi

echo "Generating version.txt and iceberg-build.properties..."
echo $version > $projectdir/version.txt
./gradlew generateGitProperties
cp $projectdir/build/iceberg-build.properties $projectdir/iceberg-build.properties

# be conservative and use the release hash, even though git produces the same
# archive (identical hashes) using the scm tag
echo "Creating tarball ${tarball} using commit $release_hash"
tarball=$tag.tar.gz
git archive $release_hash --worktree-attributes --prefix $tag/ --add-file $projectdir/version.txt --add-file $projectdir/iceberg-build.properties -o $projectdir/$tarball

# remove the uncommitted build files so they don't affect the current working copy
rm $projectdir/version.txt
rm $projectdir/iceberg-build.properties

echo "Signing the tarball..."
[[ -n "$keyid" ]] && keyopt="-u $keyid"
gpg $keyopt --armor --output ${projectdir}/${tarball}.asc --detach-sig ${projectdir}/$tarball
shasum -a 512 $tarball > ${projectdir}/${tarball}.sha512


echo "Checking out Iceberg RC subversion repo..."
svn co --depth=empty https://dist.apache.org/repos/dist/dev/iceberg $tmpdir

echo "Adding tarball to the Iceberg distribution Subversion repo..."
mkdir -p $tmpdir/$tagrc
cp $projectdir/${tarball}* $tmpdir/$tagrc
svn add $tmpdir/$tagrc
svn ci -m "Apache Iceberg $version RC${rc}" $tmpdir/$tagrc

echo "Creating release-announcement-email.txt..."
cat << EOF > $projectdir/release-announcement-email.txt
To: dev@iceberg.apache.org
Subject: [VOTE] Release Apache Iceberg ${version} RC${rc}

Hi Everyone,

I propose that we release the following RC as the official Apache Iceberg ${version} release.

The commit ID is ${release_hash}
* This corresponds to the tag: apache-iceberg-${version}-rc${rc}
* https://github.com/apache/iceberg/commits/apache-iceberg-${version}-rc${rc}
* https://github.com/apache/iceberg/tree/${release_hash}

The release tarball, signature, and checksums are here:
* https://dist.apache.org/repos/dist/dev/iceberg/apache-iceberg-${version}-rc${rc}

You can find the KEYS file here:
* https://dist.apache.org/repos/dist/dev/iceberg/KEYS

Convenience binary artifacts are staged on Nexus. The Maven repository URL is:
* https://repository.apache.org/content/repositories/orgapacheiceberg-<ID>/

Please download, verify, and test.

Please vote in the next 72 hours.

[ ] +1 Release this as Apache Iceberg ${version}
[ ] +0
[ ] -1 Do not release this because...

Only PMC members have binding votes, but other community members are encouraged to cast
non-binding votes. This vote will pass if there are 3 binding +1 votes and more binding
+1 votes than -1 votes.
EOF

echo "Success! The release candidate is available here:"
echo "  https://dist.apache.org/repos/dist/dev/iceberg/$tagrc"
echo ""
echo "Commit SHA1: $release_hash"
echo ""
echo "We have generated a release announcement email for you here:"
echo "$projectdir/release-announcement-email.txt"
echo ""
echo "Please note that you must update the Nexus repository URL"
echo "contained in the mail before sending it out."

rm -rf $tmpdir