Skip to content

Commit c9891af

Browse files
authored
appveyor: derive the build version from the repo (#819)
The "Build version format" was hard-coded in the AppVeyor project settings. Move it into the repo: set a placeholder version in .appveyor.yml (which overrides the UI setting) and, in before_build, replace it with the version from the VERSION file, the short commit hash and the build number, e.g. 0.16.0-1a2b3c4.42. The build number keeps each build's version unique even if the same commit is built more than once. Assisted-by: claude-code:claude-opus-4-8
1 parent d677dd5 commit c9891af

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

.appveyor.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# The build version is derived from the repo here, which overrides the
2+
# hard-coded "Build version format" in the AppVeyor project settings. The
3+
# {build} placeholder is replaced in before_build with the version read from
4+
# the VERSION file plus the short commit hash (see below).
5+
version: '{build}'
6+
17
environment:
28
matrix:
39
- BUILD_ENV: msbuild
@@ -6,6 +12,15 @@ environment:
612
arch: Win32
713
- BUILD_ENV: cygwin
814

15+
# Derive the build version from the repo: <VERSION>-<short commit>.<build number>,
16+
# e.g. 0.16.0-1a2b3c4.42. The build number keeps it unique even if the same
17+
# commit is built more than once.
18+
before_build:
19+
- ps: |
20+
$base = (Get-Content -Raw "$env:APPVEYOR_BUILD_FOLDER/VERSION").Trim()
21+
$short = git rev-parse --short HEAD
22+
Update-AppveyorBuild -Version "$base-$short.$env:APPVEYOR_BUILD_NUMBER"
23+
924
for:
1025
-
1126
matrix:

0 commit comments

Comments
 (0)