win builds: use appveyor build number for versioning

This commit is contained in:
Philipp Wolfer
2019-11-14 17:08:17 +01:00
parent b247766614
commit 210d22d509
3 changed files with 18 additions and 6 deletions

View File

@@ -40,7 +40,7 @@ before_build:
appveyor DownloadFile https://github.com/acoustid/chromaprint/releases/download/v%CHROMAPRINT_FPCALC_VERSION%/chromaprint-fpcalc-%CHROMAPRINT_FPCALC_VERSION%-windows-x86_64.zip -FileName fpcalc.zip
7z x fpcalc.zip -y
copy /Y chromaprint-fpcalc-%CHROMAPRINT_FPCALC_VERSION%-windows-x86_64\fpcalc.exe fpcalc.exe
IF "%APPVEYOR_REPO_TAG%" == "false" python setup.py patch_version --platform=python%PYTHON_VERSION%
IF "%APPVEYOR_REPO_TAG%" == "false" python setup.py patch_version --platform=%APPVEYOR_BUILD_NUMBER%.python%PYTHON_VERSION%
- ps: |
if ($Env:CODESIGN_PFX_BASE64) {
echo "Preparing code signing certificate"
@@ -52,7 +52,7 @@ before_build:
build_script:
- ps: |
$Certificate = @(Get-ChildItem cert:\CurrentUser\My -codesign)[0]
& .\scripts\package\win-package-app.ps1 -Certificate $Certificate
& .\scripts\package\win-package-app.ps1 -BuildNumber $env:APPVEYOR_BUILD_NUMBER -Certificate $Certificate
test_script:
- ps: |

View File

@@ -1,8 +1,14 @@
Param(
[System.Security.Cryptography.X509Certificates.X509Certificate]
$Certificate
$Certificate,
[Int]
$BuildNumber
)
If (-Not $BuildNumber) {
$BuildNumber = 0
}
Function CodeSignBinary {
Param(
[ValidateScript({Test-Path $_ -PathType Leaf})]
@@ -11,7 +17,7 @@ Function CodeSignBinary {
)
If ($Certificate) {
Set-AuthenticodeSignature -FilePath $BinaryPath -Certificate $Certificate
} else {
} Else {
Write-Output "Skip signing $BinaryPath"
}
}
@@ -27,7 +33,7 @@ Function ThrowOnExeError {
Remove-Item -Path build,dist/picard,locale -Recurse -ErrorAction Ignore
python setup.py clean 2>&1 | %{ "$_" }
ThrowOnExeError "setup.py clean failed"
python setup.py build 2>&1 | %{ "$_" }
python setup.py build --build-number=$BuildNumber 2>&1 | %{ "$_" }
ThrowOnExeError "setup.py build failed"
python setup.py build_ext -i 2>&1 | %{ "$_" }
ThrowOnExeError "setup.py build_ext -i failed"

View File

@@ -192,12 +192,14 @@ class picard_build(build):
('localedir=', None, ''),
('disable-autoupdate', None, 'disable update checking and hide settings for it'),
('disable-locales', None, ''),
('build-number=', None, 'build number (integer)'),
]
sub_commands = build.sub_commands
def initialize_options(self):
build.initialize_options(self)
self.build_number = 0
self.build_locales = None
self.localedir = None
self.disable_autoupdate = None
@@ -205,6 +207,10 @@ class picard_build(build):
def finalize_options(self):
build.finalize_options(self)
try:
self.build_number = int(self.build_number)
except ValueError:
self.build_number = 0
if self.build_locales is None:
self.build_locales = os.path.join(self.build_base, 'locale')
if self.localedir is None:
@@ -218,7 +224,7 @@ class picard_build(build):
log.info('generating scripts/%s from scripts/picard.in', PACKAGE_NAME)
generate_file('scripts/picard.in', 'scripts/' + PACKAGE_NAME, {'localedir': self.localedir, 'autoupdate': not self.disable_autoupdate})
if sys.platform == 'win32':
file_version = PICARD_VERSION[0:3] + PICARD_VERSION[4:]
file_version = PICARD_VERSION[0:3] + (self.build_number,)
file_version_str = '.'.join([str(v) for v in file_version])
# Temporarily setting it to this value to generate a nice name for Windows app