1.0.5.fix.fix #8
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Lizerium Localization Toolkit Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| env: | |
| DOTNET_VERSION: 8.0.x | |
| CONFIGURATION: Release | |
| RID: win-x64 | |
| ARTIFACT_PREFIX: Lizerium.Localization.Toolkit | |
| jobs: | |
| release: | |
| name: Build release assets | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: ${{ env.DOTNET_VERSION }} | |
| - name: Setup MSBuild | |
| uses: microsoft/setup-msbuild@v2 | |
| - name: Resolve release version | |
| shell: pwsh | |
| run: | | |
| $releaseTag = "${{ github.ref_name }}" | |
| function Get-ProjectProperty([string]$project, [string]$propertyName) { | |
| $xml = [xml](Get-Content $project) | |
| foreach ($group in $xml.Project.PropertyGroup) { | |
| $value = $group.$propertyName | |
| if (-not [string]::IsNullOrWhiteSpace($value)) { | |
| return $value.Trim() | |
| } | |
| } | |
| return $null | |
| } | |
| function Resolve-ProjectVersion([string]$project) { | |
| $version = Get-ProjectProperty $project "PackageVersion" | |
| if ([string]::IsNullOrWhiteSpace($version)) { | |
| $version = Get-ProjectProperty $project "Version" | |
| } | |
| if ($version -match '^\$\((?<PropertyName>[^)]+)\)$') { | |
| $version = Get-ProjectProperty $project $Matches.PropertyName | |
| } | |
| if ([string]::IsNullOrWhiteSpace($version)) { | |
| $version = Get-ProjectProperty $project "VsixPackageVersion" | |
| } | |
| if ([string]::IsNullOrWhiteSpace($version)) { | |
| throw "Cannot resolve version from $project" | |
| } | |
| return $version | |
| } | |
| if ("${{ github.ref_type }}" -ne "tag") { | |
| $releaseVersion = Resolve-ProjectVersion "src/Lizerium.Localization.Toolkit/Lizerium.Localization.Toolkit.csproj" | |
| $releaseTag = "v$releaseVersion" | |
| } | |
| "RELEASE_TAG=$releaseTag" >> $env:GITHUB_ENV | |
| - name: Restore solution | |
| run: dotnet restore Lizerium.Localization.Toolkit.sln | |
| - name: Build solution | |
| run: dotnet build Lizerium.Localization.Toolkit.sln -c ${{ env.CONFIGURATION }} --no-restore | |
| - name: Test AI localization | |
| run: > | |
| dotnet test src/Lizerium.AI.LocalizationAssistant.Tests/Lizerium.AI.LocalizationAssistant.Tests.csproj | |
| -c ${{ env.CONFIGURATION }} | |
| --no-restore | |
| --no-build | |
| --filter "Category!=LiveOllama" | |
| - name: Pack changed NuGet packages | |
| shell: pwsh | |
| run: | | |
| New-Item -ItemType Directory -Force artifacts/nuget | Out-Null | |
| function Get-ProjectPropertyFromText([string]$text, [string]$propertyName) { | |
| $text = $text.TrimStart([char]0xFEFF) | |
| $escapedName = [System.Text.RegularExpressions.Regex]::Escape($propertyName) | |
| $match = [System.Text.RegularExpressions.Regex]::Match( | |
| $text, | |
| "<\s*$escapedName(?:\s+[^>]*)?\s*>(?<Value>.*?)</\s*$escapedName\s*>", | |
| [System.Text.RegularExpressions.RegexOptions]::Singleline) | |
| if ($match.Success) { | |
| return $match.Groups["Value"].Value.Trim() | |
| } | |
| return $null | |
| } | |
| function Resolve-VersionFromText([string]$text) { | |
| $version = Get-ProjectPropertyFromText $text "PackageVersion" | |
| if ([string]::IsNullOrWhiteSpace($version)) { | |
| $version = Get-ProjectPropertyFromText $text "Version" | |
| } | |
| if ($version -match '^\$\((?<PropertyName>[^)]+)\)$') { | |
| $version = Get-ProjectPropertyFromText $text $Matches.PropertyName | |
| } | |
| if ([string]::IsNullOrWhiteSpace($version)) { | |
| throw "Cannot resolve version" | |
| } | |
| return $version | |
| } | |
| function Resolve-ProjectVersion([string]$project) { | |
| return Resolve-VersionFromText (Get-Content $project -Raw) | |
| } | |
| $currentTag = "${{ github.ref_name }}" | |
| $previousTag = git tag --sort=-v:refname | | |
| Where-Object { $_ -match '^v\d+\.\d+\.\d+$' -and $_ -ne $currentTag } | | |
| Select-Object -First 1 | |
| Write-Host "Current tag: $currentTag" | |
| Write-Host "Previous tag: $previousTag" | |
| $projects = @( | |
| "src/Lizerium.Localization.Core/Lizerium.Localization.Core.csproj", | |
| "src/Lizerium.AI.LocalizationAssistant.Core/Lizerium.AI.LocalizationAssistant.Core.csproj", | |
| "src/Lizerium.Localization.Generator/Lizerium.Localization.Generator.csproj", | |
| "src/Lizerium.Localization.Analyzer/Lizerium.Localization.Analyzer.csproj", | |
| "src/Lizerium.Localization.Ai.Analyzer/Lizerium.Localization.Ai.Analyzer.csproj", | |
| "src/Lizerium.Localization.Toolkit/Lizerium.Localization.Toolkit.csproj", | |
| "src/Lizerium.Localization.GUI/Lizerium.Localization.GUI.csproj" | |
| ) | |
| foreach ($project in $projects) { | |
| $version = Resolve-ProjectVersion $project | |
| $previousVersion = $null | |
| if (-not [string]::IsNullOrWhiteSpace($previousTag)) { | |
| $previousText = git show "$previousTag`:$project" 2>$null | |
| if ($LASTEXITCODE -eq 0 -and $previousText) { | |
| $previousVersion = Resolve-VersionFromText ($previousText -join "`n") | |
| } | |
| } | |
| if ($version -eq $previousVersion) { | |
| Write-Host "Skipping $project, version unchanged: $version" | |
| continue | |
| } | |
| Write-Host "Packing $project version $version" | |
| dotnet pack $project ` | |
| -c $env:CONFIGURATION ` | |
| -p:Version=$version ` | |
| -p:PackageVersion=$version ` | |
| -o artifacts/nuget ` | |
| --no-restore ` | |
| --no-build | |
| } | |
| if (-not (Get-ChildItem artifacts/nuget/*.nupkg -ErrorAction SilentlyContinue)) { | |
| Write-Host "No NuGet package versions changed; creating marker file." | |
| "No NuGet package versions changed." | Set-Content artifacts/nuget/NO_NUGET_PACKAGES_CHANGED.txt -Encoding UTF8 | |
| } | |
| - name: Build VSIX packages | |
| shell: pwsh | |
| run: | | |
| New-Item -ItemType Directory -Force artifacts/vsix | Out-Null | |
| function Get-ProjectProperty([string]$project, [string]$propertyName) { | |
| $xml = [xml](Get-Content $project) | |
| foreach ($group in $xml.Project.PropertyGroup) { | |
| $value = $group.$propertyName | |
| if (-not [string]::IsNullOrWhiteSpace($value)) { | |
| return $value.Trim() | |
| } | |
| } | |
| return $null | |
| } | |
| function Resolve-VsixVersion([string]$project) { | |
| $version = Get-ProjectProperty $project "VsixPackageVersion" | |
| if ([string]::IsNullOrWhiteSpace($version)) { | |
| $version = Get-ProjectProperty $project "Version" | |
| } | |
| if ($version -match '^\$\((?<PropertyName>[^)]+)\)$') { | |
| $version = Get-ProjectProperty $project $Matches.PropertyName | |
| } | |
| if ([string]::IsNullOrWhiteSpace($version)) { | |
| throw "Cannot resolve VSIX version from $project" | |
| } | |
| return $version | |
| } | |
| $vsixProjects = @( | |
| @{ | |
| Project = "src/Lizerium.Localization.Xaml.Vsix/Lizerium.Localization.Xaml.Vsix.csproj" | |
| PackageId = "Lizerium.Localization.Xaml.Vsix" | |
| }, | |
| @{ | |
| Project = "src/Lizerium.Localization.EditorHints/Lizerium.Localization.EditorHints.csproj" | |
| PackageId = "Lizerium.Localization.EditorHints" | |
| } | |
| ) | |
| foreach ($item in $vsixProjects) { | |
| $version = Resolve-VsixVersion $item.Project | |
| $output = "src/$($item.PackageId)/bin/$env:CONFIGURATION/net472/$($item.PackageId).$version.vsix" | |
| $releaseName = "$($item.PackageId)-v$version.vsix" | |
| Write-Host "Building $($item.Project) version $version" | |
| msbuild $item.Project ` | |
| /t:Build ` | |
| /p:Configuration=$env:CONFIGURATION ` | |
| /p:RestorePackages=false ` | |
| /p:VsixPackageVersion=$version ` | |
| /p:Version=$version ` | |
| /v:minimal | |
| Copy-Item $output "artifacts/vsix/$releaseName" -Force | |
| } | |
| - name: Restore publish projects | |
| run: | | |
| dotnet restore src/Lizerium.Localization.GUI/Lizerium.Localization.GUI.csproj -r ${{ env.RID }} | |
| dotnet restore samples/WpfSampleApp/WpfSampleApp.csproj -r ${{ env.RID }} | |
| - name: Publish GUI | |
| run: > | |
| dotnet publish src/Lizerium.Localization.GUI/Lizerium.Localization.GUI.csproj | |
| -c ${{ env.CONFIGURATION }} | |
| -r ${{ env.RID }} | |
| --self-contained true | |
| --no-restore | |
| -p:PublishSingleFile=true | |
| -p:IncludeNativeLibrariesForSelfExtract=true | |
| -p:DebugType=None | |
| -p:DebugSymbols=false | |
| -o artifacts/publish/gui/${{ env.RID }} | |
| - name: Publish Sample | |
| run: > | |
| dotnet publish samples/WpfSampleApp/WpfSampleApp.csproj | |
| -c ${{ env.CONFIGURATION }} | |
| -r ${{ env.RID }} | |
| --self-contained true | |
| --no-restore | |
| -p:PublishSingleFile=true | |
| -p:IncludeNativeLibrariesForSelfExtract=true | |
| -p:DebugType=None | |
| -p:DebugSymbols=false | |
| -o artifacts/publish/sample/${{ env.RID }} | |
| - name: Pack release assets | |
| shell: pwsh | |
| run: | | |
| $tag = $env:RELEASE_TAG | |
| $prefix = "${{ env.ARTIFACT_PREFIX }}" | |
| New-Item -ItemType Directory -Force artifacts/release | Out-Null | |
| Compress-Archive ` | |
| -Path artifacts/publish/gui/${{ env.RID }}/* ` | |
| -DestinationPath "artifacts/release/$prefix-GUI-$tag-${{ env.RID }}.zip" ` | |
| -Force | |
| Compress-Archive ` | |
| -Path artifacts/publish/sample/${{ env.RID }}/* ` | |
| -DestinationPath "artifacts/release/$prefix-Sample-$tag-${{ env.RID }}.zip" ` | |
| -Force | |
| if (Get-ChildItem artifacts/nuget/*.nupkg -ErrorAction SilentlyContinue) { | |
| Compress-Archive ` | |
| -Path artifacts/nuget/*.nupkg ` | |
| -DestinationPath "artifacts/release/$prefix-NuGet-$tag.zip" ` | |
| -Force | |
| } | |
| Compress-Archive ` | |
| -Path samples/WpfSampleApp/* ` | |
| -DestinationPath "artifacts/release/$prefix-SampleSource-$tag.zip" ` | |
| -Force | |
| Copy-Item artifacts/vsix/*.vsix artifacts/release/ -Force | |
| Copy-Item CHANGELOG.md artifacts/release/CHANGELOG.md -Force | |
| Copy-Item CHANGELOG.ru.md artifacts/release/CHANGELOG.ru.md -Force | |
| Get-ChildItem artifacts/release -File | | |
| Get-FileHash -Algorithm SHA256 | | |
| ForEach-Object { "$($_.Hash) $(Split-Path $_.Path -Leaf)" } | | |
| Set-Content "artifacts/release/SHA256SUMS.txt" -Encoding UTF8 | |
| $vsixListRu = Get-ChildItem artifacts/vsix/*.vsix | | |
| Sort-Object Name | | |
| ForEach-Object { "- VSIX для Visual Studio 2022: ``$($_.Name)``" } | |
| $vsixNotesRu = $vsixListRu -join "`n" | |
| $vsixListEn = Get-ChildItem artifacts/vsix/*.vsix | | |
| Sort-Object Name | | |
| ForEach-Object { "- Visual Studio 2022 VSIX: ``$($_.Name)``" } | |
| $vsixNotesEn = $vsixListEn -join "`n" | |
| $nugetPackages = Get-ChildItem artifacts/nuget/*.nupkg -ErrorAction SilentlyContinue | | |
| Sort-Object Name | | |
| ForEach-Object { "- ``$($_.Name)``" } | |
| $nugetNotesRu = if ($nugetPackages) { $nugetPackages -join "`n" } else { "- NuGet-пакеты не пересобирались: версии `.csproj` не изменились." } | |
| $nugetNotesEn = if ($nugetPackages) { $nugetPackages -join "`n" } else { "- NuGet packages were not rebuilt because `.csproj` versions did not change." } | |
| $releaseNotes = @" | |
| ## Lizerium.Localization.Toolkit $tag | |
| ### Русский | |
| Полное описание изменений: | |
| - [Русский CHANGELOG](https://github.com/${{ github.repository }}/blob/${{ github.sha }}/CHANGELOG.ru.md) | |
| - [English CHANGELOG](https://github.com/${{ github.repository }}/blob/${{ github.sha }}/CHANGELOG.md) | |
| ### Что входит | |
| NuGet-пакеты, пересобранные для этого релиза: | |
| $nugetNotesRu | |
| $vsixNotesRu | |
| - Самостоятельная Windows x64 сборка GUI-редактора | |
| - Опубликованная Windows x64 сборка WPF sample-приложения | |
| - Архив исходников sample-проекта | |
| - SHA-256 checksums | |
| ### English | |
| Full changelog: | |
| - [Russian CHANGELOG](https://github.com/${{ github.repository }}/blob/${{ github.sha }}/CHANGELOG.ru.md) | |
| - [English CHANGELOG](https://github.com/${{ github.repository }}/blob/${{ github.sha }}/CHANGELOG.md) | |
| ### Included | |
| NuGet packages rebuilt for this release: | |
| $nugetNotesEn | |
| $vsixNotesEn | |
| - Standalone Windows x64 GUI editor build | |
| - Published Windows x64 WPF sample application | |
| - Sample project source archive | |
| - SHA-256 checksums | |
| "@ | |
| $releaseNotes | Set-Content "artifacts/release/RELEASE_NOTES.md" -Encoding UTF8 | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: release-assets-${{ github.ref_name }} | |
| path: artifacts/release/* | |
| - name: Upload GitHub Release | |
| if: startsWith(github.ref, 'refs/tags/') | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| generate_release_notes: true | |
| body_path: artifacts/release/RELEASE_NOTES.md | |
| files: | | |
| artifacts/release/*.zip | |
| artifacts/release/*.vsix | |
| artifacts/release/CHANGELOG.md | |
| artifacts/release/CHANGELOG.ru.md | |
| artifacts/release/SHA256SUMS.txt |