Changeset View
Changeset View
Standalone View
Standalone View
contrib/devtools/update-version.sh
- This file was added.
Property | Old Value | New Value |
---|---|---|
File Mode | null | 100755 |
#!/usr/bin/env bash | |||||
export LC_ALL=C | |||||
set -euo pipefail | |||||
TOPLEVEL="$(git rev-parse --show-toplevel)" | |||||
help_message() { | |||||
echo "Update the version number of the node software." | |||||
echo "Usage: $0 <options>" | |||||
echo "-v, --version The new version number to use. Increments revision if not specified." | |||||
} | |||||
VERSION="" | |||||
# Parse command line arguments | |||||
while [[ $# -gt 0 ]]; do | |||||
case $1 in | |||||
-v|--version) | |||||
VERSION="$2" | |||||
shift # shift past argument | |||||
shift # shift past value | |||||
;; | |||||
*) | |||||
echo "Unknown argument: $1" | |||||
help_message | |||||
exit 1 | |||||
;; | |||||
esac | |||||
done | |||||
CURRENT_VERSION=$(grep -A5 "project.*bitcoin-abc" "${TOPLEVEL}/CMakeLists.txt" | grep "VERSION" | grep -oE "[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+") || { | |||||
echo "Error parsing current version number." | |||||
exit 2 | |||||
} | |||||
if [ -z "${VERSION}" ]; then | |||||
MAJOR=$(echo "${CURRENT_VERSION}" | cut -d'.' -f1 ) | |||||
MINOR=$(echo "${CURRENT_VERSION}" | cut -d'.' -f2 ) | |||||
REVISION=$(echo "${CURRENT_VERSION}" | cut -d'.' -f3 ) | |||||
REVISION=$((REVISION + 1)) | |||||
else | |||||
MAJOR=$(echo "${VERSION}" | cut -d'.' -f1 ) | |||||
MINOR=$(echo "${VERSION}" | cut -d'.' -f2 ) | |||||
REVISION=$(echo "${VERSION}" | cut -d'.' -f3 ) | |||||
fi | |||||
VERSION="${MAJOR}.${MINOR}.${REVISION}" | |||||
# release-notes*.md | |||||
RELEASE_NOTES="${TOPLEVEL}/doc/release-notes.md" | |||||
mv "${RELEASE_NOTES}" "${TOPLEVEL}/doc/release-notes/release-notes-${CURRENT_VERSION}.md" | |||||
echo "Bitcoin ABC version ${VERSION} is now available from: | |||||
<https://download.bitcoinabc.org/${VERSION}/> | |||||
This release includes the following features and fixes:" > "${RELEASE_NOTES}" | |||||
# CMakeLists | |||||
sed -i '$!N;s/\(bitcoin-abc\n\)\(\s*VERSION\s*\).*/\1\2'"${VERSION}"'/;P;D' "${TOPLEVEL}/CMakeLists.txt" | |||||
jasonbcox: For those not experienced with sed, this pattern is used to capture the VERSION line after the… | |||||
# configure.ac | |||||
CONFIGURE_AC="${TOPLEVEL}/configure.ac" | |||||
sed -i "/define(_CLIENT_VERSION_MAJOR, /c\define(_CLIENT_VERSION_MAJOR, $MAJOR)" "${CONFIGURE_AC}" | |||||
sed -i "/define(_CLIENT_VERSION_MINOR, /c\define(_CLIENT_VERSION_MINOR, $MINOR)" "${CONFIGURE_AC}" | |||||
sed -i "/define(_CLIENT_VERSION_REVISION, /c\define(_CLIENT_VERSION_REVISION, $REVISION)" "${CONFIGURE_AC}" | |||||
# gitian descriptors | |||||
sed -i "2s/.*/name: \"bitcoin-abc-${MAJOR}.${MINOR}-win\"/" "${TOPLEVEL}/contrib/gitian-descriptors/gitian-win.yml" | |||||
sed -i "2s/.*/name: \"bitcoin-abc-${MAJOR}.${MINOR}-linux\"/" "${TOPLEVEL}/contrib/gitian-descriptors/gitian-linux.yml" | |||||
sed -i "2s/.*/name: \"bitcoin-abc-${MAJOR}.${MINOR}-osx\"/" "${TOPLEVEL}/contrib/gitian-descriptors/gitian-osx.yml" | |||||
jasonbcoxAuthorUnsubmitted Done Inline ActionsSome parts of this script were backported/inspired by https://github.com/bitcoin-core/bitcoin-maintainer-tools/blob/master/release-prep.sh jasonbcox: Some parts of this script were backported/inspired by https://github.com/bitcoin-core/bitcoin… |
For those not experienced with sed, this pattern is used to capture the VERSION line after the line with project(bitcoin-abc. See https://unix.stackexchange.com/questions/285160/how-to-edit-next-line-after-pattern-using-sed for another example.
This isn't the most robust compared to the other sed calls, but I do not expect this part of our CMakeLists.txt to change format often.