changed pipeline #31
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: NEXUS Release | |
| on: | |
| push: | |
| tags: | |
| - "v*.*.*" | |
| - "v*.*.*-*" | |
| paths: | |
| - 'NEXUS.Fractal/**' | |
| - 'NEXUS.Growth/**' | |
| - 'NEXUS.Growth.Simulation/**' | |
| - '.github/workflows/release.yml' | |
| permissions: | |
| contents: write | |
| jobs: | |
| build-and-release: | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Get full history for better change detection | |
| - name: Extract version from tag | |
| id: extract-version | |
| shell: pwsh | |
| run: | | |
| $tag = $env:GITHUB_REF -replace "refs/tags/v", "" | |
| $version = $tag -replace "-.*", "" | |
| $app = $tag -replace ".*-", "" | |
| # If no app suffix, set to empty | |
| if ($app -eq $tag) { $app = "" } | |
| echo "version=$version" >> $env:GITHUB_OUTPUT | |
| echo "app=$app" >> $env:GITHUB_OUTPUT | |
| echo "VERSION=$version" >> $env:GITHUB_ENV | |
| echo "APP=$app" >> $env:GITHUB_ENV | |
| Write-Host "Extracted version: $version, app: $app" | |
| - name: Find project files | |
| id: find-projects | |
| shell: pwsh | |
| run: | | |
| $projects = @{} | |
| # Look for project files in different possible locations | |
| $fractalProj = Get-ChildItem -Path . -Recurse -Filter "NEXUS.Fractal.*proj" | Select-Object -First 1 | |
| $growthProj = Get-ChildItem -Path . -Recurse -Filter "NEXUS.Growth.*proj" | Select-Object -First 1 | |
| $simulationProj = Get-ChildItem -Path . -Recurse -Filter "NEXUS.Growth.Simulation.*proj" | Select-Object -First 1 | |
| if ($fractalProj) { | |
| $projects["fractal"] = $fractalProj.FullName | |
| Write-Host "Found Fractal project: $($fractalProj.FullName)" | |
| } | |
| if ($growthProj) { | |
| $projects["growth"] = $growthProj.FullName | |
| Write-Host "Found Growth project: $($growthProj.FullName)" | |
| } | |
| if ($simulationProj) { | |
| $projects["simulation"] = $simulationProj.FullName | |
| Write-Host "Found Simulation project: $($simulationProj.FullName)" | |
| } | |
| # Convert to JSON for output | |
| $projectsJson = $projects | ConvertTo-Json -Compress | |
| echo "projects=$projectsJson" >> $env:GITHUB_OUTPUT | |
| Write-Host "Projects found: $projectsJson" | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 9.0.x | |
| - name: Determine apps to build | |
| id: determine-apps | |
| shell: pwsh | |
| run: | | |
| $projects = '${{ steps.find-projects.outputs.projects }}' | ConvertFrom-Json -AsHashtable | |
| # If specific app requested in tag, build only that | |
| if ("${{ env.APP }}" -ne "") { | |
| $app = "${{ env.APP }}".ToLower() | |
| if ($projects.ContainsKey($app)) { | |
| echo "Building only $app as specified in tag" | |
| echo "apps=$app" >> $env:GITHUB_OUTPUT | |
| exit 0 | |
| } else { | |
| Write-Warning "Requested app '$app' not found in projects" | |
| } | |
| } | |
| # Otherwise determine based on changes | |
| $changedFiles = git diff --name-only HEAD^ HEAD | |
| $apps = @() | |
| if ($changedFiles -like "*NEXUS.Fractal*" -and $projects.ContainsKey("fractal")) { | |
| $apps += "fractal" | |
| } | |
| if ($changedFiles -like "*NEXUS.Growth*" -and $projects.ContainsKey("growth")) { | |
| $apps += "growth" | |
| } | |
| if ($changedFiles -like "*NEXUS.Growth.Simulation*" -and $projects.ContainsKey("simulation")) { | |
| $apps += "simulation" | |
| } | |
| # If no changes detected or no apps selected, build all available | |
| if ($apps.Count -eq 0) { | |
| $apps = $projects.Keys | ForEach-Object { $_ } | |
| } | |
| echo "apps=$($apps -join ',')" >> $env:GITHUB_OUTPUT | |
| Write-Host "Apps to build: $($apps -join ', ')" | |
| - name: Build NEXUS.Fractal | |
| if: contains(steps.determine-apps.outputs.apps, 'fractal') | |
| shell: pwsh | |
| run: | | |
| $projects = '${{ steps.find-projects.outputs.projects }}' | ConvertFrom-Json -AsHashtable | |
| $projectPath = $projects["fractal"] | |
| $version = "${{ env.VERSION }}" | |
| Write-Host "Building Fractal from: $projectPath" | |
| Write-Host "Version: $version" | |
| dotnet publish "$projectPath" -c Release -r win-x64 --self-contained true ` | |
| -p:PublishSingleFile=false ` | |
| -p:IncludeAllContentForSelfExtract=false ` | |
| -p:Version=$version ` | |
| -p:FileVersion=$version ` | |
| -p:AssemblyVersion=$version.0 ` | |
| -o ./artifacts/Fractal | |
| - name: Build NEXUS.Growth | |
| if: contains(steps.determine-apps.outputs.apps, 'growth') | |
| shell: pwsh | |
| run: | | |
| $projects = '${{ steps.find-projects.outputs.projects }}' | ConvertFrom-Json -AsHashtable | |
| $projectPath = $projects["growth"] | |
| $version = "${{ env.VERSION }}" | |
| Write-Host "Building Growth from: $projectPath" | |
| Write-Host "Version: $version" | |
| dotnet publish "$projectPath" -c Release -r win-x64 --self-contained true ` | |
| -p:PublishSingleFile=false ` | |
| -p:IncludeAllContentForSelfExtract=false ` | |
| -p:Version=$version ` | |
| -p:FileVersion=$version ` | |
| -p:AssemblyVersion=$version.0 ` | |
| -o ./artifacts/Growth | |
| - name: Build NEXUS.Growth.Simulation | |
| if: contains(steps.determine-apps.outputs.apps, 'simulation') | |
| shell: pwsh | |
| run: | | |
| $projects = '${{ steps.find-projects.outputs.projects }}' | ConvertFrom-Json -AsHashtable | |
| $projectPath = $projects["simulation"] | |
| $version = "${{ env.VERSION }}" | |
| Write-Host "Building Simulation from: $projectPath" | |
| Write-Host "Version: $version" | |
| dotnet publish "$projectPath" -c Release -r win-x64 --self-contained true ` | |
| -p:PublishSingleFile=false ` | |
| -p:IncludeAllContentForSelfExtract=false ` | |
| -p:Version=$version ` | |
| -p:FileVersion=$version ` | |
| -p:AssemblyVersion=$version.0 ` | |
| -o ./artifacts/Simulation | |
| - name: Verify artifacts | |
| shell: pwsh | |
| run: | | |
| Write-Host "Artifact directory structure:" | |
| Get-ChildItem -Path ./artifacts -Recurse | Format-Table FullName | |
| if (Test-Path "./artifacts/Fractal") { | |
| Write-Host "Fractal artifacts:" | |
| Get-ChildItem "./artifacts/Fractal" | Format-Table Name, Length | |
| } | |
| if (Test-Path "./artifacts/Growth") { | |
| Write-Host "Growth artifacts:" | |
| Get-ChildItem "./artifacts/Growth" | Format-Table Name, Length | |
| } | |
| if (Test-Path "./artifacts/Simulation") { | |
| Write-Host "Simulation artifacts:" | |
| Get-ChildItem "./artifacts/Simulation" | Format-Table Name, Length | |
| } | |
| - name: Create ZIP archives | |
| id: create-archives | |
| shell: pwsh | |
| run: | | |
| $version = "${{ env.VERSION }}" | |
| $files = @() | |
| if (Test-Path "./artifacts/Fractal") { | |
| $fractalFiles = Get-ChildItem "./artifacts/Fractal" -File | |
| if ($fractalFiles.Count -gt 0) { | |
| Compress-Archive -Path "./artifacts/Fractal/*" -DestinationPath "./NEXUS.Fractal-$version.zip" | |
| $files += "NEXUS.Fractal-$version.zip" | |
| Write-Host "Created Fractal archive with $($fractalFiles.Count) files" | |
| } | |
| } | |
| if (Test-Path "./artifacts/Growth") { | |
| $growthFiles = Get-ChildItem "./artifacts/Growth" -File | |
| if ($growthFiles.Count -gt 0) { | |
| Compress-Archive -Path "./artifacts/Growth/*" -DestinationPath "./NEXUS.Growth-$version.zip" | |
| $files += "NEXUS.Growth-$version.zip" | |
| Write-Host "Created Growth archive with $($growthFiles.Count) files" | |
| } | |
| } | |
| if (Test-Path "./artifacts/Simulation") { | |
| $simulationFiles = Get-ChildItem "./artifacts/Simulation" -File | |
| if ($simulationFiles.Count -gt 0) { | |
| Compress-Archive -Path "./artifacts/Simulation/*" -DestinationPath "./NEXUS.Simulation-$version.zip" | |
| $files += "NEXUS.Simulation-$version.zip" | |
| Write-Host "Created Simulation archive with $($simulationFiles.Count) files" | |
| } | |
| } | |
| echo "files=$($files -join ',')" >> $env:GITHUB_OUTPUT | |
| Write-Host "Created archives: $($files -join ', ')" | |
| - name: Calculate MD5 hashes | |
| id: calculate-hashes | |
| shell: pwsh | |
| run: | | |
| $version = "${{ env.VERSION }}" | |
| $hashes = @() | |
| if (Test-Path "./NEXUS.Fractal-$version.zip") { | |
| $hash = (Get-FileHash "./NEXUS.Fractal-$version.zip" -Algorithm MD5).Hash | |
| $hashes += "NEXUS.Fractal - $hash" | |
| } | |
| if (Test-Path "./NEXUS.Growth-$version.zip") { | |
| $hash = (Get-FileHash "./NEXUS.Growth-$version.zip" -Algorithm MD5).Hash | |
| $hashes += "NEXUS.Growth - $hash" | |
| } | |
| if (Test-Path "./NEXUS.Simulation-$version.zip") { | |
| $hash = (Get-FileHash "./NEXUS.Simulation-$version.zip" -Algorithm MD5).Hash | |
| $hashes += "NEXUS.Simulation - $hash" | |
| } | |
| $hashes | Out-File -FilePath "./hashes.md5" | |
| echo "hashes=$($hashes -join '|')" >> $env:GITHUB_OUTPUT | |
| Write-Host "Hashes calculated and saved to hashes.md5" | |
| - name: Prepare release body | |
| id: prepare-release-body | |
| shell: pwsh | |
| run: | | |
| $version = "${{ env.VERSION }}" | |
| # Формируем список приложений | |
| $appsList = [System.Collections.ArrayList]@() | |
| if (Test-Path "./NEXUS.Fractal-$version.zip") { $appsList.Add("- NEXUS.Fractal (Avalonia)") | Out-Null } | |
| if (Test-Path "./NEXUS.Growth-$version.zip") { $appsList.Add("- NEXUS.Growth (Avalonia)") | Out-Null } | |
| if (Test-Path "./NEXUS.Simulation-$version.zip") { $appsList.Add("- NEXUS.Growth.Simulation (Console)") | Out-Null } | |
| # Получаем хеши | |
| $hashesContent = Get-Content ./hashes.md5 -Raw | |
| # Формируем тело релиза | |
| $bodyLines = @( | |
| "NEXUS Desktop Applications Release $version", | |
| "", | |
| "## Included Applications", | |
| $appsList -join "`n", | |
| "", | |
| "## MD5 Hashes", | |
| "```", | |
| $hashesContent, | |
| "```", | |
| "", | |
| "## Notes", | |
| "- Applications are published as full folders (not single-file)", | |
| "- Self-contained Windows x64 builds", | |
| "- Extract ZIP and run the executable" | |
| ) | |
| $body = $bodyLines -join "`n" | |
| # Сохраняем в файл | |
| $body | Out-File -FilePath "./release_body.md" -Encoding utf8 | |
| Write-Host "Release body prepared" | |
| - name: Create GitHub Release | |
| id: create-release | |
| uses: softprops/action-gh-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: ${{ github.ref }} | |
| release_name: NEXUS ${{ env.VERSION }}${{ env.APP && format(' ({0})', env.APP) || '' }} | |
| body_file: release_body.md | |
| files: | | |
| NEXUS.*.zip | |
| hashes.md5 |