Skip to content
Merged
138 changes: 138 additions & 0 deletions dev/release/post-website.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
#!/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.

set -e
set -u

SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ARROW_DIR="${SOURCE_DIR}/../../"
: ${ARROW_SITE_DIR:="${ARROW_DIR}/../arrow-site"}

if [ "$#" -ne 2 ]; then
echo "Usage: $0 <previous-version> <version>"
exit 1
fi

previous_version=$1
version=$2

branch_name=release-note-arrow-go-${version}
release_dir="${ARROW_SITE_DIR}/_posts"
announce_file="${release_dir}/$(date +%Y-%m-%d)-arrow-go-${version}.md"

pushd "${ARROW_SITE_DIR}"
DEFAULT_BRANCH="$(git rev-parse --abbrev-ref origin/HEAD | sed s@origin/@@)"
git fetch --all --prune --tags --force -j$(nproc)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a check whether this working copy is a fork not apache/arrow-site?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

git checkout ${DEFAULT_BRANCH}
git branch -D ${branch_name} || :
git checkout -b ${branch_name}
popd

pushd "${ARROW_DIR}"

previous_major_version="$(echo v${previous_version} | grep -o '^[0-9]*')"
major_version="$(echo v${version} | grep -o '^[0-9]*')"
if [ ${previous_major_version} -eq ${major_version} ]; then
release_type=patch
else
release_type=major
fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add "minor" release detection?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added


export TZ=UTC
release_date=$(LC_TIME=C date "+%-d %B %Y")
release_date_iso8601=$(LC_TIME=C date "+%Y-%m-%d")
previous_tag_date=$(git log -n 1 --pretty=%aI v${previous_version})
rough_previous_release_date=$(date --date "${previous_tag_date}" +%s)
rough_release_date=$(date +%s)
rough_n_development_months=$(((\
${rough_release_date} - ${rough_previous_release_date}) / (60 * 60 * 24 * 30)))

git_tag=v${version}
git_range=v${previous_version}..v${version}

contributors_command_line="git shortlog -sn ${git_range}"
contributors=$(${contributors_command_line} | grep -v dependabot)

n_commits=$(git log --pretty=oneline ${git_range} | grep -i -v "chore: Bump" | wc -l)
n_contributors=$(${contributors_command_line} | grep -v dependabot | wc -l)

git_tag_hash=$(git log -n 1 --pretty=%H ${git_tag})
git_changelog="$(gh release view --json body --jq .body | grep -v '@dependabot')"
popd

pushd "${ARROW_SITE_DIR}"

cat <<ANNOUNCE >>"${announce_file}"
---
layout: post
title: "Apache Arrow Go ${version} Release"
date: "${release_date_iso8601} 00:00:00"
author: pmc
categories: [release]
---
<!--
{% comment %}
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.
{% endcomment %}
-->
The Apache Arrow team is pleased to announce the v${version} release ofApache Arrow Go.
This ${release_type} release covers ${n_commits} commits from ${n_contributors} distinct contributors.
## Contributors
\`\`\`console
$ ${contributors_command_line}
ANNOUNCE

echo "${contributors}" >>"${announce_file}"

cat <<ANNOUNCE >>"${announce_file}"
\`\`\`
## Changelog
${git_changelog}
ANNOUNCE

git add "${announce_file}"
git commit -m "[Release] Add release notes for Arrow Go ${version}"
git push -u origin ${branch_name}

github_url=$(git remote get-url origin |
sed \
-e 's,^[email protected]:,https://github.com/,' \
-e 's,\.git$,,')

echo "Success!"
echo "Create a pull request:"
echo " ${github_url}/pull/new/${branch_name}"
popd
2 changes: 1 addition & 1 deletion dev/release/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ gh release download "${rc_tag}" \

echo "Uploading to release/"
pushd "${dist_base_dir}"
svn add .
svn add "${release_id}"
svn ci -m "Apache Arrow Go ${version}"
popd
rm -rf "${dist_base_dir}"
Expand Down
Loading