YETUS-1032. Automate and update release documentation (#1)
Signed-off-by: Nick Dimiduk <ndimiduk@apache.org>
diff --git a/Formula/yetus.rb b/Formula/yetus.rb
index eec276a..e149b3d 100644
--- a/Formula/yetus.rb
+++ b/Formula/yetus.rb
@@ -18,7 +18,7 @@
class Yetus < Formula
desc "Enable contribution and release processes for software projects"
homepage "https://yetus.apache.org/"
- url "https://www.apache.org/dyn/closer.lua?path=/yetus/0.12.0/apache-yetus-0.12.0-bin.tar.gz"
+ url "https://www.apache.org/dyn/closer.cgi?filename=/yetus/0.12.0/apache-yetus-0.12.0-bin.tar.gz&action=download"
sha256 "295e01b710d68152a85c73d5bf70b1189818219f9146c2981e1623df3414232b"
option "with-all", "Build with all dependencies. Note that some dependencies such as "\
diff --git a/release.sh b/release.sh
new file mode 100755
index 0000000..3412fb4
--- /dev/null
+++ b/release.sh
@@ -0,0 +1,67 @@
+#!/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.
+
+# SHELLDOC-IGNORE
+
+USER_NAME=${SUDO_USER:=$USER}
+USER_ID=$(id -u "${USER_NAME}")
+
+usage() {
+ cat <<EOF
+$0 YETUS-xxx 0.0.0
+EOF
+ exit 1
+}
+
+cleanup() {
+ git checkout --force main
+ exit 1
+}
+
+verifyparams() {
+
+ if [[ $# -ne 2 ]]; then
+ usage
+ fi
+
+ JIRAISSUE=$1
+ VERSION=$2
+
+ if [[ ! "${JIRAISSUE}" =~ YETUS- ]]; then
+ echo "ERROR: Bad JIRA issue format."
+ usage
+ fi
+}
+
+verifyparams "$@"
+
+trap cleanup INT QUIT TRAP ABRT BUS SEGV TERM ERR
+
+set -x
+
+git clean -xdf
+git checkout --force main
+git fetch origin
+git rebase origin/main
+
+docker run -i \
+ -v "${PWD}:/src" \
+ -u "${USER_ID}" \
+ "apache/yetus:main" \
+ ./update-homebrew.sh "${VERSION}"
+
+git commit -a -S -m "${JIRAISSUE}. Release ${VERSION}"
diff --git a/update-homebrew.sh b/update-homebrew.sh
new file mode 100755
index 0000000..0cf2038
--- /dev/null
+++ b/update-homebrew.sh
@@ -0,0 +1,76 @@
+#!/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.
+
+# SHELLDOC-IGNORE
+
+this="${BASH_SOURCE-$0}"
+thisdir=$(cd -P -- "$(dirname -- "${this}")" >/dev/null && pwd -P)
+
+pushd "${thisdir}" >/dev/null || exit 1
+
+
+if [[ ! -d Formula ]]; then
+ echo "ERROR: Confused about directory structure."
+ exit 1
+fi
+
+VERSION=$1
+
+if [[ -z "${VERSION}" ]]; then
+ echo "ERROR: need a version"
+ exit 1
+fi
+
+newfile=/tmp/versionsedit.$$
+
+sed -E -i "s,[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+,${VERSION},g" Formula/yetus.rb
+
+URL=$(awk '/url/ {print $NF}' Formula/yetus.rb)
+URL=${URL//\"/}
+
+curl --location --fail --output "/tmp/yetus-binary.tgz" "${URL}"
+
+
+if ! tar tzf /tmp/yetus-binary.tgz >/dev/null; then
+ echo "ERROR: Failed to download a tgz file from ${URL}"
+ exit 1
+fi
+
+SHA256=$(sha256sum /tmp/yetus-binary.tgz)
+SHA256=${SHA256%% *}
+
+rm /tmp/yetus-binary.tgz
+
+echo "Got SHA256: ${SHA256}"
+
+## NOTE: $REPLY, the default for read, is used
+## here because it will maintain any leading spaces!
+## if read is given a variable, then IFS manipulation
+## will be required!
+
+while read -r; do
+ if [[ "${REPLY}" =~ sha256 ]]; then
+ echo " sha256 \"${SHA256}\"" >> "${newfile}"
+ else
+ echo "${REPLY}" >> "${newfile}"
+ fi
+done < Formula/yetus.rb
+
+mv "${newfile}" Formula/yetus.rb
+
+
+