CICD: Use correct version information on pull request builds.

Use the version information detected in the manage-version action, as
the actual build is happening in the speculative post-merge branch,
resulting in a bogus 'commit distance' number.

Signed-off-by: Michael Keller <github@ike.ch>
This commit is contained in:
Michael Keller 2024-07-31 00:05:43 +12:00
parent 2b7900b68d
commit df4358d252
3 changed files with 24 additions and 3 deletions

View file

@ -12,6 +12,9 @@ outputs:
version:
description: The long form version number
value: ${{ steps.version_number.outputs.version }}
version_4:
description: The 4 part version number
value: ${{ steps.version_number.outputs.version_4 }}
buildnr:
description: The build number
value: ${{ steps.version_number.outputs.buildnr }}
@ -51,6 +54,8 @@ runs:
git checkout $PULL_REQUEST_HEAD_SHA
version=$(scripts/get-version.sh)
echo "version=$version" >> $GITHUB_OUTPUT
version_4=$(scripts/get-version.sh 4)
echo "version_4=$version_4" >> $GITHUB_OUTPUT
buildnr=$(scripts/get-version.sh 1)
echo "buildnr=$buildnr" >> $GITHUB_OUTPUT
git checkout $GITHUB_SHA

View file

@ -46,6 +46,8 @@ jobs:
KEYSTORE_PASSWORD: pass:${{ secrets.ANDROID_KEYSTORE_PASSWORD }}
KEYSTORE_ALIAS: ${{ secrets.ANDROID_KEYSTORE_ALIAS }}
BUILDNR: ${{ steps.version_number.outputs.buildnr }}
VERSION: ${{ steps.version_number.outputs.version }}
VERSION_4: ${{ steps.version_number.outputs.version_4 }}
run: |
# this is rather awkward, but it allows us to use the preinstalled
# Android and Qt versions with relative paths
@ -63,7 +65,7 @@ jobs:
git config --global --add safe.directory $GITHUB_WORKSPACE/libdivecomputer
# get the build number via curl so this works both for a pull request as well as a push
export OUTPUT_DIR="$GITHUB_WORKSPACE"
bash -x ./subsurface/packaging/android/qmake-build.sh -buildnr $BUILDNR
bash -x ./subsurface/packaging/android/qmake-build.sh -buildnr $BUILDNR -canonicalversion $VERSION -canonicalversion_4 $VERSION_4
- name: delete the keystore
if: github.event_name == 'push'

View file

@ -51,6 +51,16 @@ while [ "$#" -gt 0 ] ; do
BUILDNR=$1
shift
;;
-canonicalversion)
shift
CANONICALVERSION=$1
shift
;;
-canonicalversion_4)
shift
CANONICALVERSION_4=$1
shift
;;
-version)
# only update the version info without rebuilding
# this is useful when working with Xcode
@ -86,9 +96,13 @@ mkdir -p "$BUILDROOT"/subsurface-mobile-build
pushd "$BUILDROOT"/subsurface-mobile-build
# set up the Subsurface versions by hand
CANONICALVERSION=$("$SUBSURFACE_SOURCE"/scripts/get-version.sh)
if [ -z "${CANONICALVERSION+X}" ] ; then
CANONICALVERSION=$("$SUBSURFACE_SOURCE"/scripts/get-version.sh)
fi
echo "#define CANONICAL_VERSION_STRING \"$CANONICALVERSION\"" > ssrf-version.h
CANONICALVERSION_4=$("$SUBSURFACE_SOURCE"/scripts/get-version.sh 4)
if [ -z "${CANONICALVERSION_4+X}" ] ; then
CANONICALVERSION_4=$("$SUBSURFACE_SOURCE"/scripts/get-version.sh 4)
fi
echo "#define CANONICAL_VERSION_STRING_4 \"$CANONICALVERSION_4\"" >> ssrf-version.h
popd