Skip to content

Commit 10f56a6

Browse files
committed
Write and read version to and from assembly
1 parent 8aff68f commit 10f56a6

File tree

7 files changed

+54
-13
lines changed

7 files changed

+54
-13
lines changed

.github/workflows/cd.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- name: Run tests
3434
run: dotnet run test
3535
- name: Run publishing script
36-
run: dotnet run publish
36+
run: dotnet run publish 0
3737
# For now I simply make a continuous build
3838
- name: Release files
3939
uses: marvinpinto/action-automatic-releases@latest

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- name: Restore
3434
run: dotnet run restore
3535
- name: Publish
36-
run: dotnet run publish
36+
run: dotnet run publish ${{ steps.tag_name.outputs.current_version }}
3737
- name: Get Changelog Entry
3838
id: changelog_reader
3939
uses: mindsers/changelog-reader-action@v2

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [0.5.1] - 2022-03-03
10+
11+
### Changed
12+
13+
- Add delivery as AppImage again
14+
- Write version to assembly (0 for dev builds)
15+
- Read version in bottom left corner from assembly
16+
917
## [0.5.0] - 2022-03-03
1018

1119
### Added

run.fs

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,28 @@ module Config =
2626

2727
let httpClient = new HttpClient()
2828

29+
module DotNet =
30+
let publishSelfContained outDir project version os =
31+
dotnet [
32+
"publish"
33+
"-r"
34+
DotNetOS.toString os
35+
"-v"
36+
"minimal"
37+
"-c"
38+
DotNetConfig.toString Release
39+
"-o"
40+
outDir
41+
"--self-contained"
42+
"/p:PublishSingleFile=true"
43+
"/p:PublishTrimmed=true"
44+
"/p:EnableCompressionInSingleFile=true"
45+
"/p:IncludeNativeLibrariesForSelfExtract=true"
46+
"/p:DebugType=None"
47+
$"/p:Version=%s{version}"
48+
project
49+
]
50+
2951
module Task =
3052
let restore () =
3153
job {
@@ -130,8 +152,9 @@ module Task =
130152

131153
result
132154

133-
let publish () =
134-
let publish = DotNet.publishSelfContained Config.publishPath Config.mainProject
155+
let publish version =
156+
let publish =
157+
DotNet.publishSelfContained Config.publishPath Config.mainProject version
135158

136159
Shell.mkdir Config.publishPath
137160
Shell.cleanDir Config.publishPath
@@ -175,11 +198,15 @@ let main args =
175198
Task.restore ()
176199
Task.runTest ()
177200
}
178-
| [ "publish" ] ->
201+
| [ "publish"; version ] ->
179202
job {
180203
Task.restore ()
181-
Task.publish ()
204+
Task.publish version
182205
}
206+
// Errors for missing arguments
207+
| [ "publish" ] ->
208+
let msg = [ "Missing version argument!" ]
209+
Error(1, msg)
183210
| _ ->
184211
let msg =
185212
[ "Usage: dotnet run [<command>]"

src/Andromeda/AvaloniaApp/Andromeda.AvaloniaApp.fsproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
<TargetFramework>net6.0</TargetFramework>
88
<ServerGarbageCollection>true</ServerGarbageCollection>
99
</PropertyGroup>
10+
<PropertyGroup>
11+
<Version>0</Version>
12+
</PropertyGroup>
1013

1114
<ItemGroup>
1215
<ProjectReference Include="../Core/Andromeda.Core.fsproj" />
@@ -15,7 +18,6 @@
1518
<ItemGroup>
1619
<AvaloniaResource Include="Assets\*" />
1720
<AvaloniaResource Include="Styles.xaml" />
18-
<Compile Include="Config.fs" />
1921
<Compile Include="Logger.fs" />
2022
<Compile Include="Icons.fs" />
2123
<Compile Include="DomainTypes.fs" />

src/Andromeda/AvaloniaApp/Config.fs

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/Andromeda/AvaloniaApp/ViewComponents/LeftBar.fs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ open Andromeda.AvaloniaApp
1212
open Andromeda.AvaloniaApp.Components.Main
1313
open Andromeda.AvaloniaApp.Elements
1414

15+
open System.Reflection
16+
1517
module LeftBar =
1618
[<RequireQualifiedAccess>]
1719
module Menu =
@@ -132,6 +134,13 @@ module LeftBar =
132134
]
133135

134136
let private bottomBarView downloads =
137+
let version =
138+
let assemblyVersion = Assembly.GetEntryAssembly().GetName().Version
139+
140+
match assemblyVersion with
141+
| v when v.Major > 0 -> $"v{v.Major}.{v.Minor}.{v.Build}"
142+
| _ -> "development build"
143+
135144
StackPanel.create [
136145
StackPanel.dock Dock.Bottom
137146
StackPanel.orientation Orientation.Vertical
@@ -140,7 +149,7 @@ module LeftBar =
140149
TextBlock.create [
141150
TextBlock.dock Dock.Bottom
142151
TextBlock.fontSize 10.0
143-
TextBlock.text Config.version
152+
TextBlock.text version
144153
]
145154
]
146155
]

0 commit comments

Comments
 (0)