rdblue commented on a change in pull request #3322:
URL: https://github.com/apache/iceberg/pull/3322#discussion_r732885299
##########
File path: dev/source-release.sh
##########
@@ -72,54 +77,73 @@ scriptdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &>
/dev/null && pwd )"
projectdir="$(dirname "$scriptdir")"
tmpdir=$projectdir/tmp
-if [ -d $tmpdir ]; then
+if [ -d "$tmpdir" ]; then
echo "Cannot run: $tmpdir already exists"
exit 1
fi
tag="apache-iceberg-$version"
tagrc="${tag}-rc${rc}"
+# Get original version hash to return to in test mode
+original_version_hash=$(git rev-list HEAD 2> /dev/null | head -n 1 )
+if [ $testing = true ]; then
+ echo "In test mode: will revert to current hash $original_version_hash when
done"
+fi
+
echo "Preparing source for $tagrc"
echo "Adding version.txt and tagging release..."
-echo $version > $projectdir/version.txt
-git add $projectdir/version.txt
+echo "$version" > "$projectdir/version.txt"
+git add "$projectdir/version.txt"
git commit -m "Add version.txt for release $version" $projectdir/version.txt
-set_version_hash=`git rev-list HEAD 2> /dev/null | head -n 1 `
+set_version_hash=$(git rev-list HEAD 2> /dev/null | head -n 1 )
+
+# We need to tag the release candidate, even in test mode, so the rest of the
script works.
+echo "Tagging the release candidate"
git tag -am "Apache Iceberg $version" $tagrc $set_version_hash
-echo "Pushing $tagrc to $remote..."
-git push $remote $tagrc
+# Only push the tag when we're not testing to keep remote environment pristine.
+if [ $testing != true ]; then
+ echo "Pushing $tagrc to $remote..."
+ git push $remote $tagrc
+else
+ echo "In test mode: Not pushing the tagged release candidate to $remote. A
tarball will be available at the end"
+fi
-release_hash=`git rev-list $tagrc 2> /dev/null | head -n 1 `
+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
+ exit 1
fi
# 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"
+echo "Creating tarball ${tarball} using commit $release_hash from tag $tagrc"
tarball=$tag.tar.gz
-git archive $release_hash --worktree-attributes --prefix $tag/ -o
$projectdir/$tarball
+git archive "$release_hash" --worktree-attributes --prefix "$tag"/ -o
"$projectdir"/"$tarball"
echo "Signing the tarball..."
[[ -z "$keyid" ]] && keyopt="-u $keyid"
gpg --detach-sig $keyopt --armor --output ${projectdir}/${tarball}.asc
${projectdir}/$tarball
-sha512sum ${projectdir}/$tarball > ${projectdir}/${tarball}.sha512
+shasum -a 512 ${projectdir}/$tarball > ${projectdir}/${tarball}.sha512
Review comment:
This works for me on ubuntu so I think it's a good update to make the
script more portable.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]