From 0460ec8b695624ae327b105af137648ad09db903 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Fri, 27 Oct 2023 01:47:14 +0300 Subject: [PATCH 1/5] feat: Set client version based on git tags when building non-release version --- configure.ac | 4 ++-- doc/release-process.md | 3 +-- share/genbuild.sh | 20 +++++--------------- src/clientversion.cpp | 25 +++++++++++++------------ 4 files changed, 21 insertions(+), 31 deletions(-) diff --git a/configure.ac b/configure.ac index 2f27a2aadc8b..ca6996e81a65 100644 --- a/configure.ac +++ b/configure.ac @@ -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, 1) define(_CLIENT_VERSION_BUILD, 0) -define(_CLIENT_VERSION_RC, 0) 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]) diff --git a/doc/release-process.md b/doc/release-process.md index 5df613449bc1..10c12d3ac6b0 100644 --- a/doc/release-process.md +++ b/doc/release-process.md @@ -3,13 +3,12 @@ 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 DIPs with any changes introduced by this release (see [this pull request](https://github.com/dashpay/dips/pull/142) for an example) -* [ ] 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. diff --git a/share/genbuild.sh b/share/genbuild.sh index 4da97dce0149..1de8039e291b 100755 --- a/share/genbuild.sh +++ b/share/genbuild.sh @@ -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 diff --git a/src/clientversion.cpp b/src/clientversion.cpp index 35d02d4873fe..8a8921ae4610 100644 --- a/src/clientversion.cpp +++ b/src/clientversion.cpp @@ -19,25 +19,26 @@ const std::string CLIENT_NAME("Dash Core"); #include // The , 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 ARCHIVE_GIT_DESCRIPTION ..." on the next line inside archives. $Format:%n#define ARCHIVE_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(ARCHIVE_GIT_DESCRIPTION) + // build in a folder from git archive + #define BUILD_DESC ARCHIVE_GIT_DESCRIPTION + #define BUILD_SUFFIX "-gitarc" #else + #define BUILD_DESC "v" PACKAGE_VERSION #define BUILD_SUFFIX "-unk" #endif #endif From 247856cd5856a4cf4350880a6a6735402b5bdc20 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Fri, 27 Oct 2023 22:49:27 +0300 Subject: [PATCH 2/5] feat: Set version in guix based on git tags only --- contrib/guix/libexec/codesign.sh | 8 ++------ contrib/shell/git-utils.bash | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/contrib/guix/libexec/codesign.sh b/contrib/guix/libexec/codesign.sh index 59df8e87fac2..137dbe442759 100755 --- a/contrib/guix/libexec/codesign.sh +++ b/contrib/guix/libexec/codesign.sh @@ -38,12 +38,8 @@ ACTUAL_OUTDIR="${OUTDIR}" OUTDIR="${DISTSRC}/output" git_head_version() { - local recent_tag - if recent_tag="$(git -C "$1" describe --exact-match HEAD 2> /dev/null)"; then - echo "${recent_tag#v}" - else - git -C "$1" rev-parse --short=12 HEAD - fi + recent_tag="$(git -C "$1" describe --abbrev=12 --dirty 2> /dev/null)" + echo "${recent_tag#v}" } CODESIGNATURE_GIT_ARCHIVE="${DIST_ARCHIVE_BASE}/${DISTNAME}-codesignatures-$(git_head_version "$DETACHED_SIGS_REPO").tar.gz" diff --git a/contrib/shell/git-utils.bash b/contrib/shell/git-utils.bash index 37bac1f38d8f..1371c3df70c0 100644 --- a/contrib/shell/git-utils.bash +++ b/contrib/shell/git-utils.bash @@ -5,10 +5,6 @@ git_root() { } git_head_version() { - local recent_tag - if recent_tag="$(git describe --exact-match HEAD 2> /dev/null)"; then - echo "${recent_tag#v}" - else - git rev-parse --short=12 HEAD - fi + recent_tag="$(git describe --abbrev=12 --dirty 2> /dev/null)" + echo "${recent_tag#v}" } From fc97a2eafd558d60fc24e22122437bf26d0a9487 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Thu, 16 Nov 2023 16:55:08 +0300 Subject: [PATCH 3/5] fix: drop `dev` and `gitarc` suffixes --- src/clientversion.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/clientversion.cpp b/src/clientversion.cpp index 8a8921ae4610..6fdd302b1eb6 100644 --- a/src/clientversion.cpp +++ b/src/clientversion.cpp @@ -32,11 +32,11 @@ const std::string CLIENT_NAME("Dash Core"); #if defined(BUILD_GIT_DESCRIPTION) // build in a cloned folder #define BUILD_DESC BUILD_GIT_DESCRIPTION - #define BUILD_SUFFIX "-dev" + #define BUILD_SUFFIX "" #elif defined(ARCHIVE_GIT_DESCRIPTION) // build in a folder from git archive #define BUILD_DESC ARCHIVE_GIT_DESCRIPTION - #define BUILD_SUFFIX "-gitarc" + #define BUILD_SUFFIX "" #else #define BUILD_DESC "v" PACKAGE_VERSION #define BUILD_SUFFIX "-unk" From 09c4d296f51a31e00a845fc1e39aa30bff5c13bf Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Sun, 24 Dec 2023 17:08:41 +0300 Subject: [PATCH 4/5] fix: fetch all history on checkout --- .github/workflows/guix-build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/guix-build.yml b/.github/workflows/guix-build.yml index 9b91fb2beacd..dbdaddcb37e8 100644 --- a/.github/workflows/guix-build.yml +++ b/.github/workflows/guix-build.yml @@ -16,6 +16,7 @@ jobs: with: ref: ${{ github.event.pull_request.head.sha }} path: dash + fetch-depth: 0 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 From d0b3e2509224b5eb59b23495ec18eef2bf95c59b Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Sun, 24 Dec 2023 21:38:51 +0300 Subject: [PATCH 5/5] fix: use variables set via `prelude.bash` in `guix-check` to make sure it's aligned with scripts in `contrib/guix` --- contrib/containers/guix/scripts/guix-check | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/contrib/containers/guix/scripts/guix-check b/contrib/containers/guix/scripts/guix-check index e16891bc72a2..7111f63c5b02 100755 --- a/contrib/containers/guix/scripts/guix-check +++ b/contrib/containers/guix/scripts/guix-check @@ -14,15 +14,16 @@ if [[ ! -d "$WORKSPACE_PATH" ]]; then fi cd "$WORKSPACE_PATH" -COMMIT_ID="$(git rev-parse --short=12 HEAD)" + +source "contrib/guix/libexec/prelude.bash" printf "\nBinaries:\n\n" ( \ -SRC_PATH_PREFIX="guix-build-${COMMIT_ID}/distsrc-" && \ +SRC_PATH_PREFIX="${VERSION_BASE}/distsrc-" && \ sha256sum ${SRC_PATH_PREFIX}*/src/dash{d,-cli,-tx,-wallet}{,.exe} && \ sha256sum ${SRC_PATH_PREFIX}*/src/qt/dash-qt{,.exe} && \ sha256sum ${SRC_PATH_PREFIX}*/src/test/test_dash{,.exe} \ ) | sort -k 2 printf "\nArchives:\n\n" -find "guix-build-${COMMIT_ID}/output" -type f | grep -v SHA256 | xargs sha256sum | sort -k 2 +find "${OUTDIR_BASE}" -type f | grep -v SHA256 | xargs sha256sum | sort -k 2