mirror of
https://github.com/XRPLF/rippled.git
synced 2026-02-07 23:42:28 +00:00
Conan recipes use semantic versioning, and since our version already contains a hyphen the second hyphen causes Conan to ignore it. The plus sign is a valid separator we can use instead, so this change uses a `+` to separate a version suffix (commit hash) instead of a `-`.
45 lines
1.5 KiB
YAML
45 lines
1.5 KiB
YAML
name: Generate build version number
|
|
description: "Generate build version number."
|
|
|
|
outputs:
|
|
version:
|
|
description: "The generated build version number."
|
|
value: ${{ steps.version.outputs.version }}
|
|
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
# When a tag is pushed, the version is used as-is.
|
|
- name: Generate version for tag event
|
|
if: ${{ github.event_name == 'tag' }}
|
|
shell: bash
|
|
env:
|
|
VERSION: ${{ github.ref_name }}
|
|
run: echo "VERSION=${VERSION}" >> "${GITHUB_ENV}"
|
|
|
|
# When a tag is not pushed, then the version (e.g. 1.2.3-b0) is extracted
|
|
# from the BuildInfo.cpp file and the shortened commit hash appended to it.
|
|
# We use a plus sign instead of a hyphen because Conan recipe versions do
|
|
# not support two hyphens.
|
|
- name: Generate version for non-tag event
|
|
if: ${{ github.event_name != 'tag' }}
|
|
shell: bash
|
|
run: |
|
|
echo 'Extracting version from BuildInfo.cpp.'
|
|
VERSION="$(cat src/libxrpl/protocol/BuildInfo.cpp | grep "versionString =" | awk -F '"' '{print $2}')"
|
|
if [[ -z "${VERSION}" ]]; then
|
|
echo 'Unable to extract version from BuildInfo.cpp.'
|
|
exit 1
|
|
fi
|
|
|
|
echo 'Appending shortened commit hash to version.'
|
|
SHA='${{ github.sha }}'
|
|
VERSION="${VERSION}+${SHA:0:7}"
|
|
|
|
echo "VERSION=${VERSION}" >> "${GITHUB_ENV}"
|
|
|
|
- name: Output version
|
|
id: version
|
|
shell: bash
|
|
run: echo "version=${VERSION}" >> "${GITHUB_OUTPUT}"
|