Skip to content

Commit 54fc596

Browse files
committed
fixed version check
1 parent fbb1888 commit 54fc596

File tree

2 files changed

+51
-32
lines changed

2 files changed

+51
-32
lines changed

.github/workflows/release.yml

Lines changed: 50 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -39,43 +39,62 @@ jobs:
3939
shell: cmd
4040
run: |
4141
@echo off
42-
REM Retrieve the latest tag (assumes tags are in x.y.z format)
43-
for /f "delims=" %%t in ('git describe --tags --abbrev=0') do set LATEST_TAG=%%t
44-
echo Latest tag: %LATEST_TAG%
45-
46-
REM Get the commit hash for the latest tag and for HEAD.
47-
for /f %%i in ('git rev-list -n 1 %LATEST_TAG%') do set TAG_COMMIT=%%i
48-
for /f %%i in ('git rev-parse HEAD') do set CURRENT_COMMIT=%%i
49-
50-
echo Tag commit: %TAG_COMMIT%
51-
echo Current commit: %CURRENT_COMMIT%
52-
53-
if "%TAG_COMMIT%"=="%CURRENT_COMMIT%" (
54-
echo HEAD is tagged. Using existing version %LATEST_TAG%.
55-
set "VERSION=%LATEST_TAG%"
42+
REM -- Attempt to retrieve the latest tag, assuming x.y.z format. Redirect errors.
43+
for /f "delims=" %%t in ('git describe --tags --abbrev=0 2^>nul') do set LATEST_TAG=%%t
44+
45+
REM If no tag was found, default to 0.0.0.
46+
if not defined LATEST_TAG (
47+
echo No tag found. Defaulting to 0.0.0.
48+
set "LATEST_TAG=0.0.0"
49+
REM Count all commits and subtract 1 (so that the first commit is version 0.0.0).
50+
for /f %%i in ('git rev-list HEAD --count') do set ALL_COUNT=%%i
51+
set /a COMMITS_SINCE=%ALL_COUNT%-1
5652
) else (
57-
REM Count commits since the latest tag.
53+
REM If a tag was found, count commits since that tag.
5854
for /f %%i in ('git rev-list %LATEST_TAG%..HEAD --count') do set COMMITS_SINCE=%%i
59-
echo Commits since tag: %COMMITS_SINCE%
60-
61-
REM Split LATEST_TAG into MAJOR, MINOR, and PATCH.
62-
for /f "tokens=1-3 delims=." %%a in ("%LATEST_TAG%") do (
63-
set MAJOR=%%a
64-
set MINOR=%%b
65-
set PATCH=%%c
55+
)
56+
57+
echo Latest tag: %LATEST_TAG%
58+
echo Commits since latest tag: %COMMITS_SINCE%
59+
60+
REM If a tag existed (other than our default) then compare its commit to HEAD.
61+
if not "%LATEST_TAG%"=="0.0.0" (
62+
for /f %%i in ('git rev-list -n 1 %LATEST_TAG%') do set TAG_COMMIT=%%i
63+
for /f %%i in ('git rev-parse HEAD') do set CURRENT_COMMIT=%%i
64+
echo Tag commit: %TAG_COMMIT%
65+
echo Current commit: %CURRENT_COMMIT%
66+
if "%TAG_COMMIT%"=="%CURRENT_COMMIT%" (
67+
echo HEAD is tagged. Using existing version %LATEST_TAG%.
68+
set "VERSION=%LATEST_TAG%"
69+
goto WriteOutput
6670
)
67-
set /a NEW_PATCH=%PATCH% + %COMMITS_SINCE%
68-
set "VERSION=%MAJOR%.%MINOR%.%NEW_PATCH%"
69-
echo New version: %VERSION%
70-
71-
REM Create an annotated tag and push it.
72-
git tag -a %VERSION% -m "Auto-incremented tag %VERSION%"
73-
git push origin %VERSION%
71+
) else (
72+
REM For our default base tag case, if no commits after the first commit, keep version 0.0.0.
73+
if "%COMMITS_SINCE%"=="0" (
74+
set "VERSION=0.0.0"
75+
goto WriteOutput
76+
)
77+
)
78+
79+
REM Otherwise, split LATEST_TAG into major, minor, and patch.
80+
for /f "tokens=1-3 delims=." %%a in ("%LATEST_TAG%") do (
81+
set MAJOR=%%a
82+
set MINOR=%%b
83+
set PATCH=%%c
7484
)
75-
76-
REM Write the version to the GitHub actions output environment file.
85+
set /a NEW_PATCH=%PATCH% + %COMMITS_SINCE%
86+
set "VERSION=%MAJOR%.%MINOR%.%NEW_PATCH%"
87+
echo New version: %VERSION%
88+
89+
REM Create an annotated tag on the current commit and push it.
90+
git tag -a %VERSION% -m "Auto-incremented tag %VERSION%"
91+
git push origin %VERSION%
92+
93+
:WriteOutput
94+
REM Write the computed version into the GitHub actions output environment file.
7795
echo version=%VERSION%>> %GITHUB_OUTPUT%
7896
97+
7998
- name: Rename release package with version
8099
shell: cmd
81100
run: |

Module/LoadFileHook.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ uintptr_t __fastcall load_file_hook(hook_arg_t hook_arg, func_args *args)
8888
trackid = songinfo->track_browser_id;
8989
}
9090
info("Track Browser ID: %x", trackid);
91-
load_track(uiplayer, trackid);
91+
load_track(uiplayer, (uint32_t)trackid);
9292
return 0;
9393
}
9494

0 commit comments

Comments
 (0)