Skip to content

Commit ae248d6

Browse files
Update versioning scheme
1 parent 7f04d34 commit ae248d6

File tree

6 files changed

+61
-26
lines changed

6 files changed

+61
-26
lines changed

.gitlab-ci.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -300,15 +300,12 @@ before_script:
300300
image: fedora:40
301301
stage: build
302302
script:
303-
- dnf install rpmdevtools dnf-plugins-core libcurl-devel qt5-qtbase-devel -y
303+
- dnf install rpmdevtools dnf-plugins-core libcurl-devel qt5-qtbase-devel git -y
304304
- rpmdev-setuptree
305305
- ./scripts/build-package-files.sh fedora/OpenRGB.spec
306-
- ls /root/
307306
- cp fedora/OpenRGB.spec /root/rpmbuild/SPECS
308-
- cp ../OpenRGB /root/rpmbuild/SOURCES/ -r
309-
- cd /root/rpmbuild/SOURCES
310-
- tar -cf OpenRGB.tar.gz OpenRGB/
311-
- cd ..
307+
- cp -rp . /root/rpmbuild/SOURCES/OpenRGB
308+
- cd /root/rpmbuild
312309
- dnf builddep SPECS/OpenRGB.spec -y
313310
- rpmbuild -ba SPECS/OpenRGB.spec
314311
- cd RPMS/x86_64/

OpenRGB.pro

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,44 @@ greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
2626
#-----------------------------------------------------------------------------------------------#
2727
MAJOR = 0
2828
MINOR = 9
29-
REVISION = 1
30-
VERSION = $$MAJOR"."$$MINOR$$REVISION
29+
SUFFIX = git
30+
31+
SHORTHASH = $$system("git rev-parse --short=7 HEAD")
32+
LASTTAG = "release_"$$MAJOR"."$$MINOR
33+
COMMAND = "git rev-list --count "$$LASTTAG"..HEAD"
34+
COMMITS = $$system($$COMMAND)
35+
36+
VERSION_NUM = $$MAJOR"."$$MINOR"."$$COMMITS
37+
VERSION_STR = $$MAJOR"."$$MINOR
38+
39+
VERSION_DEB = $$VERSION_NUM
40+
VERSION_WIX = $$VERSION_NUM".0"
41+
VERSION_AUR = $$VERSION_NUM
42+
VERSION_RPM = $$VERSION_NUM
43+
44+
equals(SUFFIX, "git") {
45+
VERSION_STR = $$VERSION_STR"+ ("$$SUFFIX$$COMMITS")"
46+
VERSION_DEB = $$VERSION_DEB"~git"$$SHORTHASH
47+
VERSION_AUR = $$VERSION_AUR"-g"$$SHORTHASH
48+
VERSION_RPM = $$VERSION_RPM"^git"$$SHORTHASH
49+
} else {
50+
!isEmpty(SUFFIX) {
51+
VERSION_STR = $$VERSION_STR"+ ("$$SUFFIX")"
52+
VERSION_DEB = $$VERSION_DEB"~"$$SUFFIX
53+
VERSION_AUR = $$VERSION_AUR"-"$$SUFFIX
54+
VERSION_RPM = $$VERSION_RPM"^"$$SUFFIX
55+
}
56+
}
57+
3158
TARGET = OpenRGB
3259
TEMPLATE = app
3360

