Skip to content

Commit f72650d

Browse files
authored
feat: Set client version for non-release binaries and version in guix based on git tags (dashpay#5653)
## Issue being fixed or feature implemented Client version string is inconsistent. Building `v20.0.0-beta.8` tag locally produces binaries that report `v20.0.0-beta.8` version but binaries built in guix would report `v20.0.0rc1-g3e732a952226a20505f907e4fd9b3fdbb14ea5ee` instead. Building any commit after `v20.0.0-beta.8` locally would result in versions like `v20.0.0rc1-8c94153d2497` which is close but it's still yet another format. And both versions with `rc1` in their names are confusing cause you'd expect them to mention `beta.8` instead maybe (or is it just me? :D ). ## What was done? Change it so that the version string would look like this: on tag: ~`v20.0.0-beta.8-dev` or `v20.0.0-beta.8-gitarc`~ `v20.0.0-beta.8` post-tag: ~`v20.0.0-beta.8-1-gb837e08164-gitarc`~ `v20.0.0-beta.8-1-gb837e08164` post-tag format is `recent tag`-`commits since that tag`-`g+12 chars of commit hash`-`dirty (optional)` ~-`dev or gitarc`~ ~`dev`/`gitarc` suffixes should help avoiding confusion with the release versions and they also indicate the way non-release binaries were built.~ Note that release binaries do not use any of this, they still use `PACKAGE_VERSION` from `configure` like before. Also, `CLIENT_VERSION_RC` is no longer used in this setup so it was removed. Few things aren't clear to me yet: 1. Version bump in `configure.ac` no longer affects the reported version (unless it's an actual release). Are there any downsides I might be missing? 2. Which tag should we use on `develop` once we bump version in configure? `v21.0.0-init`? `v21.0.0-alpha1`? 3. How is it going to behave once `merge master back into develop` kind of PR is merged? E.g. say `develop` branch is on `v21.0.0-alpha1` tag and we merge v20.1.0 from `master` back into it. Will this bring `v20.1.0` release tag into `develop`? Will it become the one that will be used from that moment? If so we will probably need another tag on `develop` every time such PR is merged e.g. `v21.0.0-alpha2` (or whatever the next number is). Don't think these are blockers but would like to hear thoughts from others. ## How Has This Been Tested? Built binaries locally, built them using guix at a specific tag and at some commit on top of it. ## Breaking Changes n/a ## Checklist: - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_
1 parent ca77d06 commit f72650d

File tree

8 files changed

+29
-45
lines changed

8 files changed

+29
-45
lines changed

.github/workflows/guix-build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
with:
1717
ref: ${{ github.event.pull_request.head.sha }}
1818
path: dash
19+
fetch-depth: 0
1920

2021
- name: Set up Docker Buildx
2122
uses: docker/setup-buildx-action@v3

configure.ac

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
AC_PREREQ([2.69])
2+
dnl Don't forget to push a corresponding tag when updating any of _CLIENT_VERSION_* numbers
23
define(_CLIENT_VERSION_MAJOR, 20)
34
define(_CLIENT_VERSION_MINOR, 1)
45
define(_CLIENT_VERSION_BUILD, 0)
5-
define(_CLIENT_VERSION_RC, 0)
66
define(_CLIENT_VERSION_IS_RELEASE, false)
77
define(_COPYRIGHT_YEAR, 2023)
88
define(_COPYRIGHT_HOLDERS,[The %s developers])
99
define(_COPYRIGHT_HOLDERS_SUBSTITUTION,[[Dash Core]])
10-
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/])
10+
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/])
1111
AC_CONFIG_SRCDIR([src/validation.cpp])
1212
AC_CONFIG_HEADERS([src/config/bitcoin-config.h])
1313
AC_CONFIG_AUX_DIR([build-aux])

contrib/containers/guix/scripts/guix-check

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@ if [[ ! -d "$WORKSPACE_PATH" ]]; then
1414
fi
1515

1616
cd "$WORKSPACE_PATH"
17-
COMMIT_ID="$(git rev-parse --short=12 HEAD)"
17+
18+
source "contrib/guix/libexec/prelude.bash"
1819

1920
printf "\nBinaries:\n\n"
2021
( \
21-
SRC_PATH_PREFIX="guix-build-${COMMIT_ID}/distsrc-" && \
22+
SRC_PATH_PREFIX="${VERSION_BASE}/distsrc-" && \
2223
sha256sum ${SRC_PATH_PREFIX}*/src/dash{d,-cli,-tx,-wallet}{,.exe} && \
2324
sha256sum ${SRC_PATH_PREFIX}*/src/qt/dash-qt{,.exe} && \
2425
sha256sum ${SRC_PATH_PREFIX}*/src/test/test_dash{,.exe} \
2526
) | sort -k 2
2627

2728
printf "\nArchives:\n\n"
28-
find "guix-build-${COMMIT_ID}/output" -type f | grep -v SHA256 | xargs sha256sum | sort -k 2
29+
find "${OUTDIR_BASE}" -type f | grep -v SHA256 | xargs sha256sum | sort -k 2

contrib/guix/libexec/codesign.sh

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,8 @@ ACTUAL_OUTDIR="${OUTDIR}"
3838
OUTDIR="${DISTSRC}/output"
3939

