Complete redesign of Subsurface version numbers

- for now all versions start with v6.0
- CICD builds use the monolithic build number as patch level, e.g. v6.0.12345
- local builds use the following algorithm
  - find the newest commit with a CICD build number that is included in the
    working tree
  - count the number of commits in the working tree since that commit
  - if there are no commits since the last CICD build, the local build version
    will be v6.0.12345-local
  - if there are N commits since the last CICD build, it will be
    v6.0.12345-N-local
- test builds in the CICD that don't create artifacts simply use a dummy release
  in order to not incorrectly increment the build number and also not to waste
  time and resources by manually checking out the nightly-build repo for each of
  these builds.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2024-01-04 20:44:31 -08:00
parent 8a2dd8db74
commit 62477d8c65
24 changed files with 295 additions and 126 deletions

View file

@ -18,7 +18,7 @@ jobs:
uses: actions/checkout@v1 uses: actions/checkout@v1
- name: atomically create or retrieve the build number - name: atomically create or retrieve the build number
id: build_nr id: version_number
if: github.event_name == 'push' if: github.event_name == 'push'
run: | run: |
cd .. # check out parallel to subsurface sources cd .. # check out parallel to subsurface sources
@ -31,6 +31,16 @@ jobs:
git push origin main git push origin main
cd .. cd ..
bash -x subsurface/scripts/get-or-create-build-nr.sh ${{ github.sha }} bash -x subsurface/scripts/get-or-create-build-nr.sh ${{ github.sha }}
cp nightly-builds/latest-subsurface-buildnumber subsurface
echo "CICD-release" > subsurface/latest-subsurface-buildnumber-extension
version=$(bash subsurface/scripts/get-version)
echo "version=$version" >> $GITHUB_OUTPUT
- name: store dummy version and build number for pull request
if: github.event_name == 'pull_request'
run: |
echo "100" > latest-subsurface-buildnumber
echo "CICD-pull-request" > latest-subsurface-buildnumber-extension
- name: run build - name: run build
id: build id: build
@ -59,15 +69,6 @@ jobs:
curl -q https://raw.githubusercontent.com/subsurface/nightly-builds/main/latest-subsurface-buildnumber > buildnr.dat curl -q https://raw.githubusercontent.com/subsurface/nightly-builds/main/latest-subsurface-buildnumber > buildnr.dat
OUTPUT_DIR=$GITHUB_WORKSPACE bash -x ./subsurface/packaging/android/qmake-build.sh OUTPUT_DIR=$GITHUB_WORKSPACE bash -x ./subsurface/packaging/android/qmake-build.sh
- name: create version number
id: version_number
if: github.event_name == 'push'
run: |
gitversion=$(bash scripts/get-version win)
latest=$(cat ../nightly-builds/latest-subsurface-buildnumber)
version="$gitversion-$latest"
echo "version=$version" >> $GITHUB_OUTPUT
# only publish a 'release' on push events (those include merging a PR) # only publish a 'release' on push events (those include merging a PR)
- name: upload binaries - name: upload binaries
if: github.event_name == 'push' if: github.event_name == 'push'

View file

@ -44,5 +44,5 @@ jobs:
email: glance@acc.umu.se email: glance@acc.umu.se
command: subsurface/scripts/build.sh -desktop -build-with-webkit command: subsurface/scripts/build.sh -desktop -build-with-webkit
working-directory: ${{ github.workspace }}/.. working-directory: ${{ github.workspace }}/..
version: $(/scripts/get-version linux) version: $(/scripts/get-version)
description: Automatic scan on github actions description: Automatic scan on github actions

View file

@ -15,6 +15,25 @@ jobs:
- name: Check out sources - name: Check out sources
uses: actions/checkout@v1 uses: actions/checkout@v1
- name: atomically create or retrieve the build number
id: version_number
if: github.event_name == 'push'
run: |
cd .. # check out parallel to subsurface sources
url="https://subsurface:${{ secrets.NIGHTLY_BUILDS }}@github.com/subsurface/nightly-builds"
# the clone followed by the pointless push should verify that the password is stored in the config
# that way the script doesn't need the password
git clone -b main https://github.com/subsurface/nightly-builds
cd nightly-builds
git remote set-url origin "$url"
git push origin main
cd ..
bash -x subsurface/scripts/get-or-create-build-nr.sh ${{ github.sha }}
cp nightly-builds/latest-subsurface-buildnumber subsurface
echo "CICD-release" > subsurface/latest-subsurface-buildnumber-extension
version=$(bash subsurface/scripts/get-version)
echo "version=$version" >> $GITHUB_OUTPUT
- name: Setup API token for copr-cli - name: Setup API token for copr-cli
env: env:
API_TOKEN: ${{ secrets.COPR_TOKEN }} API_TOKEN: ${{ secrets.COPR_TOKEN }}
@ -43,4 +62,4 @@ jobs:
run: | run: |
cd .. cd ..
bash -x subsurface/packaging/copr/make-package.sh post bash -x subsurface/packaging/copr/make-package.sh post

