Skip to content

Commit f0622db

Browse files
authored
Introduce development versioning (#1641)
Introduce development versioning (enabled by default) - `make` -> `Lynx <current_version>-dev-<commith_hash>`, i.e. `Lynx 1.9.1-dev-955dce1` - GH CI builds -> `Lynx <current_version>-<branch>-<run_number>-dev-<commit_hash>`, i.e. `Lynx 1.9.1-main-5932-dev-955dce1` - GH Release builds -> `Lynx <new_version>`, i.e. `Lynx 1.9.1`
1 parent d1bb797 commit f0622db

4 files changed

Lines changed: 23 additions & 8 deletions

File tree

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ jobs:
8989
(Get-Content $input_path) -Replace $regex, '${{ github.event.inputs.new_engine_version }}' | Out-File $input_path
9090
9191
- name: Publish ${{ matrix.runtime-identifier }} version
92-
run: dotnet publish src/Lynx.Cli/Lynx.Cli.csproj -c Release --runtime ${{ matrix.runtime-identifier }} --self-contained /p:Optimized=true /p:DeterministicBuild=true -o artifacts/${{ matrix.runtime-identifier }}
92+
run: dotnet publish src/Lynx.Cli/Lynx.Cli.csproj -c Release --runtime ${{ matrix.runtime-identifier }} --self-contained /p:Optimized=true /p:DeterministicBuild=true /p:ReleaseBuild=true -o artifacts/${{ matrix.runtime-identifier }}
9393

9494
- name: Upload Lynx-${{ matrix.runtime-identifier }} artifact
9595
if: github.event.inputs.new_engine_version != ''
@@ -113,7 +113,7 @@ jobs:
113113

114114
- name: Deterministic build
115115
if: matrix.runtime-identifier == 'linux-x64'
116-
run: dotnet clean -c Release && dotnet build -c Release /p:DeterministicBuild=true
116+
run: dotnet clean -c Release && dotnet build -c Release /p:DeterministicBuild=true /p:ReleaseBuild=true
117117

118118
- name: Pack NuGet package
119119
if: matrix.runtime-identifier == 'linux-x64'

Directory.Build.props

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
<EmbedUntrackedSources>true</EmbedUntrackedSources>
3434
</PropertyGroup>
3535

36+
<PropertyGroup Condition="'$(ReleaseBuild)' == 'true'">
37+
<DefineConstants>LYNX_RELEASE</DefineConstants>
38+
</PropertyGroup>
39+
3640
<PropertyGroup>
3741
<NoWarn>$(NoWarn),1591,S101,S104,S103,S107,S109,S125,S1067,S1135,S1659,S2148,S3903,S4041,S1133,IDE0290,RCS1090,CA1031,CA1045,CA1062,CA1505,CA1724,CA1815,CA1819,CA2007,VSTHRD200,IDE0290</NoWarn>
3842
</PropertyGroup>

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ test:
4545
dotnet test -c Release & dotnet test -c Release --filter "TestCategory=LongRunning" & dotnet test -c Release --filter "TestCategory=Perft"
4646

4747
publish:
48-
dotnet publish src/Lynx.Cli/Lynx.Cli.csproj -c Release --runtime ${RUNTIME} --self-contained /p:Optimized=true /p:DeterministicBuild=true /p:ExecutableName=$(EXE) -o ${OUTPUT_DIR}
48+
dotnet publish src/Lynx.Cli/Lynx.Cli.csproj -c Release --runtime ${RUNTIME} --self-contained /p:Optimized=true /p:ExecutableName=$(EXE) -o ${OUTPUT_DIR}
4949

5050
run:
5151
dotnet run --project src/Lynx.Cli/Lynx.Cli.csproj -c Release --runtime ${RUNTIME}

src/Lynx/UCI/Commands/Engine/IdCommand.cs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,22 @@ public sealed class IdCommand : IEngineBaseCommand
2121

2222
public static string GetLynxVersion()
2323
{
24-
return
25-
Assembly.GetAssembly(typeof(IdCommand))
26-
!.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
27-
?.InformationalVersion?.Split('+')[0]
28-
?? "Unknown";
24+
var fullVersion = Assembly.GetAssembly(typeof(IdCommand))
25+
!.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
26+
?.InformationalVersion;
27+
28+
var parts = fullVersion?.Split('+');
29+
30+
#if LYNX_RELEASE
31+
return parts?[0] ?? "Unknown";
32+
#else
33+
return parts?.Length switch
34+
{
35+
>= 2 => $"{parts[0]}-dev-{parts[1][..Math.Min(7, parts[1].Length)]}",
36+
1 => parts[0],
37+
_ => "Unknown"
38+
};
39+
#endif
2940
}
3041

3142
public static string NameString => $"id name {EngineName} {GetLynxVersion()}";

0 commit comments

Comments
 (0)