4040
git_head_version() {
41-
local recent_tag
42-
if recent_tag="$(git -C "$1" describe --exact-match HEAD 2> /dev/null)"; then
43-
echo "${recent_tag#v}"
44-
else
45-
git -C "$1" rev-parse --short=12 HEAD
46-
fi
41+
recent_tag="$(git -C "$1" describe --abbrev=12 --dirty 2> /dev/null)"
42+
echo "${recent_tag#v}"
4743
}
4844

4945
CODESIGNATURE_GIT_ARCHIVE="${DIST_ARCHIVE_BASE}/${DISTNAME}-codesignatures-$(git_head_version "$DETACHED_SIGS_REPO").tar.gz"

contrib/shell/git-utils.bash

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ git_root() {
55
}
66

77
git_head_version() {
8-
local recent_tag
9-
if recent_tag="$(git describe --exact-match HEAD 2> /dev/null)"; then
10-
echo "${recent_tag#v}"
11-
else
12-
git rev-parse --short=12 HEAD
13-
fi
8+
recent_tag="$(git describe --abbrev=12 --dirty 2> /dev/null)"
9+
echo "${recent_tag#v}"
1410
}

doc/release-process.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ Release Process
33

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

87
Before every minor and major release:
98

109
* [ ] Update [bips.md](bips.md) to account for changes since the last release.
1110
* [ ] Update DIPs with any changes introduced by this release (see [this pull request](https://github.com/dashpay/dips/pull/142) for an example)
12-
* [ ] 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`)
11+
* [ ] Update version in `configure.ac` (don't forget to set `CLIENT_VERSION_IS_RELEASE` to `true`)
1312
* [ ] Write release notes (see below)
1413
* [ ] Update `src/chainparams.cpp` `nMinimumChainWork` with information from the `getblockchaininfo` rpc.
1514
* [ ] Update `src/chainparams.cpp` `defaultAssumeValid` with information from the `getblockhash` rpc.

share/genbuild.sh

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,17 @@ else
1818
exit 1
1919
fi
2020

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

27-
# if latest commit is tagged and not dirty, then override using the tag name
28-
RAWDESC=$(git describe --abbrev=0 2>/dev/null)
29-
if [ "$(git rev-parse HEAD)" = "$(git rev-list -1 $RAWDESC 2>/dev/null)" ]; then
30-
git diff-index --quiet HEAD -- && GIT_TAG=$RAWDESC
31-
fi
32-
33-
# otherwise generate suffix from git, i.e. string like "59887e8-dirty"
34-
GIT_COMMIT=$(git rev-parse --short=12 HEAD)
35-
git diff-index --quiet HEAD -- || GIT_COMMIT="$GIT_COMMIT-dirty"
26+
# override using the tag name from git, i.e. string like "v20.0.0-beta.8-5-g99786590df6f-dirty"
27+
GIT_DESCRIPTION=$(git describe --abbrev=12 --dirty 2>/dev/null)
3628
fi
3729

38-
if [ -n "$GIT_TAG" ]; then
39-
NEWINFO="#define BUILD_GIT_TAG \"$GIT_TAG\""
40-
elif [ -n "$GIT_COMMIT" ]; then
41-
NEWINFO="#define BUILD_GIT_COMMIT \"$GIT_COMMIT\""
30+
if [ -n "$GIT_DESCRIPTION" ]; then
31+
NEWINFO="#define BUILD_GIT_DESCRIPTION \"$GIT_DESCRIPTION\""
4232
else
4333
NEWINFO="// No build information available"
4434
fi

src/clientversion.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,26 @@ const std::string CLIENT_NAME("Dash Core");
1919
#include <obj/build.h>
2020
// The <obj/build.h>, which is generated by the build environment (share/genbuild.sh),
2121
// could contain only one line of the following:
22-
// - "#define BUILD_GIT_TAG ...", if the top commit is tagged
23-
// - "#define BUILD_GIT_COMMIT ...", if the top commit is not tagged
22+
// - "#define BUILD_GIT_DESCRIPTION ...", if the top commit is not tagged
2423
// - "// No build information available", if proper git information is not available
2524
#endif
2625

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

29-
#ifdef BUILD_GIT_TAG
30-
#define BUILD_DESC BUILD_GIT_TAG
28+
#if CLIENT_VERSION_IS_RELEASE
29+
#define BUILD_DESC "v" PACKAGE_VERSION
3130
#define BUILD_SUFFIX ""
3231
#else
33-
#define BUILD_DESC "v" PACKAGE_VERSION
34-
#if CLIENT_VERSION_IS_RELEASE
32+
#if defined(BUILD_GIT_DESCRIPTION)
33+
// build in a cloned folder
34+
#define BUILD_DESC BUILD_GIT_DESCRIPTION
35+
#define BUILD_SUFFIX ""
36+
#elif defined(ARCHIVE_GIT_DESCRIPTION)
37+
// build in a folder from git archive
38+
#define BUILD_DESC ARCHIVE_GIT_DESCRIPTION
3539
#define BUILD_SUFFIX ""
36-
#elif defined(BUILD_GIT_COMMIT)
37-
#define BUILD_SUFFIX "-" BUILD_GIT_COMMIT
38-
#elif defined(GIT_COMMIT_ID)
39-
#define BUILD_SUFFIX "-g" GIT_COMMIT_ID
4040
#else
41+
#define BUILD_DESC "v" PACKAGE_VERSION
4142
#define BUILD_SUFFIX "-unk"
4243
#endif
4344
#endif

0 commit comments

Comments
 (0)