View file

@ -13,16 +13,25 @@ jobs:
steps: steps:
- name: switch to Xcode 11 - name: switch to Xcode 11
run: sudo xcode-select -s "/Applications/Xcode_11.7.app" run: sudo xcode-select -s "/Applications/Xcode_11.7.app"
- name: checkout sources - name: checkout sources
uses: actions/checkout@v1 uses: actions/checkout@v1
- name: setup Homebrew - name: setup Homebrew
run: brew install autoconf automake libtool pkg-config run: brew install autoconf automake libtool pkg-config
- name: set our Qt build - name: set our Qt build
run: | run: |
env env
curl -L --output Qt-5.14.1-ios.tar.xz https://f002.backblazeb2.com/file/Subsurface-Travis/Qt-5.14.1-ios.tar.xz curl -L --output Qt-5.14.1-ios.tar.xz https://f002.backblazeb2.com/file/Subsurface-Travis/Qt-5.14.1-ios.tar.xz
mkdir -p $HOME/Qt mkdir -p $HOME/Qt
xzcat Qt-5.14.1-ios.tar.xz | tar -x -C $HOME/Qt -f - xzcat Qt-5.14.1-ios.tar.xz | tar -x -C $HOME/Qt -f -
- name: store dummy version and build number for test build
run: |
echo "100" > latest-subsurface-buildnumber
echo "CICD-test-build" > latest-subsurface-buildnumber-extension
- name: build Subsurface-mobile for iOS - name: build Subsurface-mobile for iOS
env: env:
SUBSURFACE_REPO_PATH: ${{ github.workspace }} SUBSURFACE_REPO_PATH: ${{ github.workspace }}

View file

@ -31,6 +31,11 @@ jobs:
qtpositioning5-dev qtscript5-dev qttools5-dev qttools5-dev-tools \ qtpositioning5-dev qtscript5-dev qttools5-dev qttools5-dev-tools \
qtquickcontrols2-5-dev xvfb libbluetooth-dev libmtp-dev qtquickcontrols2-5-dev xvfb libbluetooth-dev libmtp-dev
- name: store dummy version and build number for pull request
if: github.event_name == 'pull_request'
run: |
echo "6.0.100" > latest-subsurface-buildnumber
- name: build Subsurface - name: build Subsurface
env: env:
SUBSURFACE_REPO_PATH: ${{ github.workspace }} SUBSURFACE_REPO_PATH: ${{ github.workspace }}

View file

@ -33,6 +33,11 @@ jobs:
bluez-libs-devel libgit2-devel libzip-devel libmtp-devel \ bluez-libs-devel libgit2-devel libzip-devel libmtp-devel \
xorg-x11-server-Xvfb xorg-x11-server-Xvfb
- name: store dummy version and build number for test build
run: |
echo "100" > latest-subsurface-buildnumber
echo "CICD-test-build" > latest-subsurface-buildnumber-extension
- name: build Subsurface - name: build Subsurface
env: env:
SUBSURFACE_REPO_PATH: ${{ github.workspace }} SUBSURFACE_REPO_PATH: ${{ github.workspace }}

View file

@ -35,6 +35,11 @@ jobs:
qtpositioning5-dev qtscript5-dev qttools5-dev qttools5-dev-tools \ qtpositioning5-dev qtscript5-dev qttools5-dev qttools5-dev-tools \
qtquickcontrols2-5-dev xvfb libbluetooth-dev libmtp-dev qtquickcontrols2-5-dev xvfb libbluetooth-dev libmtp-dev
- name: store dummy version and build number for test build
run: |
echo "100" > latest-subsurface-buildnumber
echo "CICD-test-build" > latest-subsurface-buildnumber-extension
- name: build Subsurface-mobile - name: build Subsurface-mobile
env: env:
SUBSURFACE_REPO_PATH: ${{ github.workspace }} SUBSURFACE_REPO_PATH: ${{ github.workspace }}

View file

@ -35,6 +35,11 @@ jobs:
qtpositioning5-dev qtscript5-dev qttools5-dev qttools5-dev-tools \ qtpositioning5-dev qtscript5-dev qttools5-dev qttools5-dev-tools \
qtquickcontrols2-5-dev xvfb libbluetooth-dev libmtp-dev qtquickcontrols2-5-dev xvfb libbluetooth-dev libmtp-dev
- name: store dummy version and build number for test build
run: |
echo "100" > latest-subsurface-buildnumber
echo "CICD-test-build" > latest-subsurface-buildnumber-extension
- name: build Subsurface-mobile - name: build Subsurface-mobile
env: env:
SUBSURFACE_REPO_PATH: ${{ github.workspace }} SUBSURFACE_REPO_PATH: ${{ github.workspace }}

