Skip to content

Commit

Permalink
feat: map about to git ahsh
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Sep 14, 2022
1 parent 7c8b6a0 commit e84b876
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
8 changes: 4 additions & 4 deletions publish.ps1
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
$fileversion = "$env:SemVer.0"
$path = (Get-Location).Path

dotnet pack -c Release -o $path\artifacts\build -p:Version=$env:Version -p:FileVersion=$fileversion
dotnet pack -c Release -o $path\artifacts\build -p:Version=$env:Version -p:FileVersion=$fileversion -p:SourceRevisionId=$env:APPVEYOR_REPO_COMMIT

dotnet publish src\Aguacongas.TheIdServer.IS4\Aguacongas.TheIdServer.IS4.csproj -c Release -o $path\artifacts\Aguacongas.TheIdServer.IS4 -p:Version=$env:Version -p:FileVersion=$fileversion
dotnet publish src\Aguacongas.TheIdServer.IS4\Aguacongas.TheIdServer.IS4.csproj -c Release -o $path\artifacts\Aguacongas.TheIdServer.IS4 -p:Version=$env:Version -p:FileVersion=$fileversion -p:SourceRevisionId=$env:APPVEYOR_REPO_COMMIT
if ($LASTEXITCODE -ne 0) {
throw "publis failed src/Aguacongas.TheIdServer/Aguacongas.TheIdServer.IS4.csproj"
}

dotnet publish src\Aguacongas.TheIdServer.Duende\Aguacongas.TheIdServer.Duende.csproj -c Release -o $path\artifacts\Aguacongas.TheIdServer.Duende -p:Version=$env:Version -p:FileVersion=$fileversion
dotnet publish src\Aguacongas.TheIdServer.Duende\Aguacongas.TheIdServer.Duende.csproj -c Release -o $path\artifacts\Aguacongas.TheIdServer.Duende -p:Version=$env:Version -p:FileVersion=$fileversion -p:SourceRevisionId=$env:APPVEYOR_REPO_COMMIT
if ($LASTEXITCODE -ne 0) {
throw "publis failed src/Aguacongas.TheIdServer/Aguacongas.TheIdServer.Duende.csproj"
}

dotnet publish src\Aguacongas.TheIdServer.BlazorApp\Aguacongas.TheIdServer.BlazorApp.csproj -c Release -o $path\artifacts\Aguacongas.TheIdServer.BlazorApp -p:Version=$env:Version -p:FileVersion=$fileversion
dotnet publish src\Aguacongas.TheIdServer.BlazorApp\Aguacongas.TheIdServer.BlazorApp.csproj -c Release -o $path\artifacts\Aguacongas.TheIdServer.BlazorApp -p:Version=$env:Version -p:FileVersion=$fileversion -p:SourceRevisionId=$env:APPVEYOR_REPO_COMMIT
if ($LASTEXITCODE -ne 0) {
throw "publish failed src/Aguacongas.TheIdServer.BlazorApp/Aguacongas.TheIdServer.BlazorApp.csproj"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,6 @@
</li>
</ul>
<div class="fixed-bottom bg-light col-1">
<a class="px-3" href="https://github.com/aguacongas/TheIdServer/blob/master/README.md" target="_blank">@Localizer["About"]</a>
<a class="px-3" href="https://github.com/aguacongas/TheIdServer/blob/@GitHash/README.md" target="_blank">@Localizer["About"]</a>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using Aguacongas.TheIdServer.BlazorApp.Models;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Options;
using System.Linq;
using System.Reflection;

namespace Aguacongas.TheIdServer.BlazorApp.Components
{
Expand All @@ -25,5 +27,30 @@ protected override void OnInitialized()
Localizer.OnResourceReady = () => InvokeAsync(StateHasChanged);
base.OnInitialized();
}

private string? _gitHash;

string GitHash
{
get
{
if (string.IsNullOrEmpty(_gitHash))
{
var version = "1.0.0+LOCALBUILD"; // Dummy version for local dev
var appAssembly = Assembly.GetExecutingAssembly();
var infoVerAttr = appAssembly.GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute))
.FirstOrDefault() as AssemblyInformationalVersionAttribute;

if (infoVerAttr is not null && infoVerAttr.InformationalVersion.Length > 6)
{
// Hash is embedded in the version after a '+' symbol, e.g. 1.0.0+a34a913742f8845d3da5309b7b17242222d41a21
version = infoVerAttr.InformationalVersion;
}
_gitHash = version[(version.IndexOf('+') + 1)..];
}

return _gitHash;
}
}
}
}

0 comments on commit e84b876

Please sign in to comment.