@@ -25,15 +25,14 @@ jobs:
2525 - name : Restore dependencies
2626 run : dotnet restore -r linux-x64
2727
28- - name : Build
29- run : dotnet build -c Release -r linux-x64 --no-restore
30-
31- - name : Get version
28+ - name : Build and extract version
3229 id : version
3330 run : |
34- VERSION=$(dotnet msbuild BusLane.csproj -getProperty:Version -p:Configuration=Release)
31+ BUILD_OUTPUT=$(dotnet build -c Release -r linux-x64 --no-restore 2>&1)
32+ echo "$BUILD_OUTPUT"
33+ VERSION=$(echo "$BUILD_OUTPUT" | grep -oP "MinVer: Calculated version \K[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?" || echo "0.0.0")
3534 echo "version=$VERSION" >> $GITHUB_OUTPUT
36- echo "Building version: $VERSION"
35+ echo "Extracted version: $VERSION"
3736
3837 - name : Publish
3938 run : dotnet publish -c Release -r linux-x64 --self-contained -o ./publish --no-build
@@ -66,15 +65,18 @@ jobs:
6665 - name : Restore dependencies
6766 run : dotnet restore -r win-x64
6867
69- - name : Build
70- run : dotnet build -c Release -r win-x64 --no-restore
71-
72- - name : Get version
68+ - name : Build and extract version
7369 id : version
7470 run : |
75- $VERSION = dotnet msbuild BusLane.csproj -getProperty:Version -p:Configuration=Release
71+ $BUILD_OUTPUT = dotnet build -c Release -r win-x64 --no-restore 2>&1 | Out-String
72+ Write-Output $BUILD_OUTPUT
73+ if ($BUILD_OUTPUT -match "MinVer: Calculated version ([0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?)") {
74+ $VERSION = $matches[1]
75+ } else {
76+ $VERSION = "0.0.0"
77+ }
7678 echo "version=$VERSION" >> $env:GITHUB_OUTPUT
77- echo "Building version: $VERSION"
79+ Write-Output "Extracted version: $VERSION"
7880
7981 - name : Publish
8082 run : dotnet publish -c Release -r win-x64 --self-contained -o ./publish --no-build
@@ -115,15 +117,14 @@ jobs:
115117 - name : Restore dependencies for runtime
116118 run : dotnet restore -r ${{ matrix.runtime }}
117119
118- - name : Build
119- run : dotnet build -c Release -r ${{ matrix.runtime }} --no-restore
120-
121- - name : Get version
120+ - name : Build and extract version
122121 id : version
123122 run : |
124- VERSION=$(dotnet msbuild BusLane.csproj -getProperty:Version -p:Configuration=Release)
123+ BUILD_OUTPUT=$(dotnet build -c Release -r ${{ matrix.runtime }} --no-restore 2>&1)
124+ echo "$BUILD_OUTPUT"
125+ VERSION=$(echo "$BUILD_OUTPUT" | grep -oP "MinVer: Calculated version \K[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?" || echo "0.0.0")
125126 echo "version=$VERSION" >> $GITHUB_OUTPUT
126- echo "Building version: $VERSION"
127+ echo "Extracted version: $VERSION"
127128
128129 - name : Publish
129130 run : dotnet publish -c Release -r ${{ matrix.runtime }} --self-contained -o ./publish --no-build
0 commit comments