From 4accd5950dbaf884fe6fc5d8a5d5bdcadc8ef88b Mon Sep 17 00:00:00 2001 From: Aurelien David Date: Thu, 27 Feb 2025 13:07:59 +0100 Subject: [PATCH] scripts: build version string based only on release tags --- Makefile | 4 ++-- build/xcode/generate_ios.sh | 4 ++-- check_revision.sh | 4 ++-- generate_installer.bat | 4 ++-- mkdmg.sh | 6 ++---- version.bat | 7 +++---- 6 files changed, 13 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 490f03f224..796f92a7b0 100644 --- a/Makefile +++ b/Makefile @@ -23,8 +23,8 @@ config.mak: GITREV_PATH:=$(SRC_PATH)/include/gpac/revision.h -TAG:=$(shell git --git-dir=$(SRC_PATH)/.git describe --tags --abbrev=0 2> /dev/null) -VERSION:=$(shell echo `git --git-dir=$(SRC_PATH)/.git describe --tags --long || echo "UNKNOWN"` | sed "s/^$(TAG)-//") +TAG:=$(shell git --git-dir=$(SRC_PATH)/.git describe --tags --abbrev=0 --match "v*" 2> /dev/null) +VERSION:=$(shell echo `git --git-dir=$(SRC_PATH)/.git describe --tags --long --match "v*" || echo "UNKNOWN"` | sed "s/^$(TAG)-//") BRANCH:=$(shell git --git-dir=$(SRC_PATH)/.git rev-parse --abbrev-ref HEAD 2> /dev/null || echo "UNKNOWN") version: diff --git a/build/xcode/generate_ios.sh b/build/xcode/generate_ios.sh index 407ac43b3a..33db243b31 100755 --- a/build/xcode/generate_ios.sh +++ b/build/xcode/generate_ios.sh @@ -4,8 +4,8 @@ cd "`dirname $0`" echo "*** Set version within Info.plist application file ***" version=`grep '#define GPAC_VERSION ' ../../include/gpac/version.h | cut -d '"' -f 2` -TAG=$(git describe --tags --abbrev=0 2> /dev/null) -REVISION=$(echo `git describe --tags --long 2> /dev/null || echo "UNKNOWN"` | sed "s/^$TAG-//") +TAG=$(git describe --tags --abbrev=0 --match "v*" 2> /dev/null) +REVISION=$(echo `git describe --tags --long --match "v*" 2> /dev/null || echo "UNKNOWN"` | sed "s/^$TAG-//") BRANCH=$(git rev-parse --abbrev-ref HEAD 2> /dev/null || echo "UNKNOWN") rev="$REVISION-$BRANCH" if [ "$rev" != "" ] diff --git a/check_revision.sh b/check_revision.sh index d885c3e5d2..5da1aa5da7 100755 --- a/check_revision.sh +++ b/check_revision.sh @@ -4,8 +4,8 @@ version="`grep '#define GPAC_VERSION ' \"./include/gpac/version.h\" | cut -d '"' #check for .git - if so use nb commits till last tag for rev + commit id if [ -d ".git" ]; then -TAG=$(git describe --tags --abbrev=0 2>>gtmp) -VERSION=$(echo `git describe --tags --long 2>>gtmp || echo "UNKNOWN"` | sed "s/^$TAG-//") +TAG=$(git describe --tags --abbrev=0 --match "v*" 2>>gtmp) +VERSION=$(echo `git describe --tags --long --match "v*" 2>>gtmp || echo "UNKNOWN"` | sed "s/^$TAG-//") BRANCH=$(git rev-parse --abbrev-ref HEAD 2>>gtmp || echo "UNKNOWN") revision="$VERSION-$BRANCH" diff --git a/generate_installer.bat b/generate_installer.bat index e716dc3dce..a8f84a3020 100644 --- a/generate_installer.bat +++ b/generate_installer.bat @@ -49,8 +49,8 @@ echo diff = %diff% if not "%diff%"=="" echo Local and remote revisions not in sync, consider pushing or pulling changes REM execute git and check if the result if found within revision.h -for /f "delims=" %%a in ('git describe --tags --long') do @set VERSION=%%a -for /f "delims=" %%a in ('git describe --tags --abbrev^=0') do @set TAG=%%a- +for /f "delims=" %%a in ('git describe --tags --long --match "v*" ') do @set VERSION=%%a +for /f "delims=" %%a in ('git describe --tags --abbrev^=0 --match "v*" ') do @set TAG=%%a- for /f "delims=" %%a in ('git rev-parse --abbrev-ref HEAD') do @set BRANCH=%%a REM remove anotated tag from VERSION setlocal enabledelayedexpansion diff --git a/mkdmg.sh b/mkdmg.sh index a493f453e8..ecdfbe0bc0 100755 --- a/mkdmg.sh +++ b/mkdmg.sh @@ -80,8 +80,8 @@ version=`grep '#define GPAC_VERSION ' $source_path/include/gpac/version.h | cut cur_dir=`pwd` cd $source_path -TAG=$(git describe --tags --abbrev=0 2> /dev/null) -REVISION=$(echo `git describe --tags --long 2> /dev/null || echo "UNKNOWN"` | sed "s/^$TAG-//") +TAG=$(git describe --tags --abbrev=0 --match "v*" 2> /dev/null) +REVISION=$(echo `git describe --tags --long --match "v*" 2> /dev/null || echo "UNKNOWN"` | sed "s/^$TAG-//") BRANCH=$(git rev-parse --abbrev-ref HEAD 2> /dev/null || echo "UNKNOWN") rev="$REVISION-$BRANCH" cd $cur_dir @@ -121,5 +121,3 @@ chmod 755 $pck_name echo "$pck_name ready" rm -rf tmpdmg rm -rf tmppkg.pkg - - diff --git a/version.bat b/version.bat index c37217c6a4..83858cc0b6 100644 --- a/version.bat +++ b/version.bat @@ -4,8 +4,8 @@ cd /d %~dp0 IF NOT EXIST .\.git\NUL GOTO not_git -for /f "delims=" %%a in ('git describe --tags --long') do @set VERSION=%%a -for /f "delims=" %%a in ('git describe --tags --abbrev^=0') do @set TAG=%%a- +for /f "delims=" %%a in ('git describe --tags --long --match "v*" ') do @set VERSION=%%a +for /f "delims=" %%a in ('git describe --tags --abbrev^=0 --match "v*" ') do @set TAG=%%a- for /f "delims=" %%a in ('git rev-parse --abbrev-ref HEAD') do @set BRANCH=%%a REM remove anotated tag from VERSION setlocal enabledelayedexpansion @@ -26,7 +26,7 @@ goto done :not_git echo "not a git dir" -find /c "-DEV" include\gpac\version.h >nul +find /c "-DEV" include\gpac\version.h >nul if %errorlevel% equ 1 goto rel_tag echo "unknwon tag" @echo off @@ -43,4 +43,3 @@ goto write_file :done cd /d %OLDDIR% exit/b -