@@ -34,30 +34,30 @@ jobs:
3434 - name : Build x64 Release
3535 run : msbuild /m /p:Configuration=${{ env.BUILD_CONFIGURATION }} /p:Platform=${{ env.PLATFORM }} ${{ env.SOLUTION_FILE_PATH }}
3636
37- - name : Determine version and create tag if needed
37+ - name : Determine version
3838 id : version
3939 shell : cmd
4040 run : |
4141 @echo off
42- REM -- Attempt to retrieve the latest tag, assuming x.y.z format. Redirect errors.
42+ REM Attempt to retrieve the latest tag (expected format: x.y.z). Suppress errors.
4343 for /f "delims=" %%t in ('git describe --tags --abbrev=0 2^>nul') do set LATEST_TAG=%%t
4444
45- REM If no tag was found, default to 0.0.0.
4645 if not defined LATEST_TAG (
4746 echo No tag found. Defaulting to 0.0.0.
4847 set "LATEST_TAG=0.0.0"
49- REM Count all commits and subtract 1 ( so that the first commit is version 0.0.0) .
48+ REM Count all commits. Subtract 1 so the first commit remains 0.0.0.
5049 for /f %%i in ('git rev-list HEAD --count') do set ALL_COUNT=%%i
51- set /a COMMITS_SINCE=%ALL_COUNT%-1
50+ set /a COMMITS_SINCE=ALL_COUNT - 1
51+ if %COMMITS_SINCE% lss 0 set COMMITS_SINCE=0
5252 ) else (
53- REM If a tag was found , count commits since that tag.
53+ REM If a tag exists , count commits from that tag to HEAD .
5454 for /f %%i in ('git rev-list %LATEST_TAG%..HEAD --count') do set COMMITS_SINCE=%%i
5555 )
5656
5757 echo Latest tag: %LATEST_TAG%
5858 echo Commits since latest tag: %COMMITS_SINCE%
5959
60- REM If a tag existed ( other than our default) then compare its commit to HEAD.
60+ REM If a tag exists other than the default base, compare its commit hash with HEAD.
6161 if not "%LATEST_TAG%"=="0.0.0" (
6262 for /f %%i in ('git rev-list -n 1 %LATEST_TAG%') do set TAG_COMMIT=%%i
6363 for /f %%i in ('git rev-parse HEAD') do set CURRENT_COMMIT=%%i
@@ -69,14 +69,14 @@ jobs:
6969 goto WriteOutput
7070 )
7171 ) else (
72- REM For our default base tag case, if no commits after the first commit, keep version 0.0.0.
72+ REM For our default base tag case, if no additional commits exist, remain at 0.0.0.
7373 if "%COMMITS_SINCE%"=="0" (
7474 set "VERSION=0.0.0"
7575 goto WriteOutput
7676 )
7777 )
7878
79- REM Otherwise, split LATEST_TAG into major, minor, and patch .
79+ REM Otherwise, split LATEST_TAG (assumed in x.y.z format) into its parts .
8080 for /f "tokens=1-3 delims=." %%a in ("%LATEST_TAG%") do (
8181 set MAJOR=%%a
8282 set MINOR=%%b
@@ -86,12 +86,12 @@ jobs:
8686 set "VERSION=%MAJOR%.%MINOR%.%NEW_PATCH%"
8787 echo New version: %VERSION%
8888
89- REM Create an annotated tag on the current commit and push it.
90- git tag -a %VERSION% -m "Auto-incremented tag %VERSION%"
89+ REM Create a lightweight tag (so no commit signature is required) and push it.
90+ git tag %VERSION%
9191 git push origin %VERSION%
9292
9393 :WriteOutput
94- REM Write the computed version into the GitHub actions output environment file.
94+ REM Write the computed version to the GitHub Actions output environment file.
9595 echo version=%VERSION%>> %GITHUB_OUTPUT%
9696
9797
0 commit comments