Skip to content

Commit 39620a8

Browse files
Added Nerdbank.GitVersioning
1 parent 9cc0a5e commit 39620a8

8 files changed

Lines changed: 37 additions & 31 deletions

File tree

.github/workflows/build-project.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ env:
1414
DOTNET_VERSION: 8
1515
DOTNET_CLI_HOME: /tmp/.dotnet
1616
FREEDESKTOP_VERSION: 24.08
17-
APP_VERSION: 8.0.0.${{github.run_number}}
1817

1918
jobs:
2019
build:
@@ -47,7 +46,7 @@ jobs:
4746
run: dotnet restore ${{ env.PROJECT_PATH }}
4847

4948
- name: ${{ matrix.rid }} Build
50-
run: dotnet publish -p:DefineConstants=AUTOBUILD -p:PublishProfile=${{ matrix.rid }} -p:AssemblyVersion=${{ env.APP_VERSION }} -p:FileVersion=${{ env.APP_VERSION}} -c Release -o ./output/${{ matrix.rid }} ${{ env.PROJECT_PATH }}
49+
run: dotnet publish -p:DefineConstants=COMMITBUILD -p:PublishProfile=${{ matrix.rid }} -c Release -o ./output/${{ matrix.rid }} ${{ env.PROJECT_PATH }}
5150

5251
- name: Upload Artifact
5352
uses: actions/upload-artifact@v4

.github/workflows/build-release.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ name: Build Release
33
on:
44
workflow_dispatch:
55
inputs:
6-
version:
7-
description: 'Version'
8-
required: true
9-
default: '8.0.0.4'
106
tag:
117
description: 'Tag'
128
required: true
@@ -73,12 +69,10 @@ jobs:
7369
python3 flatpak-dotnet-generator.py ./flatpak/nuget-sources.json ${{env.PROJECT_PATH}} --dotnet ${{env.DOTNET_VERSION}} --freedesktop ${{env.FREEDESKTOP_VERSION}}
7470
7571
- name: win-x64 Build
76-
run: dotnet publish -p:PublishProfile=win-x64 -c Release -p:AssemblyVersion=${{ github.event.inputs.version }} -p:FileVersion=${{ github.event.inputs.version }} -o ./output/win-x64 ${{env.PROJECT_PATH}}
72+
run: dotnet publish -p:PublishProfile=win-x64 -c Release -o ./output/win-x64 ${{env.PROJECT_PATH}}
7773

7874
- name: flatpak-x86_64 Build
79-
env:
80-
APP_VERSION: ${{ github.event.inputs.version }}
81-
run: flatpak-builder --user --force-clean --install-deps-from=flathub --repo=repo builddir ./flatpak/${{ env.FLATPAK_ID }}.yml
75+
run: flatpak-builder --user --force-clean --install-deps-from=flathub --repo=repo builddir ./flatpak/${{env.FLATPAK_ID}}.yml
8276

8377
- name: Build Flatpak Bundle
8478
run: flatpak build-bundle repo ./flatpak/${{env.FLATPAK_ID}}.flatpak ${{env.FLATPAK_ID}}

Source/HedgeModManager.UI/Controls/Sidebar.axaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
<c:SidebarButton Type="Normal" Click="OnRunClicked" Icon="{DynamicResource Geometry.Play}" IsEnabled="{Binding IsBusy, Converter={StaticResource InvertedBoolConverter}}" />
7272
</StackPanel>
7373
<TextBlock Text="{Binding AppVersion}"
74-
Margin="16,16,16,0" TextWrapping="Wrap"
74+
Margin="14,16,14,0" TextWrapping="Wrap"
7575
TextAlignment="Center"
7676
HorizontalAlignment="Center" />
7777
</StackPanel>

Source/HedgeModManager.UI/HedgeModManager.UI.csproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
<ApplicationManifest>app.manifest</ApplicationManifest>
88
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
99
<ApplicationIcon>Assets\icon.ico</ApplicationIcon>
10-
<AssemblyVersion Condition="'$(AssemblyVersion)' == ''">8.0.0.4</AssemblyVersion>
11-
<FileVersion Condition="'$(FileVersion)' == ''">8.0.0.4</FileVersion>
1210
</PropertyGroup>
1311
<PropertyGroup Label="Avalonia">
1412
<AvaloniaXamlReportImportance>Low</AvaloniaXamlReportImportance>
@@ -40,6 +38,10 @@
4038
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
4139
<PackageReference Include="Markdig" Version="0.40.0" />
4240
<PackageReference Include="Material.Icons.Avalonia" Version="2.2.0" />
41+
<PackageReference Include="Nerdbank.GitVersioning" Version="3.7.115">
42+
<PrivateAssets>all</PrivateAssets>
43+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
44+
</PackageReference>
4345
</ItemGroup>
4446