View file

@ -20,6 +20,31 @@ jobs:
# Needed for version determination to work # Needed for version determination to work
fetch-depth: 0 fetch-depth: 0
- name: atomically create or retrieve the build number
id: version_number
if: github.event_name == 'push'
run: |
cd .. # check out parallel to subsurface sources
url="https://subsurface:${{ secrets.NIGHTLY_BUILDS }}@github.com/subsurface/nightly-builds"
# the clone followed by the pointless push should verify that the password is stored in the config
# that way the script doesn't need the password
git clone -b main https://github.com/subsurface/nightly-builds
cd nightly-builds
git remote set-url origin "$url"
git push origin main
cd ..
bash -x subsurface/scripts/get-or-create-build-nr.sh ${{ github.sha }}
cp nightly-builds/latest-subsurface-buildnumber subsurface
echo "CICD-release" > subsurface/latest-subsurface-buildnumber-extension
version=$(bash subsurface/scripts/get-version)
echo "version=$version" >> $GITHUB_OUTPUT
- name: store dummy version and build number for pull request
if: github.event_name == 'pull_request'
run: |
echo "100" > latest-subsurface-buildnumber
echo "CICD-pull-request" > latest-subsurface-buildnumber-extension
- name: Set up LXD - name: Set up LXD
uses: canonical/setup-lxd@main uses: canonical/setup-lxd@main
@ -56,6 +81,7 @@ jobs:
run: ccache --show-stats --zero-stats run: ccache --show-stats --zero-stats
- name: Upload the snap - name: Upload the snap
if: github.event_name == 'push'
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
with: with:
name: ${{ steps.build-snap.outputs.snap-name }} name: ${{ steps.build-snap.outputs.snap-name }}

View file

