mirror of https://github.com/procxx/kepka.git
Update version by a python script.
This commit is contained in:
parent
8b6e24e83d
commit
3a928aac9f
|
@ -7,10 +7,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
*/
|
||||
#pragma once
|
||||
|
||||
#define ALPHA_VERSION_MACRO (1004004002ULL)
|
||||
#define TDESKTOP_REQUESTED_ALPHA_VERSION (1004004002ULL)
|
||||
|
||||
#ifdef TDESKTOP_OFFICIAL_TARGET
|
||||
#define TDESKTOP_ALPHA_VERSION ALPHA_VERSION_MACRO
|
||||
#define TDESKTOP_ALPHA_VERSION TDESKTOP_REQUESTED_ALPHA_VERSION
|
||||
#else // TDESKTOP_OFFICIAL_TARGET
|
||||
#define TDESKTOP_ALPHA_VERSION (0ULL)
|
||||
#endif // TDESKTOP_OFFICIAL_TARGET
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
Dim action, pat, patparts, rxp, inp, matchCount
|
||||
action = WScript.Arguments(0)
|
||||
pat = WScript.Arguments(1)
|
||||
pat = Replace(pat, """, chr(34))
|
||||
pat = Replace(pat, "&hat;", "^")
|
||||
pat = Replace(pat, "&", "&")
|
||||
|
||||
Set rxp = new RegExp
|
||||
rxp.Global = True
|
||||
rxp.Multiline = False
|
||||
If action = "Replace" Then
|
||||
patparts = Split(pat, "/")
|
||||
rxp.Pattern = patparts(0)
|
||||
Else
|
||||
rxp.Pattern = pat
|
||||
End If
|
||||
|
||||
matchCount = 0
|
||||
Do While Not WScript.StdIn.AtEndOfStream
|
||||
inp = WScript.StdIn.ReadLine()
|
||||
If rxp.Test(inp) Then
|
||||
matchCount = matchCount + 1
|
||||
End If
|
||||
If action = "Replace" Then
|
||||
WScript.Echo rxp.Replace(inp, patparts(1))
|
||||
End If
|
||||
Loop
|
||||
|
||||
If action = "Replace" Then
|
||||
If matchCount = 0 Then
|
||||
WScript.Quit(2)
|
||||
End If
|
||||
Else
|
||||
WScript.Echo matchCount
|
||||
End If
|
|
@ -1,166 +1,12 @@
|
|||
@echo OFF
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
set "FullScriptPath=%~dp0"
|
||||
|
||||
set "InputVersion=%1"
|
||||
|
||||
for /F "tokens=1,2,3,4 delims=. " %%a in ("%InputVersion%") do (
|
||||
set "VersionMajor=%%a"
|
||||
set "VersionMinor=%%b"
|
||||
set "VersionPatch=%%c"
|
||||
if "%%d" == "" (
|
||||
set "VersionAlpha=0"
|
||||
set "VersionBeta=0"
|
||||
) else if "%%d" == "beta" (
|
||||
set "VersionAlpha=0"
|
||||
set "VersionBeta=1"
|
||||
) else (
|
||||
set "VersionAlpha=%%d"
|
||||
set "VersionBeta=0"
|
||||
)
|
||||
)
|
||||
|
||||
set /a "VersionMajorCleared=%VersionMajor% %% 1000"
|
||||
if "%VersionMajorCleared%" neq "%VersionMajor%" (
|
||||
echo Bad major version!
|
||||
exit /b 1
|
||||
)
|
||||
set /a "VersionMinorCleared=%VersionMinor% %% 1000"
|
||||
if "%VersionMinorCleared%" neq "%VersionMinor%" (
|
||||
echo Bad minor version!
|
||||
exit /b 1
|
||||
)
|
||||
set /a "VersionPatchCleared=%VersionPatch% %% 1000"
|
||||
if "%VersionPatchCleared%" neq "%VersionPatch%" (
|
||||
echo Bad patch version!
|
||||
exit /b 1
|
||||
)
|
||||
if "%VersionBeta%" neq "0" (
|
||||
if "%VersionBeta%" neq "1" (
|
||||
echo Bad beta version!
|
||||
exit /b 1
|
||||
)
|
||||
set "VersionBetaBool=true"
|
||||
) else (
|
||||
set "VersionBetaBool=false"
|
||||
)
|
||||
|
||||
set /a "VersionFull=%VersionMajor% * 1000000 + %VersionMinor% * 1000 + %VersionPatch%"
|
||||
if "%VersionAlpha%" neq "0" (
|
||||
set /a "VersionAlphaCleared=%VersionAlpha% %% 1000"
|
||||
if "!VersionAlphaCleared!" neq "%VersionAlpha%" (
|
||||
echo Bad alpha version!
|
||||
exit /b 1
|
||||
)
|
||||
set /a "VersionAlphaMul=1000 + %VersionAlpha%"
|
||||
set "VersionFullAlpha=%VersionFull%!VersionAlphaMul:~1!"
|
||||
) else (
|
||||
set "VersionFullAlpha=0"
|
||||
)
|
||||
|
||||
set "VersionStr=%VersionMajor%.%VersionMinor%.%VersionPatch%"
|
||||
if "%VersionPatch%" neq "0" (
|
||||
set "VersionStrSmall=%VersionStr%"
|
||||
) else (
|
||||
set "VersionStrSmall=%VersionMajor%.%VersionMinor%"
|
||||
)
|
||||
|
||||
if "%VersionBeta%" neq "0" (
|
||||
echo Setting version: %VersionStr% beta
|
||||
) else if "%VersionAlpha%" neq "0" (
|
||||
echo Setting version: %VersionStr%.%VersionAlpha% closed alpha
|
||||
) else (
|
||||
echo Setting version: %VersionStr% stable
|
||||
)
|
||||
|
||||
echo Checking changelog...
|
||||
set "ChangelogFile=%FullScriptPath%..\..\changelog.txt"
|
||||
call :count "Argument=^%VersionStr% " "Filename=%ChangelogFile%"
|
||||
if "%FoundCount%" equ "0" (
|
||||
call :count "Argument=^%VersionStrSmall% " "Filename=%ChangelogFile%"
|
||||
if "!FoundCount!" equ "0" (
|
||||
echo Changelog entry not found!
|
||||
exit /b 1
|
||||
) else if "!FoundCount!" neq "1" (
|
||||
echo Wrong changelog entries count found: %FoundCount%
|
||||
exit /b 1
|
||||
)
|
||||
) else if "%FoundCount%" neq "1" (
|
||||
echo Wrong changelog entries count found: %FoundCount%
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo Patching build/version...
|
||||
set "VersionFilePath=%FullScriptPath%version"
|
||||
call :repl "Argument=(AppVersion) (\s*)\d+/$1$2 %VersionFull%" "Filename=%VersionFilePath%" || goto :error
|
||||
call :repl "Argument=(AppVersionStrMajor) (\s*)[\d\.]+/$1$2 %VersionMajor%.%VersionMinor%" "Filename=%VersionFilePath%" || goto :error
|
||||
call :repl "Argument=(AppVersionStrSmall) (\s*)[\d\.]+/$1$2 %VersionStrSmall%" "Filename=%VersionFilePath%" || goto :error
|
||||
call :repl "Argument=(AppVersionStr) (\s*)[\d\.]+/$1$2 %VersionStr%" "Filename=%VersionFilePath%" || goto :error
|
||||
call :repl "Argument=(BetaChannel) (\s*)[\d\.]+/$1$2 %VersionBeta%" "Filename=%VersionFilePath%" || goto :error
|
||||
call :repl "Argument=(AlphaVersion) (\s*)\d+/$1$2 %VersionFullAlpha%" "Filename=%VersionFilePath%" || goto :error
|
||||
|
||||
echo Patching core/version.h...
|
||||
set "VersionHeaderPath=%FullScriptPath%..\SourceFiles\core\version.h"
|
||||
call :repl "Argument=(ALPHA_VERSION_MACRO\s+)\(\d+ULL\)/$1(%VersionFullAlpha%ULL)" "Filename=%VersionHeaderPath%" || goto :error
|
||||
call :repl "Argument=(AppVersion\s+=) (\s*)\d+/$1$2 %VersionFull%" "Filename=%VersionHeaderPath%" || goto :error
|
||||
call :repl "Argument=(AppVersionStr\s+=) (\s*)[&hat;;]+/$1$2 "%VersionStrSmall%"" "Filename=%VersionHeaderPath%" || goto :error
|
||||
call :repl "Argument=(AppBetaVersion\s+=) (\s*)[a-z]+/$1$2 %VersionBetaBool%" "Filename=%VersionHeaderPath%" || goto :error
|
||||
|
||||
echo Patching Telegram.rc...
|
||||
set "ResourcePath=%FullScriptPath%..\Resources\winrc\Telegram.rc"
|
||||
call :repl "Argument=(FILEVERSION) (\s*)\d+,\d+,\d+,\d+/$1$2 %VersionMajor%,%VersionMinor%,%VersionPatch%,%VersionAlpha%" "Filename=%ResourcePath%" || goto :error
|
||||
call :repl "Argument=(PRODUCTVERSION) (\s*)\d+,\d+,\d+,\d+/$1$2 %VersionMajor%,%VersionMinor%,%VersionPatch%,%VersionAlpha%" "Filename=%ResourcePath%" || goto :error
|
||||
call :repl "Argument=("FileVersion",) (\s*)"\d+.\d+.\d+.\d+"/$1$2 "%VersionMajor%.%VersionMinor%.%VersionPatch%.%VersionAlpha%"" "Filename=%ResourcePath%" || goto :error
|
||||
call :repl "Argument=("ProductVersion",) (\s*)"\d+.\d+.\d+.\d+"/$1$2 "%VersionMajor%.%VersionMinor%.%VersionPatch%.%VersionAlpha%"" "Filename=%ResourcePath%" || goto :error
|
||||
|
||||
echo Patching Updater.rc...
|
||||
set "ResourcePath=%FullScriptPath%..\Resources\winrc\Updater.rc"
|
||||
call :repl "Argument=(FILEVERSION) (\s*)\d+,\d+,\d+,\d+/$1$2 %VersionMajor%,%VersionMinor%,%VersionPatch%,%VersionAlpha%" "Filename=%ResourcePath%" || goto :error
|
||||
call :repl "Argument=(PRODUCTVERSION) (\s*)\d+,\d+,\d+,\d+/$1$2 %VersionMajor%,%VersionMinor%,%VersionPatch%,%VersionAlpha%" "Filename=%ResourcePath%" || goto :error
|
||||
call :repl "Argument=("FileVersion",) (\s*)"\d+.\d+.\d+.\d+"/$1$2 "%VersionMajor%.%VersionMinor%.%VersionPatch%.%VersionAlpha%"" "Filename=%ResourcePath%" || goto :error
|
||||
call :repl "Argument=("ProductVersion",) (\s*)"\d+.\d+.\d+.\d+"/$1$2 "%VersionMajor%.%VersionMinor%.%VersionPatch%.%VersionAlpha%"" "Filename=%ResourcePath%" || goto :error
|
||||
|
||||
echo Patching appxmanifest.xml...
|
||||
set "ResourcePath=%FullScriptPath%..\Resources\uwp\AppX\AppxManifest.xml"
|
||||
call :repl "Argument= (Version=)"\d+.\d+.\d+.\d+"/ $1"%VersionMajor%.%VersionMinor%.%VersionPatch%.%VersionAlpha%"" "Filename=%ResourcePath%" || goto :error
|
||||
python %FullScriptPath%set_version.py %1
|
||||
if %errorlevel% neq 0 goto error
|
||||
|
||||
exit /b
|
||||
|
||||
:error
|
||||
(
|
||||
set ErrorCode=%errorlevel%
|
||||
echo Error !ErrorCode!
|
||||
exit /b !ErrorCode!
|
||||
)
|
||||
|
||||
:repl
|
||||
(
|
||||
set %1
|
||||
set %2
|
||||
set "TempFilename=!Filename!__tmp__"
|
||||
cscript //Nologo "%FullScriptPath%replace.vbs" "Replace" "!Argument!" < "!Filename!" > "!TempFilename!" || goto :repl_finish
|
||||
xcopy /Y !TempFilename! !Filename! >NUL || goto :repl_finish
|
||||
goto :repl_finish
|
||||
)
|
||||
|
||||
:count
|
||||
(
|
||||
set %1
|
||||
set %2
|
||||
set "TempFilename=!Filename!__tmp__"
|
||||
cscript //Nologo "%FullScriptPath%replace.vbs" "Count" "!Argument!" < "!Filename!" > "!TempFilename!" || goto :repl_finish
|
||||
FOR /F "tokens=1,2* delims= " %%i in (!TempFilename!) do set "FoundCount=%%i"
|
||||
goto :repl_finish
|
||||
)
|
||||
|
||||
:repl_finish
|
||||
(
|
||||
set ErrorCode=%errorlevel%
|
||||
if !ErrorCode! neq 0 (
|
||||
echo Replace error !ErrorCode!
|
||||
echo While replacing "%Replace%"
|
||||
echo In file "%Filename%"
|
||||
)
|
||||
del %TempFilename%
|
||||
exit /b !ErrorCode!
|
||||
)
|
||||
echo FAILED
|
||||
exit /b 1
|
||||
|
|
|
@ -0,0 +1,145 @@
|
|||
'''
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
'''
|
||||
import sys, os, re, subprocess
|
||||
|
||||
def finish(code):
|
||||
global executePath
|
||||
os.chdir(executePath)
|
||||
sys.exit(code)
|
||||
|
||||
if sys.platform == 'win32' and not 'COMSPEC' in os.environ:
|
||||
print('[ERROR] COMSPEC environment variable is not set.')
|
||||
finish(1)
|
||||
|
||||
executePath = os.getcwd()
|
||||
scriptPath = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
inputVersion = ''
|
||||
versionMajor = ''
|
||||
versionMinor = ''
|
||||
versionPatch = ''
|
||||
versionAlpha = '0'
|
||||
versionBeta = False
|
||||
for arg in sys.argv:
|
||||
match = re.match(r'^(\d+)\.(\d+)(\.(\d+)(\.(\d+|beta))?)?', arg)
|
||||
if match:
|
||||
inputVersion = arg
|
||||
versionMajor = match.group(1)
|
||||
versionMinor = match.group(2)
|
||||
versionPatch = match.group(4) if match.group(4) else '0'
|
||||
if match.group(5) > 0:
|
||||
if match.group(6) == 'beta':
|
||||
versionBeta = True
|
||||
else:
|
||||
versionAlpha = match.group(6)
|
||||
|
||||
def checkVersionPart(part):
|
||||
cleared = int(part) % 1000
|
||||
if str(cleared) != part:
|
||||
print("Bad version part: " + part)
|
||||
finish(1)
|
||||
|
||||
checkVersionPart(versionMajor)
|
||||
checkVersionPart(versionMinor)
|
||||
checkVersionPart(versionPatch)
|
||||
checkVersionPart(versionAlpha)
|
||||
|
||||
versionFull = str(int(versionMajor) * 1000000 + int(versionMinor) * 1000 + int(versionPatch))
|
||||
versionFullAlpha = '0'
|
||||
if versionAlpha != '0':
|
||||
versionFullAlpha = str(int(versionFull) * 1000 + int(versionAlpha))
|
||||
|
||||
versionStr = versionMajor + '.' + versionMinor + '.' + versionPatch
|
||||
versionStrSmall = versionStr if versionPatch != '0' else versionMajor + '.' + versionMinor
|
||||
|
||||
if versionBeta:
|
||||
print('Setting version: ' + versionStr + ' beta')
|
||||
elif versionAlpha != '0':
|
||||
print('Setting version: ' + versionStr + '.' + versionAlpha + ' closed alpha')
|
||||
else:
|
||||
print('Setting version: ' + versionStr + ' stable')
|
||||
|
||||
#def replaceInFile(path, replaces):
|
||||
|
||||
def checkChangelog():
|
||||
global scriptPath, versionStr, versionStrSmall
|
||||
|
||||
count = 0
|
||||
with open(scriptPath + '/../../changelog.txt', 'r') as f:
|
||||
for line in f:
|
||||
if line.startswith(versionStr + ' ') or line.startswith(versionStrSmall + ' '):
|
||||
count = count + 1
|
||||
if count == 0:
|
||||
print('Changelog entry not found!')
|
||||
finish(1)
|
||||
elif count != 1:
|
||||
print('Wrong changelog entries count found: ' + count)
|
||||
finish(1)
|
||||
|
||||
checkChangelog()
|
||||
|
||||
def replaceInFile(path, replacements):
|
||||
content = ''
|
||||
foundReplacements = {}
|
||||
updated = False
|
||||
with open(path, 'r') as f:
|
||||
for line in f:
|
||||
for replacement in replacements:
|
||||
if re.search(replacement[0], line):
|
||||
changed = re.sub(replacement[0], replacement[1], line)
|
||||
if changed != line:
|
||||
line = changed
|
||||
updated = True
|
||||
foundReplacements[replacement[0]] = True
|
||||
content = content + line
|
||||
for replacement in replacements:
|
||||
if not replacement[0] in foundReplacements:
|
||||
print('Could not find "' + replacement[0] + '" in "' + path + '".')
|
||||
finish(1)
|
||||
if updated:
|
||||
with open(path, 'w') as f:
|
||||
f.write(content)
|
||||
|
||||
print('Patching build/version...')
|
||||
replaceInFile(scriptPath + '/version', [
|
||||
[ r'(AppVersion\s+)\d+', r'\g<1>' + versionFull ],
|
||||
[ r'(AppVersionStrMajor\s+)\d[\d\.]*', r'\g<1>' + versionMajor + '.' + versionMinor ],
|
||||
[ r'(AppVersionStrSmall\s+)\d[\d\.]*', r'\g<1>' + versionStrSmall ],
|
||||
[ r'(AppVersionStr\s+)\d[\d\.]*', r'\g<1>' + versionStr ],
|
||||
[ r'(BetaChannel\s+)\d', r'\g<1>' + ('1' if versionBeta else '0') ],
|
||||
[ r'(AlphaVersion\s+)\d+', r'\g<1>' + versionFullAlpha ],
|
||||
])
|
||||
|
||||
print('Patching core/version.h...')
|
||||
replaceInFile(scriptPath + '/../SourceFiles/core/version.h', [
|
||||
[ r'(TDESKTOP_REQUESTED_ALPHA_VERSION\s+)\(\d+ULL\)', r'\g<1>(' + versionFullAlpha + 'ULL)' ],
|
||||
[ r'(AppVersion\s+=\s+)\d+', r'\g<1>' + versionFull ],
|
||||
[ r'(AppVersionStr\s+=\s+)[^;]+', r'\g<1>"' + versionStrSmall + '"' ],
|
||||
[ r'(AppBetaVersion\s+=\s+)[a-z]+', r'\g<1>' + ('true' if versionBeta else 'false') ],
|
||||
])
|
||||
|
||||
parts = [versionMajor, versionMinor, versionPatch, versionAlpha]
|
||||
withcomma = ','.join(parts)
|
||||
withdot = '.'.join(parts)
|
||||
rcReplaces = [
|
||||
[ r'(FILEVERSION\s+)\d+,\d+,\d+,\d+', r'\g<1>' + withcomma ],
|
||||
[ r'(PRODUCTVERSION\s+)\d+,\d+,\d+,\d+', r'\g<1>' + withcomma ],
|
||||
[ r'("FileVersion",\s+)"\d+\.\d+\.\d+\.\d+"', r'\g<1>"' + withdot + '"' ],
|
||||
[ r'("ProductVersion",\s+)"\d+\.\d+\.\d+\.\d+"', r'\g<1>"' + withdot + '"' ],
|
||||
]
|
||||
|
||||
print('Patching Telegram.rc...')
|
||||
replaceInFile(scriptPath + '/../Resources/winrc/Telegram.rc', rcReplaces)
|
||||
|
||||
print('Patching Updater.rc...')
|
||||
replaceInFile(scriptPath + '/../Resources/winrc/Updater.rc', rcReplaces)
|
||||
|
||||
print('Patching appxmanifest.xml...')
|
||||
replaceInFile(scriptPath + '/../Resources/uwp/AppX/AppxManifest.xml', [
|
||||
[ r'( Version=)"\d+\.\d+\.\d+\.\d+"', r'\g<1>"' + withdot + '"' ],
|
||||
])
|
|
@ -1,145 +1,9 @@
|
|||
set -e
|
||||
|
||||
pushd `dirname $0` > /dev/null
|
||||
FullScriptPath=`pwd`
|
||||
popd > /dev/null
|
||||
|
||||
Error () {
|
||||
echo "$1"
|
||||
exit 1
|
||||
}
|
||||
python $FullScriptPath/set_version.py $1
|
||||
|
||||
InputVersion="$1"
|
||||
|
||||
IFS='.' read -ra VersionParts <<< "$InputVersion"
|
||||
VersionMajor="${VersionParts[0]}"
|
||||
VersionMinor="${VersionParts[1]}"
|
||||
VersionPatch="${VersionParts[2]}"
|
||||
if [ "${VersionParts[3]}" == "" ]; then
|
||||
VersionAlpha=0
|
||||
VersionBeta=0
|
||||
elif [ "${VersionParts[3]}" == "beta" ]; then
|
||||
VersionAlpha=0
|
||||
VersionBeta=1
|
||||
else
|
||||
VersionAlpha="${VersionParts[3]}"
|
||||
VersionBeta=0
|
||||
fi
|
||||
|
||||
VersionMajorCleared=`echo "$VersionMajor % 1000" | bc`
|
||||
if [ "$VersionMajorCleared" != "$VersionMajor" ]; then
|
||||
Error "Bad major version!"
|
||||
fi
|
||||
VersionMinorCleared=`echo "$VersionMinor % 1000" | bc`
|
||||
if [ "$VersionMinorCleared" != "$VersionMinor" ]; then
|
||||
Error "Bad minor version!"
|
||||
fi
|
||||
VersionPatchCleared=`echo "$VersionPatch % 1000" | bc`
|
||||
if [ "$VersionPatchCleared" != "$VersionPatch" ]; then
|
||||
Error "Bad patch version!"
|
||||
fi
|
||||
if [ "$VersionBeta" != "0" ]; then
|
||||
if [ "$VersionBeta" != "1" ]; then
|
||||
Error "Bad beta version!"
|
||||
fi
|
||||
VersionBetaBool=true
|
||||
else
|
||||
VersionBetaBool=false
|
||||
fi
|
||||
|
||||
VersionFull=`echo "$VersionMajor * 1000000 + $VersionMinor * 1000 + $VersionPatch" | bc`
|
||||
if [ "$VersionAlpha" != "0" ]; then
|
||||
VersionAlphaCleared=`echo "$VersionAlpha % 1000" | bc`
|
||||
if [ "$VersionAlphaCleared" != "$VersionAlpha" ]; then
|
||||
Error "Bad alpha version!"
|
||||
fi
|
||||
VersionAlphaMul=`echo "$VersionAlpha + 1000" | bc`
|
||||
VersionFullAlpha="$VersionFull${VersionAlphaMul:1}"
|
||||
else
|
||||
VersionFullAlpha=0
|
||||
fi
|
||||
|
||||
VersionStr="$VersionMajor.$VersionMinor.$VersionPatch"
|
||||
if [ "$VersionPatch" != "0" ]; then
|
||||
VersionStrSmall="$VersionStr"
|
||||
else
|
||||
VersionStrSmall="$VersionMajor.$VersionMinor"
|
||||
fi
|
||||
|
||||
if [ "$VersionBeta" != "0" ]; then
|
||||
echo "Setting version: $VersionStr beta"
|
||||
elif [ "$VersionAlpha" != "0" ]; then
|
||||
echo "Setting version: $VersionStr.$VersionAlpha closed alpha"
|
||||
else
|
||||
echo "Setting version: $VersionStr stable"
|
||||
fi
|
||||
|
||||
repl () {
|
||||
Pattern="$1"
|
||||
Replacement="$2"
|
||||
File="$3"
|
||||
CheckCommand="grep -sc '$Pattern' $File"
|
||||
set +e
|
||||
CheckCount=`eval $CheckCommand`
|
||||
set -e
|
||||
if [ "$CheckCount" -gt 0 ]; then
|
||||
ReplaceCommand="sed -i'.~' 's/$Pattern/$Replacement/g' $File"
|
||||
eval $ReplaceCommand
|
||||
else
|
||||
echo "Not found $Pattern"
|
||||
Error "While processing $File"
|
||||
fi
|
||||
}
|
||||
|
||||
echo "Checking changelog..."
|
||||
ChangelogFile="$FullScriptPath/../../changelog.txt"
|
||||
ChangelogCommand="grep -sc '^$VersionStr ' $ChangelogFile"
|
||||
set +e
|
||||
FoundCount=`eval $ChangelogCommand`
|
||||
set -e
|
||||
if [ "$FoundCount" == "0" ]; then
|
||||
ChangelogCommand="grep -sc '^$VersionStrSmall ' $ChangelogFile"
|
||||
set +e
|
||||
FoundCount=`eval $ChangelogCommand`
|
||||
set -e
|
||||
if [ "$FoundCount" == "0" ]; then
|
||||
Error "Changelog entry not found!"
|
||||
elif [ "$FoundCount" != "1" ]; then
|
||||
Error "Wrong changelog entries count found: $FoundCount"
|
||||
fi
|
||||
elif [ "$FoundCount" != "1" ]; then
|
||||
Error "Wrong changelog entries count found: $FoundCount"
|
||||
fi
|
||||
|
||||
echo "Patching build/version..."
|
||||
VersionFilePath="$FullScriptPath/version"
|
||||
repl "\(AppVersion\) \([ ]*\)[0-9][0-9]*" "\1\2 $VersionFull" "$VersionFilePath"
|
||||
repl "\(AppVersionStrMajor\) \([ ]*\)[0-9][0-9\.]*" "\1\2 $VersionMajor.$VersionMinor" "$VersionFilePath"
|
||||
repl "\(AppVersionStrSmall\) \([ ]*\)[0-9][0-9\.]*" "\1\2 $VersionStrSmall" "$VersionFilePath"
|
||||
repl "\(AppVersionStr\) \([ ]*\)[0-9][0-9\.]*" "\1\2 $VersionStr" "$VersionFilePath"
|
||||
repl "\(BetaChannel\) \([ ]*\)[0-9][0-9]*" "\1\2 $VersionBeta" "$VersionFilePath"
|
||||
repl "\(AlphaVersion\) \([ ]*\)[0-9][0-9]*" "\1\2 $VersionFullAlpha" "$VersionFilePath"
|
||||
|
||||
echo "Patching core/version.h..."
|
||||
VersionHeaderPath="$FullScriptPath/../SourceFiles/core/version.h"
|
||||
repl "\(ALPHA_VERSION_MACRO [ ]*\)([0-9][0-9]*ULL)" "\1(${VersionFullAlpha}ULL)" "$VersionHeaderPath"
|
||||
repl "\(AppVersion [ ]*=\) \([ ]*\)[0-9][0-9]*" "\1\2 $VersionFull" "$VersionHeaderPath"
|
||||
repl "\(AppVersionStr [ ]*=\) \([ ]*\)[^;][^;]*" "\1\2 \"$VersionStrSmall\"" "$VersionHeaderPath"
|
||||
repl "\(AppBetaVersion [ ]*=\) \([ ]*\)[a-z][a-z]*" "\1\2 $VersionBetaBool" "$VersionHeaderPath"
|
||||
|
||||
echo "Patching Telegram.rc..."
|
||||
ResourcePath="$FullScriptPath/../Resources/winrc/Telegram.rc"
|
||||
repl "\(FILEVERSION\) \([ ]*\)[0-9][0-9]*,[0-9][0-9]*,[0-9][0-9]*,[0-9][0-9]*" "\1\2 $VersionMajor,$VersionMinor,$VersionPatch,$VersionAlpha" "$ResourcePath"
|
||||
repl "\(PRODUCTVERSION\) \([ ]*\)[0-9][0-9]*,[0-9][0-9]*,[0-9][0-9]*,[0-9][0-9]*" "\1\2 $VersionMajor,$VersionMinor,$VersionPatch,$VersionAlpha" "$ResourcePath"
|
||||
repl "\(\"FileVersion\",\) \([ ]*\)\"[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\"" "\1\2 \"$VersionMajor.$VersionMinor.$VersionPatch.$VersionAlpha\"" "$ResourcePath"
|
||||
repl "\(\"ProductVersion\",\) \([ ]*\)\"[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\"" "\1\2 \"$VersionMajor.$VersionMinor.$VersionPatch.$VersionAlpha\"" "$ResourcePath"
|
||||
|
||||
echo "Patching Updater.rc..."
|
||||
ResourcePath="$FullScriptPath/../Resources/winrc/Updater.rc"
|
||||
repl "\(FILEVERSION\) \([ ]*\)[0-9][0-9]*,[0-9][0-9]*,[0-9][0-9]*,[0-9][0-9]*" "\1\2 $VersionMajor,$VersionMinor,$VersionPatch,$VersionAlpha" "$ResourcePath"
|
||||
repl "\(PRODUCTVERSION\) \([ ]*\)[0-9][0-9]*,[0-9][0-9]*,[0-9][0-9]*,[0-9][0-9]*" "\1\2 $VersionMajor,$VersionMinor,$VersionPatch,$VersionAlpha" "$ResourcePath"
|
||||
repl "\(\"FileVersion\",\) \([ ]*\)\"[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\"" "\1\2 \"$VersionMajor.$VersionMinor.$VersionPatch.$VersionAlpha\"" "$ResourcePath"
|
||||
repl "\(\"ProductVersion\",\) \([ ]*\)\"[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\"" "\1\2 \"$VersionMajor.$VersionMinor.$VersionPatch.$VersionAlpha\"" "$ResourcePath"
|
||||
|
||||
echo "Patching appxmanifest.xml..."
|
||||
ResourcePath="$FullScriptPath/../Resources/uwp/AppX/AppxManifest.xml"
|
||||
repl " \(Version=\)\"[0-9][0-9]*.[0-9][0-9]*.[0-9][0-9]*.[0-9][0-9]*\"" " \1\"$VersionMajor.$VersionMinor.$VersionPatch.$VersionAlpha\"" "$ResourcePath"
|
||||
exit
|
||||
|
|
Loading…
Reference in New Issue