diff --git a/contrib/source-control-tools/automated-commits.sh b/contrib/source-control-tools/automated-commits.sh index dc1f824e5..e0741ecbc 100755 --- a/contrib/source-control-tools/automated-commits.sh +++ b/contrib/source-control-tools/automated-commits.sh @@ -1,132 +1,86 @@ #!/usr/bin/env bash # Note: Any bot running this script must have the appropriate permissions to # push commits upstream. When running locally, this script will git push in a # dry run by default. export LC_ALL=C.UTF-8 set -euxo pipefail help_message() { cat < "${RELEASE_NOTES_FILE}" - - git add "${RELEASE_NOTES_FILE}" "${RELEASE_NOTES_ARCHIVE}" - git commit -m "${BOT_PREFIX} Archive release notes for version ${RELEASE_NOTES_VERSION}" - ;; - - *) - if [ -z "${SCRIPT}" ]; then - echo "Error: Invalid commit name '${COMMIT_TYPE}'" - exit 10 - fi - - if [ ! -f "${SCRIPT}" ]; then - echo "Error: '${SCRIPT}' does not exist" - exit 10 - fi +if [ ! -f "${SCRIPT}" ]; then + echo "Error: '${SCRIPT}' does not exist" + exit 10 +fi - "${SCRIPT}" "${SCRIPT_ARGS[@]}" - ;; -esac +"${SCRIPT}" "${SCRIPT_ARGS[@]}" # Bail early if there's nothing to land if [ "$(git rev-parse HEAD)" == "${OLD_HEAD}" ]; then echo "No new changes. Nothing to do." exit 0 fi # Land the generated commit "${TOPLEVEL}"/contrib/source-control-tools/land-patch.sh "${LAND_PATCH_ARGS[@]}" diff --git a/contrib/source-control-tools/patch-recipes/archive-release-notes.sh b/contrib/source-control-tools/patch-recipes/archive-release-notes.sh new file mode 100755 index 000000000..7299221c9 --- /dev/null +++ b/contrib/source-control-tools/patch-recipes/archive-release-notes.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +export LC_ALL=C.UTF-8 + +set -euxo pipefail + +TOPLEVEL=$(git rev-parse --show-toplevel) + +# shellcheck source=../../utils/compare-version.sh +source "${TOPLEVEL}"/contrib/utils/compare-version.sh +RELEASE_NOTES_FILE="${TOPLEVEL}/doc/release-notes.md" +RELEASE_NOTES_VERSION=$(sed -n "1s/^Bitcoin ABC version \([0-9]\+\.[0-9]\+\.[0-9]\+\).\+$/\1/p" "${RELEASE_NOTES_FILE}") +RELEASE_NOTES_ARCHIVE="${TOPLEVEL}/doc/release-notes/release-notes-${RELEASE_NOTES_VERSION}.md" + +CURRENT_VERSION="" +get_current_version CURRENT_VERSION + +# Compare the versions. We only want to archive the release notes if the +# current version is greater the our release notes version. +if version_less_equal "${CURRENT_VERSION}" "${RELEASE_NOTES_VERSION}" +then + echo "Current version ${CURRENT_VERSION} <= release-notes version ${RELEASE_NOTES_VERSION}, skip the update" + exit 0 +fi + +# Archive the release notes +cp "${RELEASE_NOTES_FILE}" "${RELEASE_NOTES_ARCHIVE}" + +# Generate a fresh blank release notes file for the new version +PROJECT_VERSION="${CURRENT_VERSION}" envsubst < "${TOPLEVEL}/doc/release-notes/release-notes.md.in" > "${RELEASE_NOTES_FILE}" + +git add "${RELEASE_NOTES_FILE}" "${RELEASE_NOTES_ARCHIVE}" +git commit -m "[Automated] Archive release notes for version ${RELEASE_NOTES_VERSION}"