61+
message("VERSION_NUM: "$$VERSION_NUM)
62+
message("VERSION_STR: "$$VERSION_STR)
63+
message("VERSION_DEB: "$$VERSION_DEB)
64+
message("VERSION_WIX: "$$VERSION_WIX)
65+
message("VERSION_AUR: "$$VERSION_AUR)
66+
message("VERSION_RPM: "$$VERSION_RPM)
3467
#-----------------------------------------------------------------------------------------------#
3568
# Automatically generated build information #
3669
#-----------------------------------------------------------------------------------------------#
@@ -40,10 +73,11 @@ freebsd:BUILDDATE = $$system(date -j -R -r "${SOURCE_DATE_EPOCH:-$(date +%
4073
macx:BUILDDATE = $$system(date -j -R -r "${SOURCE_DATE_EPOCH:-$(date +%s)}")
4174
GIT_COMMIT_ID = $$system(git log -n 1 --pretty=format:"%H")
4275
GIT_COMMIT_DATE = $$system(git log -n 1 --pretty=format:"%ci")
43-
GIT_BRANCH = $$system(git branch --show-current)
76+
GIT_BRANCH = $$system(scripts/git-get-branch.sh)
4477

78+
message("GIT_BRANCH: "$$GIT_BRANCH)
4579
DEFINES += \
46-
VERSION_STRING=\\"\"\"$$VERSION\\"\"\" \
80+
VERSION_STRING=\\"\"\"$$VERSION_STR\\"\"\" \
4781
BUILDDATE_STRING=\\"\"\"$$BUILDDATE\\"\"\" \
4882
GIT_COMMIT_ID=\\"\"\"$$GIT_COMMIT_ID\\"\"\" \
4983
GIT_COMMIT_DATE=\\"\"\"$$GIT_COMMIT_DATE\\"\"\" \

fedora/OpenRGB.spec.in

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ Summary: Open source RGB lighting control that doesn't depend on manufact
77

88
License: GPLv2
99
URL: https://gitlab.com/CalcProgrammer1/%{_name}
10-
Source0: OpenRGB.tar.gz
1110

1211
BuildRequires: gcc-c++ libusbx-devel libstdc++-devel qt5-qtbase-devel qt5-linguist desktop-file-utils hidapi-devel mbedtls-devel systemd-rpm-macros
1312
Requires: hicolor-icon-theme
@@ -18,7 +17,7 @@ Open source RGB lighting control that doesn't depend on manufacturer software. S
1817
ASUS, ASRock, Corsair, G.Skill, Gigabyte, HyperX, MSI, Razer, ThermalTake, and more supported
1918

2019
%prep
21-
cp %{_sourcedir}/%{_name}/* %{_builddir} -r
20+
cp -r %{_sourcedir}/%{_name}/. %{_builddir}
2221

2322
%build
2423
cd %{_builddir}

scripts/build-msi.sh

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,14 @@ LICENSEFILE="scripts/License.rtf"
77
BANNERIMAGE="scripts/banner.bmp"
88
DIALOGBACKGROUND="scripts/dialog_background.bmp"
99
ZIP="/jobs/artifacts/master/download?job=Windows+64"
10+
PROJECT_FILE="OpenRGB.pro"
1011

1112
PRODUCTID=$(uuidgen -n @url -N ${WEBSITE} --sha1 | awk '{ print toupper($0) }')
1213
PRODUCTNAME="OpenRGB"
1314
VENDOR=$PRODUCTNAME
1415
PRODUCTCOMMENT="Open source RGB lighting control that doesn't depend on manufacturer software."
1516

16-
MAJOR=$(grep "MAJOR\ *=" OpenRGB.pro | cut -d= -f 2 | tr -d [:space:])
17-
MINOR=$(grep "MINOR\ *=" OpenRGB.pro | cut -d= -f 2 | tr -d [:space:])
18-
REVISION=$(grep "REVISION\ *=" OpenRGB.pro | cut -d= -f 2 | tr -d [:space:])
19-
#The commit count since last tag. The commit ID can be added with group \3 however Wix only accepts integers
20-
RELEASE=$(git describe --tags --abbrev=8 | sed -E "s/(.*)-([0-9]*)-g(\w*)/\2/g")
21-
22-
VERSION="${MAJOR}.${MINOR}.${REVISION}.${RELEASE}"
17+
VERSION=$(qmake ${PROJECT_FILE} 2>&1 | grep VERSION_WIX | cut -d ':' -f 3 | tr -d ' ')
2318

2419
XMLOUTFILE=${PRODUCTNAME,,}".wxs"
2520

@@ -99,4 +94,4 @@ echo -e "\t...Done!\n\n"
9994

10095
#Once the XML file manifest is created create the package
10196
candle -arch x64 ${PRODUCTNAME,,}.wxs
102-
light -sval -ext WixUIExtension ${PRODUCTNAME,,}.wixobj -out ${PRODUCTNAME}_Windows_64.msi
97+
light -sval -ext WixUIExtension ${PRODUCTNAME,,}.wixobj -out ${PRODUCTNAME}_Windows_64.msi

scripts/build-package-files.sh

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,20 @@ if [ -e ${1} ]; then
1919
echo "Warning: File ${1} exists and will be overwritten"
2020
fi
2121

22-
MAJOR=$(grep MAJOR\ ${PROJECT_FILE} | cut -d= -f 2 | tr -d [:space:])
23-
MINOR=$(grep MINOR\ ${PROJECT_FILE} | cut -d= -f 2 | tr -d [:space:])
24-
REVISION=$(grep REVISION\ ${PROJECT_FILE} | cut -d= -f 2 | tr -d [:space:])
22+
VERSION_VAR="VERSION_NUM"
23+
QMAKE_EXE="qmake"
2524

26-
#Convert Revision to a nummber in case it is blank in the project file
27-
REVISION=$(( ${REVISION} + 0 ))
25+
if [[ ${1} == *"debian"* ]]; then
26+
VERSION_VAR="VERSION_DEB"
27+
QMAKE_EXE="qmake"
28+
fi
29+
30+
if [[ ${1} == *"fedora"* ]]; then
31+
VERSION_VAR="VERSION_RPM"
32+
QMAKE_EXE="qmake-qt5"
33+
fi
2834

29-
PACKAGE_VERSION="${MAJOR}.${MINOR}.${REVISION}"
35+
PACKAGE_VERSION=$(${QMAKE_EXE} ${PROJECT_FILE} 2>&1 | grep ${VERSION_VAR} | cut -d ':' -f 3 | tr -d ' ')
36+
echo $PACKAGE_VERSION
3037

3138
sed -e "s/${VERSION_PATTERN}/${PACKAGE_VERSION}/g" ${INFILE_PATH} > ${1}

scripts/git-get-branch.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#! /bin/bash
2+
3+
git show-ref | grep $(git log --pretty=%h -1) | sed 's|.*/\(.*\)|\1|' | sort -u | grep -v HEAD

0 commit comments

Comments
 (0)