Skip to content

Commit

Permalink
fix: Set client version based on git tags when building non-release v…
Browse files Browse the repository at this point in the history
…ersion
  • Loading branch information
UdjinM6 committed Oct 26, 2023
1 parent 3e732a9 commit 6c19abc
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 31 deletions.
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
AC_PREREQ([2.69])
dnl Don't forget to push a corresponding tag when updating any of _CLIENT_VERSION_* numbers
define(_CLIENT_VERSION_MAJOR, 20)
define(_CLIENT_VERSION_MINOR, 0)
define(_CLIENT_VERSION_BUILD, 0)
define(_CLIENT_VERSION_RC, 1)
define(_CLIENT_VERSION_IS_RELEASE, false)
define(_COPYRIGHT_YEAR, 2023)
define(_COPYRIGHT_HOLDERS,[The %s developers])
define(_COPYRIGHT_HOLDERS_SUBSTITUTION,[[Dash Core]])
AC_INIT([Dash Core],m4_join([.], _CLIENT_VERSION_MAJOR, _CLIENT_VERSION_MINOR, _CLIENT_VERSION_BUILD)m4_if(_CLIENT_VERSION_RC, [0], [], [rc]_CLIENT_VERSION_RC),[https://github.com/dashpay/dash/issues],[dashcore],[https://dash.org/])
AC_INIT([Dash Core],m4_join([.], _CLIENT_VERSION_MAJOR, _CLIENT_VERSION_MINOR, _CLIENT_VERSION_BUILD),[https://github.com/dashpay/dash/issues],[dashcore],[https://dash.org/])
AC_CONFIG_SRCDIR([src/validation.cpp])
AC_CONFIG_HEADERS([src/config/bitcoin-config.h])
AC_CONFIG_AUX_DIR([build-aux])
Expand Down
3 changes: 1 addition & 2 deletions doc/release-process.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ Release Process
* Update translations, see [translation_process.md](https://github.com/dashpay/dash/blob/master/doc/translation_process.md#synchronising-translations).

* Update manpages, see [gen-manpages.sh](https://github.com/dashpay/dash/blob/master/contrib/devtools/README.md#gen-manpagessh).
* Update release candidate version in `configure.ac` (`CLIENT_VERSION_RC`)

Before every minor and major release:

* Update [bips.md](bips.md) to account for changes since the last release.
* Update version in `configure.ac` (don't forget to set `CLIENT_VERSION_IS_RELEASE` to `true`) (don't forget to set `CLIENT_VERSION_RC` to `0`)
* Update version in `configure.ac` (don't forget to set `CLIENT_VERSION_IS_RELEASE` to `true`)
* Write release notes (see below)
* Update `src/chainparams.cpp` nMinimumChainWork with information from the getblockchaininfo rpc.
* Update `src/chainparams.cpp` defaultAssumeValid with information from the getblockhash rpc.
Expand Down
20 changes: 5 additions & 15 deletions share/genbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,17 @@ else
exit 1
fi

GIT_TAG=""
GIT_COMMIT=""
GIT_DESCRIPTION=""
if [ "${BITCOIN_GENBUILD_NO_GIT}" != "1" ] && [ -e "$(command -v git)" ] && [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]; then
# clean 'dirty' status of touched files that haven't been modified
git diff >/dev/null 2>/dev/null

# if latest commit is tagged and not dirty, then override using the tag name
RAWDESC=$(git describe --abbrev=0 2>/dev/null)
if [ "$(git rev-parse HEAD)" = "$(git rev-list -1 $RAWDESC 2>/dev/null)" ]; then
git diff-index --quiet HEAD -- && GIT_TAG=$RAWDESC
fi

# otherwise generate suffix from git, i.e. string like "59887e8-dirty"
GIT_COMMIT=$(git rev-parse --short=12 HEAD)
git diff-index --quiet HEAD -- || GIT_COMMIT="$GIT_COMMIT-dirty"
# override using the tag name from git, i.e. string like "v20.0.0-beta.8-5-g99786590df6f-dirty"
GIT_DESCRIPTION=$(git describe --abbrev=12 --dirty 2>/dev/null)
fi

if [ -n "$GIT_TAG" ]; then
NEWINFO="#define BUILD_GIT_TAG \"$GIT_TAG\""
elif [ -n "$GIT_COMMIT" ]; then
NEWINFO="#define BUILD_GIT_COMMIT \"$GIT_COMMIT\""
if [ -n "$GIT_DESCRIPTION" ]; then
NEWINFO="#define BUILD_GIT_DESCRIPTION \"$GIT_DESCRIPTION\""
else
NEWINFO="// No build information available"
fi
Expand Down
25 changes: 13 additions & 12 deletions src/clientversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,26 @@ const std::string CLIENT_NAME("Dash Core");
#include <obj/build.h>
// The <obj/build.h>, which is generated by the build environment (share/genbuild.sh),
// could contain only one line of the following:
// - "#define BUILD_GIT_TAG ...", if the top commit is tagged
// - "#define BUILD_GIT_COMMIT ...", if the top commit is not tagged
// - "#define BUILD_GIT_DESCRIPTION ...", if the top commit is not tagged
// - "// No build information available", if proper git information is not available
#endif

//! git will put "#define GIT_COMMIT_ID ..." on the next line inside archives. $Format:%n#define GIT_COMMIT_ID "%H"$
//! git will put "#define GIT_DESCRIPTION ..." on the next line inside archives. $Format:%n#define GIT_DESCRIPTION "%(describe:abbrev=12)"$

#ifdef BUILD_GIT_TAG
#define BUILD_DESC BUILD_GIT_TAG
#if CLIENT_VERSION_IS_RELEASE
#define BUILD_DESC "v" PACKAGE_VERSION
#define BUILD_SUFFIX ""
#else
#define BUILD_DESC "v" PACKAGE_VERSION
#if CLIENT_VERSION_IS_RELEASE
#define BUILD_SUFFIX ""
#elif defined(BUILD_GIT_COMMIT)
#define BUILD_SUFFIX "-" BUILD_GIT_COMMIT
#elif defined(GIT_COMMIT_ID)
#define BUILD_SUFFIX "-g" GIT_COMMIT_ID
#if defined(BUILD_GIT_DESCRIPTION)
// build in a cloned folder
#define BUILD_DESC BUILD_GIT_DESCRIPTION
#define BUILD_SUFFIX "-dev"
#elif defined(GIT_DESCRIPTION)
// build in a folder from git archive
#define BUILD_DESC GIT_DESCRIPTION
#define BUILD_SUFFIX "-arc"
#else
#define BUILD_DESC "v" PACKAGE_VERSION
#define BUILD_SUFFIX "-unk"
#endif
#endif
Expand Down

0 comments on commit 6c19abc

Please sign in to comment.