@ -17,6 +17,31 @@ jobs:
- name: checkout sources - name: checkout sources
uses: actions/checkout@v1 uses: actions/checkout@v1
- name: atomically create or retrieve the build number
id: version_number
if: github.event_name == 'push'
run: |
cd .. # check out parallel to subsurface sources
url="https://subsurface:${{ secrets.NIGHTLY_BUILDS }}@github.com/subsurface/nightly-builds"
# the clone followed by the pointless push should verify that the password is stored in the config
# that way the script doesn't need the password
git clone -b main https://github.com/subsurface/nightly-builds
cd nightly-builds
git remote set-url origin "$url"
git push origin main
cd ..
bash -x subsurface/scripts/get-or-create-build-nr.sh ${{ github.sha }}
cp nightly-builds/latest-subsurface-buildnumber subsurface
echo "CICD-release" > subsurface/latest-subsurface-buildnumber-extension
version=$(bash subsurface/scripts/get-version)
echo "version=$version" >> $GITHUB_OUTPUT
- name: store dummy version and build number for pull request
if: github.event_name == 'pull_request'
run: |
echo "100" > latest-subsurface-buildnumber
echo "CICD-pull-request" > latest-subsurface-buildnumber-extension
- name: run build - name: run build
env: env:
SUBSURFACE_REPO_PATH: ${{ github.workspace }} SUBSURFACE_REPO_PATH: ${{ github.workspace }}
@ -39,3 +64,35 @@ jobs:
with: with:
name: Linux-artifacts name: Linux-artifacts
path: Linux-artifacts path: Linux-artifacts
- name: prepare release artifacts
if: github.event_name == 'push'
run: |
mv Subsurface.AppImage Subsurface-v${{ steps.version_number.outputs.version }}.AppImage
# only publish a 'release' on push events (those include merging a PR)
- name: upload binaries
if: github.event_name == 'push'
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.version_number.outputs.version }}
repository: subsurface/nightly-builds
token: ${{ secrets.NIGHTLY_BUILDS }}
prerelease: false
fail_on_unmatched_files: true
files: |
./Subsurface*.AppImage
body: |
CICD release artifact
These builds are created on every merge or push into the [Subsurface repo](http://github.com/subsurface/subsurface).
This build is based on http://github.com/subsurface/subsurface/commit/${{ github.sha }}
None of these artifacts are signed.
The Android APK can be side-loaded on most Android devices. If you had a previous Subsurface-mobile version installed from the Google Play store, you'll have to uninstall that first.
The Windows installer will ask you to confirm installation of an app from an unknown developer.
The macOS DMG makes it even harder with a multi-step dance that requires opening the Privacy & Security settings in the System Preferences and explicitly confirming that you are willing to install this app.
You can find similar Subsurface-Daily builds for [Ubuntu](https://ppa.launchpadcontent.net/subsurface) and Subsurface-test for [Fedora](https://copr.fedorainfracloud.org/coprs/dirkhh/Subsurface-test).
Please report any issues with these builds in the [Subsurface user forum](https://groups.google.com/g/subsurface-divelog).

View file

@ -13,8 +13,9 @@ jobs:
steps: steps:
- name: checkout sources - name: checkout sources
uses: actions/checkout@v1 uses: actions/checkout@v1
- name: atomically create or retrieve the build number - name: atomically create or retrieve the build number
id: build_nr id: version_number
if: github.event_name == 'push' if: github.event_name == 'push'
run: | run: |
cd .. # check out parallel to subsurface sources cd .. # check out parallel to subsurface sources
@ -27,6 +28,16 @@ jobs:
git push origin main git push origin main
cd .. cd ..
bash -x subsurface/scripts/get-or-create-build-nr.sh ${{ github.sha }} bash -x subsurface/scripts/get-or-create-build-nr.sh ${{ github.sha }}
cp nightly-builds/latest-subsurface-buildnumber subsurface
echo "CICD-release" > subsurface/latest-subsurface-buildnumber-extension
version=$(bash subsurface/scripts/get-version)
echo "version=$version" >> $GITHUB_OUTPUT
- name: store dummy version and build number for pull request
if: github.event_name == 'pull_request'
run: |
echo "100" > latest-subsurface-buildnumber
echo "CICD-pull-request" > latest-subsurface-buildnumber-extension
- name: setup Homebrew - name: setup Homebrew
run: brew install hidapi libxslt libjpg libmtp create-dmg confuse run: brew install hidapi libxslt libjpg libmtp create-dmg confuse
@ -55,15 +66,6 @@ jobs:
echo "Created $IMG" echo "Created $IMG"
echo "dmg=$IMG" >> $GITHUB_OUTPUT echo "dmg=$IMG" >> $GITHUB_OUTPUT
- name: create version number
id: version_number
if: github.event_name == 'push'
run: |
gitversion=$(bash scripts/get-version win)
latest=$(cat ../nightly-builds/latest-subsurface-buildnumber)
version="$gitversion-$latest"
echo "version=$version" >> $GITHUB_OUTPUT
# only publish a 'release' on push events (those include merging a PR) # only publish a 'release' on push events (those include merging a PR)
- name: upload binaries - name: upload binaries
if: github.event_name == 'push' if: github.event_name == 'push'

View file

@ -49,7 +49,7 @@ unset LD_LIBRARY_PATH
./linuxdeployqt*.AppImage --appimage-extract-and-run ./appdir/usr/share/applications/*.desktop -exclude-libs=libdbus-1.so.3 -bundle-non-qt-libs -qmldir=./subsurface/stats -qmldir=./subsurface/map-widget/ -verbose=2 ./linuxdeployqt*.AppImage --appimage-extract-and-run ./appdir/usr/share/applications/*.desktop -exclude-libs=libdbus-1.so.3 -bundle-non-qt-libs -qmldir=./subsurface/stats -qmldir=./subsurface/map-widget/ -verbose=2
# create the AppImage # create the AppImage
export VERSION=$(cd subsurface/scripts ; ./get-version linux) # linuxdeployqt uses this for naming the file export VERSION=$(cd subsurface/scripts ; ./get-version) # linuxdeployqt uses this for naming the file
./linuxdeployqt*.AppImage --appimage-extract-and-run ./appdir/usr/share/applications/*.desktop -exclude-libs=libdbus-1.so.3 -appimage -qmldir=./subsurface/stats -qmldir=./subsurface/map-widget/ -verbose=2 ./linuxdeployqt*.AppImage --appimage-extract-and-run ./appdir/usr/share/applications/*.desktop -exclude-libs=libdbus-1.so.3 -appimage -qmldir=./subsurface/stats -qmldir=./subsurface/map-widget/ -verbose=2
# copy AppImage to the calling VM # copy AppImage to the calling VM

View file

@ -14,6 +14,25 @@ jobs:
- name: Check out sources - name: Check out sources
uses: actions/checkout@v1 uses: actions/checkout@v1
- name: atomically create or retrieve the build number
id: version_number
if: github.event_name == 'push'
run: |
cd .. # check out parallel to subsurface sources
url="https://subsurface:${{ secrets.NIGHTLY_BUILDS }}@github.com/subsurface/nightly-builds"
# the clone followed by the pointless push should verify that the password is stored in the config
# that way the script doesn't need the password
git clone -b main https://github.com/subsurface/nightly-builds
cd nightly-builds
git remote set-url origin "$url"
git push origin main
cd ..
bash -x subsurface/scripts/get-or-create-build-nr.sh ${{ github.sha }}
cp nightly-builds/latest-subsurface-buildnumber subsurface
echo "CICD-release" > subsurface/latest-subsurface-buildnumber-extension
version=$(bash subsurface/scripts/get-version)
echo "version=$version" >> $GITHUB_OUTPUT
- name: Setup build dependencies - name: Setup build dependencies
run: | run: |
sudo apt-get update sudo apt-get update

View file

@ -18,7 +18,7 @@ jobs:
uses: actions/checkout@v1 uses: actions/checkout@v1
- name: atomically create or retrieve the build number - name: atomically create or retrieve the build number
id: build_nr id: version_number
if: github.event_name == 'push' if: github.event_name == 'push'
run: | run: |
cd .. # check out parallel to subsurface sources cd .. # check out parallel to subsurface sources
@ -31,6 +31,16 @@ jobs:
git push origin main git push origin main
cd .. cd ..
bash -x subsurface/scripts/get-or-create-build-nr.sh ${{ github.sha }} bash -x subsurface/scripts/get-or-create-build-nr.sh ${{ github.sha }}
cp nightly-builds/latest-subsurface-buildnumber subsurface
echo "CICD-release" > subsurface/latest-subsurface-buildnumber-extension
version=$(bash subsurface/scripts/get-version)
echo "version=$version" >> $GITHUB_OUTPUT
- name: store dummy version and build number for pull request
if: github.event_name == 'pull_request'
run: |
echo "100" > latest-subsurface-buildnumber
echo "CICD-pull-request" > latest-subsurface-buildnumber-extension
- name: get other dependencies - name: get other dependencies
env: env:
@ -49,15 +59,6 @@ jobs:
bash -x subsurface/.github/workflows/scripts/windows-in-container-build.sh 2>&1 | tee build.log bash -x subsurface/.github/workflows/scripts/windows-in-container-build.sh 2>&1 | tee build.log
grep "Built target installer" build.log grep "Built target installer" build.log
- name: create version number
id: version_number
if: github.event_name == 'push'
run: |
gitversion=$(bash scripts/get-version win)
latest=$(cat ../nightly-builds/latest-subsurface-buildnumber)
version="$gitversion-$latest"
echo "version=$version" >> $GITHUB_OUTPUT
# only publish a 'release' on push events (those include merging a PR) # only publish a 'release' on push events (those include merging a PR)
- name: upload binaries - name: upload binaries
if: github.event_name == 'push' if: github.event_name == 'push'

View file

@ -320,7 +320,7 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
endif() endif()
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
execute_process( execute_process(
COMMAND sh scripts/get-version linux COMMAND bash scripts/get-version
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE SSRF_VERSION_STRING OUTPUT_VARIABLE SSRF_VERSION_STRING
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_STRIP_TRAILING_WHITESPACE

View file

@ -1,7 +1,7 @@
# Generate the ssrf-config.h every 'make' # Generate the ssrf-config.h every 'make'
file(WRITE ${CMAKE_BINARY_DIR}/version.h.in file(WRITE ${CMAKE_BINARY_DIR}/version.h.in
"#define GIT_VERSION_STRING \"@GIT_VERSION_STRING@\" "#define CANONICAL_VERSION_STRING \"@CANONICAL_VERSION_STRING@\"
#define CANONICAL_VERSION_STRING \"@CANONICAL_VERSION_STRING@\" #define CANONICAL_VERSION_STRING_4 \"@CANONICAL_VERSION_STRING_4@\"
") ")
file(COPY cmake/Modules/version.cmake file(COPY cmake/Modules/version.cmake

View file

@ -1,11 +1,20 @@
execute_process( execute_process(
COMMAND sh ${CMAKE_TOP_SRC_DIR}/scripts/get-version linux COMMAND bash ${CMAKE_TOP_SRC_DIR}/scripts/get-version 4
WORKING_DIRECTORY ${CMAKE_TOP_SRC_DIR} WORKING_DIRECTORY ${CMAKE_TOP_SRC_DIR}
OUTPUT_VARIABLE GIT_VERSION_STRING OUTPUT_VARIABLE CANONICAL_VERSION_STRING_4
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_STRIP_TRAILING_WHITESPACE
) )
execute_process( execute_process(
COMMAND sh ${CMAKE_TOP_SRC_DIR}/scripts/get-version full COMMAND bash ${CMAKE_TOP_SRC_DIR}/scripts/get-version 3
WORKING_DIRECTORY ${CMAKE_TOP_SRC_DIR}
OUTPUT_VARIABLE CANONICAL_VERSION_STRING_3
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND bash ${CMAKE_TOP_SRC_DIR}/scripts/get-version
WORKING_DIRECTORY ${CMAKE_TOP_SRC_DIR} WORKING_DIRECTORY ${CMAKE_TOP_SRC_DIR}
OUTPUT_VARIABLE CANONICAL_VERSION_STRING OUTPUT_VARIABLE CANONICAL_VERSION_STRING
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_STRIP_TRAILING_WHITESPACE
@ -15,8 +24,8 @@ configure_file(${SRC} ${DST} @ONLY)
if(CMAKE_SYSTEM_NAME STREQUAL "Windows") if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
execute_process( execute_process(
COMMAND cat ${CMAKE_TOP_SRC_DIR}/packaging/windows/subsurface.nsi.in COMMAND cat ${CMAKE_TOP_SRC_DIR}/packaging/windows/subsurface.nsi.in
COMMAND sed -e "s/VERSIONTOKEN/${GIT_VERSION_STRING}/" COMMAND sed -e "s/VERSIONTOKEN/${CANONICAL_VERSION_STRING}/"
COMMAND sed -e "s/PRODVTOKEN/${CANONICAL_VERSION_STRING}/" COMMAND sed -e "s/PRODVTOKEN/${CANONICAL_VERSION_STRING_4}/"
OUTPUT_FILE ${CMAKE_BINARY_DIR}/staging/subsurface.nsi OUTPUT_FILE ${CMAKE_BINARY_DIR}/staging/subsurface.nsi
) )
endif() endif()

View file

@ -1,9 +1,10 @@
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
#include "ssrf-version.h" #include "ssrf-version.h"
// let's leave the two redundant functions in case we change our minds on git SHAs
const char *subsurface_git_version(void) const char *subsurface_git_version(void)
{ {
return GIT_VERSION_STRING; return CANONICAL_VERSION_STRING_4;
} }
const char *subsurface_canonical_version(void) const char *subsurface_canonical_version(void)

View file

@ -84,10 +84,10 @@ mkdir -p "$BUILDROOT"/subsurface-mobile-build
pushd "$BUILDROOT"/subsurface-mobile-build pushd "$BUILDROOT"/subsurface-mobile-build
# set up the Subsurface versions by hand # set up the Subsurface versions by hand
GITVERSION=$(cd "$SUBSURFACE_SOURCE" ; git describe --match "v[0-9]*" --abbrev=12) CANONICALVERSION=$("$SUBSURFACE_SOURCE"/scripts/get-version)
CANONICALVERSION=$(echo "$GITVERSION" | sed -e 's/-g.*$// ; s/^v//' | sed -e 's/-/./')
echo "#define GIT_VERSION_STRING \"$GITVERSION\"" > ssrf-version.h
echo "#define CANONICAL_VERSION_STRING \"$CANONICALVERSION\"" >> ssrf-version.h echo "#define CANONICAL_VERSION_STRING \"$CANONICALVERSION\"" >> ssrf-version.h
CANONICALVERSION_4=$("$SUBSURFACE_SOURCE"/scripts/get-version 4)
echo "#define CANONICAL_VERSION_STRING_4 \"$CANONICALVERSION_4\"" >> ssrf-version.h
popd popd
if [ "$versionOnly" = "1" ] ; then if [ "$versionOnly" = "1" ] ; then

View file

@ -77,10 +77,10 @@ if [[ $QT_VERSION = 5.15* ]] ; then
fi fi
# set up the Subsurface versions by hand # set up the Subsurface versions by hand
GITVERSION=$(cd "$SUBSURFACE_SOURCE" ; git describe --match "v[0-9]*" --abbrev=12) CANONICALVERSION=$("$SUBSURFACE_SOURCE"/scripts/get-version)
CANONICALVERSION=$(echo "$GITVERSION" | sed -e 's/-g.*$// ; s/^v//' | sed -e 's/-/./')
echo "#define GIT_VERSION_STRING \"$GITVERSION\"" > "$SUBSURFACE_SOURCE"/ssrf-version.h
echo "#define CANONICAL_VERSION_STRING \"$CANONICALVERSION\"" >> "$SUBSURFACE_SOURCE"/ssrf-version.h echo "#define CANONICAL_VERSION_STRING \"$CANONICALVERSION\"" >> "$SUBSURFACE_SOURCE"/ssrf-version.h
CANONICALVERSION_4=$("$SUBSURFACE_SOURCE"/scripts/get-version 4)
echo "#define CANONICAL_VERSION_STRING_4 \"$CANONICALVERSION_4\"" >> "$SUBSURFACE_SOURCE"/ssrf-version.h
BUNDLE=org.subsurface-divelog.subsurface-mobile BUNDLE=org.subsurface-divelog.subsurface-mobile
if [ "${IOS_BUNDLE_PRODUCT_IDENTIFIER}" != "" ] ; then if [ "${IOS_BUNDLE_PRODUCT_IDENTIFIER}" != "" ] ; then
@ -264,7 +264,7 @@ if [ "$QUICK" != "1" ] ; then
if [ ! "$CURRENT_SHA" = "$PREVIOUS_SHA" ] ; then if [ ! "$CURRENT_SHA" = "$PREVIOUS_SHA" ] ; then
echo "$CURRENT_SHA" > "${PARENT_DIR}/libdivecomputer-build-${ARCH}/git.SHA" echo "$CURRENT_SHA" > "${PARENT_DIR}/libdivecomputer-build-${ARCH}/git.SHA"
pushd "${PARENT_DIR}/libdivecomputer-build-${ARCH}" pushd "${PARENT_DIR}/libdivecomputer-build-${ARCH}"
"${SUBSURFACE_SOURCE}/libdivecomputer/configure" --host=${BUILDCHAIN} --prefix="$PREFIX" --enable-static --disable-shared --enable-examples=no --without-libusb --without-hidapi "${SUBSURFACE_SOURCE}/libdivecomputer/configure" --host=${BUILDCHAIN} --prefix="$PREFIX" --enable-static --disable-shared --enable-examples=no --without-libusb --without-hidapi
make -j make -j
make install make install
popd popd

View file

@ -11,7 +11,7 @@ DMGCREATE=create-dmg
# same git version magic as in the Makefile # same git version magic as in the Makefile
# for the naming of volume and dmg we want the 3 digits of the full version number # for the naming of volume and dmg we want the 3 digits of the full version number
VERSION=$(cd ${DIR}/subsurface; ./scripts/get-version linux) VERSION=$(cd ${DIR}/subsurface; ./scripts/get-version)
# first build and install Subsurface and then clean up the staging area # first build and install Subsurface and then clean up the staging area
# make sure we didn't lose the minimum OS version # make sure we didn't lose the minimum OS version

View file

@ -7,7 +7,7 @@ cd /__w
# grab the version number # grab the version number
cd subsurface cd subsurface
VERSION=$(./scripts/get-version linux) VERSION=$(./scripts/get-version)
cd .. cd ..
# prep the container # prep the container

View file

@ -1,76 +1,80 @@
#!/bin/sh #!/bin/bash
# shellcheck disable=SC2164
# $1 - os name {linux|darwin|win} # consistently name all builds, regardless of OS or desktop/mobile
# $2 - [optional] raw version string "vX.Y-patchN-sha1". as from `git describe' #
# (see below) # we do need to be able to create three digit (M.m.p) and four digit (M.m.p.c) version strings
# default is VERSION_EXTENSION version - an argument of '4' or '3' gets you a digits only version string
set -eu #
#set -x # we hardcode a base version - this will rarely change
# (we actually haven't discussed a situation where it would change...)
SUBSURFACE_BASE_VERSION=6.0
# little silly helper functions
croak() { croak() {
echo "$0: $*" >&2 echo "$0: $*" >&2
exit 1 exit 1
} }
croak_usage() {
croak "Usage: $0 [3|4]"
}
[ $# -ge 1 ] || croak "missing OS argument" if [[ $# -gt 1 ]] ; then croak_usage ; fi
os=$1 if [[ $# -eq 1 ]] ; then
if [[ $1 != "4" && $1 != "3" ]] ; then croak_usage ; fi
if [ $# -eq 2 ] && [ "$2" ]; then DIGITS="$1"
v0=$2
else
cmd="git describe --match "v[0-9]*" --abbrev=12"
v0=$($cmd) || v0=$(cat .gitversion) || croak "odd; command '$cmd' failed"
fi fi
# strip off the 'v' prefix, if any # figure out where we are in the file system
v0=${v0#v} cd "$(dirname "$0")/../"
export SUBSURFACE_SOURCE=$PWD
case $os in # add the build number to this as 'patch' component
linux) # if we run in an environment where we are given a build number (e.g. CICD builds)
v=$v0 # we just grab that - otherwise we have to figure it out on the fly
;; if [ ! -f latest-subsurface-buildnumber ] ; then
darwin) # figure out the most recent build number, given our own git history
# just the dots in the version string - this way we can # this assumes that (a) we are in a checked out git tree and
# count them # (b) we have the ability to check out another git repo
IFS=. # in situations where either of these isn't true, it's the caller's
set -- $v0 # split $v0 using $IFS separator # responsibility to ensure that the latest-subsurface-buildnumber file exists
dots=$(($# - 1)) # use positional argument count if [ ! -d "$SUBSURFACE_SOURCE/nightly-builds" ] ; then
# split version string using a '-' separator git clone https://github.com/subsurface/nightly-builds &> /dev/null || croak "failed to clone nightly-builds repo"
IFS=- fi
set -- $v0 cd nightly-builds
v=$1 git fetch &> /dev/null
# do we need to add another digit? LAST_BUILD_BRANCHS=$(git branch -a --sort=-committerdate --list | grep remotes/origin/branch-for | head -50 | cut -d/ -f3)
# We know there are 1 or 2 dots in $v, so if it's just one for LAST_BUILD_BRANCH in $LAST_BUILD_BRANCHS "not-found" ; do
# or we are trying to get to 4, add one digit LAST_BUILD_SHA=$(cut -d- -f 3 <<< "$LAST_BUILD_BRANCH")
if [ $dots -eq 1 ]; then git -C "$SUBSURFACE_SOURCE" merge-base --is-ancestor "$LAST_BUILD_SHA" HEAD && break
if [ $# -gt 1 ]; then done
v=$v.$2 [ "not-found" = "$LAST_BUILD_BRANCH" ] && croak "can't find a build number for the current working tree"
else git checkout "$LAST_BUILD_BRANCH" &> /dev/null || croak "failed to check out $LAST_BUILD_BRANCH in nightly-builds"
v=$v.0 BUILDNR=$(<./latest-subsurface-buildnumber)
fi cd "$SUBSURFACE_SOURCE"
fi VERSION_EXTENSION="-"
;; VERSION_EXTENSION+=$(git log --pretty="oneline" "${LAST_BUILD_SHA}...HEAD" | wc -l | tr -d '[:space:]')
full|win) VERSION_EXTENSION+="-"
# just the dots in the version string - this way we can [ "$VERSION_EXTENSION" = "-0-" ] && VERSION_EXTENSION="-"
# count them VERSION_EXTENSION+="local"
IFS=. else
set -- $v0 # split $v0 using $IFS separator # use the files included with the sources
dots=$(($# - 1)) # use positional argument count BUILDNR=$(<"$SUBSURFACE_SOURCE/latest-subsurface-buildnumber")
# split version string using a '-' separator VERSION_EXTENSION=""
IFS=- if [ -f "$SUBSURFACE_SOURCE/latest-subsurface-buildnumber-extension" ] ; then
set -- $v0 VERSION_EXTENSION="-"
v=$1 VERSION_EXTENSION+=$(<"$SUBSURFACE_SOURCE/latest-subsurface-buildnumber-extension")
if [ $dots -eq 1 ]; then fi
v=$v.0 fi
fi
if [ $# -gt 1 ]; then COMMITS_SINCE=$(tr -cd "[:digit:]" <<<"$VERSION_EXTENSION")
v=$v.$2 [[ -z $COMMITS_SINCE ]] && COMMITS_SINCE="0"
else
v=$v.0 if [[ $DIGITS == "3" ]] ; then
fi VERSION="${SUBSURFACE_BASE_VERSION}.${BUILDNR}"
;; elif [[ $DIGITS == "4" ]] ; then
*) VERSION="${SUBSURFACE_BASE_VERSION}.${BUILDNR}.${COMMITS_SINCE}"
v=git.missing.please.hardcode.version else
;; VERSION="${SUBSURFACE_BASE_VERSION}.${BUILDNR}${VERSION_EXTENSION}"
esac fi
printf '%s' $v printf '%s' "$VERSION"

View file

@ -1,23 +1,24 @@
message(STATUS "processing version.cmake") message(STATUS "processing version.cmake")
execute_process( execute_process(
COMMAND sh ${CMAKE_TOP_SRC_DIR}/../scripts/get-version linux COMMAND bash ${CMAKE_TOP_SRC_DIR}/../scripts/get-version
WORKING_DIRECTORY ${CMAKE_TOP_SRC_DIR}
OUTPUT_VARIABLE GIT_VERSION_STRING
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND sh ${CMAKE_TOP_SRC_DIR}/../scripts/get-version full
WORKING_DIRECTORY ${CMAKE_TOP_SRC_DIR} WORKING_DIRECTORY ${CMAKE_TOP_SRC_DIR}
OUTPUT_VARIABLE CANONICAL_VERSION_STRING OUTPUT_VARIABLE CANONICAL_VERSION_STRING
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_STRIP_TRAILING_WHITESPACE
) )
execute_process(
COMMAND bash ${CMAKE_TOP_SRC_DIR}/../scripts/get-version 4
WORKING_DIRECTORY ${CMAKE_TOP_SRC_DIR}
OUTPUT_VARIABLE CANONICAL_VERSION_STRING_4
OUTPUT_STRIP_TRAILING_WHITESPACE
)
configure_file(${SRC} ${DST} @ONLY) configure_file(${SRC} ${DST} @ONLY)
if(CMAKE_SYSTEM_NAME STREQUAL "Windows") if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
execute_process( execute_process(
COMMAND cat ${CMAKE_TOP_SRC_DIR}/../packaging/windows/smtk-import.nsi.in COMMAND cat ${CMAKE_TOP_SRC_DIR}/../packaging/windows/smtk-import.nsi.in
COMMAND sed -e "s/VERSIONTOKEN/${GIT_VERSION_STRING}/" COMMAND sed -e "s/VERSIONTOKEN/${CANONICAL_VERSION_STRING}/"
COMMAND sed -e "s/PRODVTOKEN/${CANONICAL_VERSION_STRING}/" COMMAND sed -e "s/PRODVTOKEN/${CANONICAL_VERSION_STRING_4}/"
OUTPUT_FILE ${CMAKE_BINARY_DIR}/staging/smtk-import.nsi OUTPUT_FILE ${CMAKE_BINARY_DIR}/staging/smtk-import.nsi
) )
endif() endif()