4547
<ItemGroup>

Source/HedgeModManager.UI/Program.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -178,26 +178,26 @@ static void installToRegistery(string schema, string args)
178178

179179
public static string GetFormattedAppVersion()
180180
{
181-
string unstableType = "beta";
182-
#if AUTOBUILD
183-
unstableType = "dev";
181+
string commitHash = ThisAssembly.GitCommitId[..7];
182+
if (Version.TryParse(ThisAssembly.AssemblyFileVersion, out Version? version) && version != null)
183+
{
184+
string baseVersion = $"{version.Major}.{version.Minor}.{version.Build}";
185+
#if COMMITBUILD
186+
return $"{baseVersion} {commitHash}";
187+
#else
188+
if (version.Revision == 0)
189+
return baseVersion;
190+
return $"{baseVersion} beta {version.Revision}";
184191
#endif
185-
186-
var version = Assembly.GetExecutingAssembly().GetName().Version ?? Version.Parse("0");
187-
if (version.Revision == 0)
188-
return $"{version.Major}.{version.Minor}.{version.Build}";
189-
return $"{version.Major}.{version.Minor}.{version.Build} {unstableType} {version.Revision}";
192+
}
193+
return commitHash;
190194
}
191195

192196
public static string GetTagName()
193197
{
194-
string unstableType = "beta";
195-
#if AUTOBUILD
196-
unstableType = "dev";
197-
#endif
198-
199-
var version = Assembly.GetExecutingAssembly().GetName().Version ?? Version.Parse("0");
200-
return $"{version.Major}.{version.Minor}.{version.Build}-{unstableType}{version.Revision}";
198+
if (Version.TryParse(ThisAssembly.AssemblyFileVersion, out Version? version) && version != null)
199+
return $"{version.Major}.{version.Minor}.{version.Build}-beta{version.Revision}";
200+
return "0";
201201
}
202202

203203
// Avalonia configuration, don't remove; also used by visual designer.

Source/HedgeModManager.UI/ViewModels/MainWindowViewModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,10 @@ public async Task OnStartUpAsync()
102102
if (Config.LastUpdateCheck.AddMinutes(20) < DateTime.Now &&
103103
!Design.IsDesignMode && !Program.IsDebugBuild)
104104
{
105+
#if !COMMITBUILD
105106
if (OperatingSystem.IsWindows())
106107
await CheckForManagerUpdatesAsync();
108+
#endif
107109

108110
try
109111
{
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/main/src/NerdBank.GitVersioning/version.schema.json",
3+
"version": "8.0.0.4",
4+
"publicReleaseRefSpec": [
5+
"^refs/heads/main",
6+
"^refs/heads/rel/v\\d+\\.\\d+"
7+
],
8+
"nugetPackageVersion": {
9+
"semVer": 2
10+
}
11+
}

flatpak/io.github.hedge_dev.hedgemodmanager-autobuild.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,8 @@ modules:
4646
- type: dir
4747
path: ../
4848
- ./nuget-sources.json
49-
secret-env:
50-
- APP_VERSION
5149
build-commands:
52-
- dotnet publish Source/HedgeModManager.UI/HedgeModManager.UI.csproj -c Release -p:DefineConstants=AUTOBUILD -p:AssemblyVersion=${APP_VERSION} -p:FileVersion=${APP_VERSION} --no-self-contained --source ./nuget-sources
50+
- dotnet publish Source/HedgeModManager.UI/HedgeModManager.UI.csproj -c Release -p:DefineConstants=COMMITBUILD --no-self-contained --source ./nuget-sources
5351
- mkdir -p ${FLATPAK_DEST}/bin
5452
- cp -r Source/HedgeModManager.UI/bin/Release/net8.0/publish/* ${FLATPAK_DEST}/bin
5553
- install -Dm644 flatpak/hedgemodmanager.png ${FLATPAK_DEST}/share/icons/hicolor/256x256/apps/${FLATPAK_ID}.png

0 commit comments

Comments
 (0)