From 9e655de179cc4aa69e3e0397bd2fa9f070bed592 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20C=C3=A1ceres?= Date: Sun, 6 Oct 2024 20:07:34 +0200 Subject: [PATCH] build imgui and extensions in same pipelines with same versions (#7) --- .../generate-bindings-nugets/action.yml | 10 +-- .github/workflows/cd-extensions.yml | 83 ------------------ .github/workflows/cd-imgui.yml | 4 +- .github/workflows/ci-extensions.yml | 33 ------- .github/workflows/ci-imgui.yml | 9 +- scripts/generate-bindings.ps1 | 85 ++++++++++--------- scripts/generate-nugets.ps1 | 47 +++++----- 7 files changed, 81 insertions(+), 190 deletions(-) delete mode 100644 .github/workflows/cd-extensions.yml delete mode 100644 .github/workflows/ci-extensions.yml diff --git a/.github/actions/generate-bindings-nugets/action.yml b/.github/actions/generate-bindings-nugets/action.yml index c102a04..f7460bc 100644 --- a/.github/actions/generate-bindings-nugets/action.yml +++ b/.github/actions/generate-bindings-nugets/action.yml @@ -1,10 +1,6 @@ name: Binding Nugets description: Generate and build bindings inputs: - ImX: - description: "Values: 'Imgui', 'Imguizmo', 'Imnodes' or 'Implot'. Default 'Imgui'" - required: false - default: Imgui NugetsPath: description: "Local path to deliver the nugets" required: false @@ -22,15 +18,15 @@ runs: shell: pwsh id: build_bindings run: | - .\scripts\generate-bindings.ps1 -ImX ${{ inputs.ImX }} + .\scripts\generate-bindings.ps1 - name: Generate NuGet packages shell: pwsh id: build_nugets run: | - .\scripts\generate-nugets.ps1 -ImX ${{ inputs.ImX }} -outputfolder ${{ inputs.NugetsPath }} + .\scripts\generate-nugets.ps1 -outputfolder ${{ inputs.NugetsPath }} - name: Save nugets uses: actions/upload-artifact@v4 with: - name: ${{ inputs.ImX }}-nugets + name: Imgui-nugets path: ${{ inputs.NugetsPath }} retention-days: 5 diff --git a/.github/workflows/cd-extensions.yml b/.github/workflows/cd-extensions.yml deleted file mode 100644 index b951904..0000000 --- a/.github/workflows/cd-extensions.yml +++ /dev/null @@ -1,83 +0,0 @@ -name: CD Extensions -# This CD builds and publish what is currently on the repo. -# Addionally, periodically updates the reference to latest Imgui nuget and try to publish a new ones. -on: - workflow_dispatch: - inputs: - publishEnabled: - description: "Publish to Nuget.org" - type: boolean - required: false - default: false - schedule: - - cron: "23 20 * * *" # Executed every day at 23:20 - -env: - nugetsPath: "nupkgs" - imguiNuget: "Evergine.Bindings.Imgui" - imguizmoPath: "./Generator/Evergine.Bindings.Imguizmo" - imnodesPath: "./Generator/Evergine.Bindings.Imnodes" - implotPath: "./Generator/Evergine.Bindings.Implot" - -jobs: - build_publish_extensions_win: - name: Generate extensions nugets (windows only) - runs-on: windows-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - uses: actions/setup-dotnet@v4 - with: - dotnet-version: 8.x - - name: Update nugets - shell: pwsh - run: | - dotnet add ${{ env.imguizmoPath }} package ${{ env.imguiNuget }} - dotnet add ${{ env.imnodesPath }} package ${{ env.imguiNuget }} - dotnet add ${{ env.implotPath }} package ${{ env.imguiNuget }} - # check if there is a new nuget of Imgui - - name: Verify Imgui nuget changes - id: verify-imgui-nuget - shell: pwsh - run: | - .\scripts\verify-changes.ps1 - # TODO move build native steps to different jobs, commit, and then continue with Imgui on Windows - - uses: ./.github/actions/build-native-win - if: ${{ success() && (github.event_name != 'schedule' || steps.verify-imgui-nuget.outputs.files_changed == 'true') }} - with: - Target: Extensions - NugetsPath: ${{ env.nugetsPath }} - - uses: ./.github/actions/generate-bindings-nugets - if: ${{ success() && (github.event_name != 'schedule' || steps.verify-imgui-nuget.outputs.files_changed == 'true') }} - with: - ImX: Imguizmo - NugetsPath: ${{ env.nugetsPath }} - - uses: ./.github/actions/generate-bindings-nugets - if: ${{ success() && (github.event_name != 'schedule' || steps.verify-imgui-nuget.outputs.files_changed == 'true') }} - with: - ImX: Imnodes - NugetsPath: ${{ env.nugetsPath }} - - uses: ./.github/actions/generate-bindings-nugets - if: ${{ success() && (github.event_name != 'schedule' || steps.verify-imgui-nuget.outputs.files_changed == 'true') }} - with: - ImX: Implot - NugetsPath: ${{ env.nugetsPath }} - - name: Verify changes - id: verify-changed-files - if: ${{ success() && (github.event_name != 'schedule' || steps.verify-imgui-nuget.outputs.files_changed == 'true') }} - shell: pwsh - run: | - .\scripts\verify-changes.ps1 - - uses: ./.github/actions/publish-nugets - if: ${{ success() && ((github.event_name != 'schedule' && github.event.inputs.publishEnabled == 'true') || (github.event_name == 'schedule' && steps.verify-changed-files.outputs.files_changed == 'true')) }} - with: - NugetsPath: ${{ env.nugetsPath }} - Token: ${{ secrets.EVERGINE_NUGETORG_TOKEN }} - - name: Commit if appropiate - if: ${{ success() && steps.verify-changed-files.outputs.files_changed == 'true' }} # don't commit if only dlls have been changed - uses: EndBug/add-and-commit@v9 - with: - message: Updating nugets - committer_name: GitHub Actions - committer_email: 41898282+github-actions[bot]@users.noreply.github.com diff --git a/.github/workflows/cd-imgui.yml b/.github/workflows/cd-imgui.yml index ce04272..3507a00 100644 --- a/.github/workflows/cd-imgui.yml +++ b/.github/workflows/cd-imgui.yml @@ -31,10 +31,12 @@ jobs: - uses: ./.github/actions/build-native-win with: Target: Imgui + - uses: ./.github/actions/build-native-win + with: + Target: Extensions - uses: ./.github/actions/generate-bindings-nugets id: nugets with: - ImX: Imgui NugetsPath: ${{ env.nugetsPath }} - name: Verify changes id: verify-changed-files diff --git a/.github/workflows/ci-extensions.yml b/.github/workflows/ci-extensions.yml deleted file mode 100644 index f8aa9b6..0000000 --- a/.github/workflows/ci-extensions.yml +++ /dev/null @@ -1,33 +0,0 @@ -name: CI Extensions -# This CI only builds what is currently on the repo -on: - push: - paths: - - "Generator/ImguizmoGen/**" - - "Generator/ImnodesGen/**" - - "Generator/ImplotGen/**" - - "NativeLibraries/extensions/**" - - "scripts/deploy-win-native.ps1" - - "scripts/generate-bindings.ps1" - - "scripts/generate-nugets.ps1" - -jobs: - build_extensions_win: - name: Build extensions nugets - runs-on: windows-latest - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - uses: ./.github/actions/build-native-win - with: - Target: Extensions - - uses: ./.github/actions/generate-bindings-nugets - with: - ImX: Imguizmo - - uses: ./.github/actions/generate-bindings-nugets - with: - ImX: Imnodes - - uses: ./.github/actions/generate-bindings-nugets - with: - ImX: Implot diff --git a/.github/workflows/ci-imgui.yml b/.github/workflows/ci-imgui.yml index e299190..c07c8f7 100644 --- a/.github/workflows/ci-imgui.yml +++ b/.github/workflows/ci-imgui.yml @@ -4,7 +4,11 @@ on: push: paths: - "Generator/ImguiGen/**" + - "Generator/ImguizmoGen/**" + - "Generator/ImnodesGen/**" + - "Generator/ImplotGen/**" - "NativeLibraries/cimgui/**" + - "NativeLibraries/extensions/**" - "scripts/deploy-win-native.ps1" - "scripts/generate-bindings.ps1" - "scripts/generate-nugets.ps1" @@ -20,6 +24,7 @@ jobs: - uses: ./.github/actions/build-native-win with: Target: Imgui - - uses: ./.github/actions/generate-bindings-nugets + - uses: ./.github/actions/build-native-win with: - ImX: Imgui + Target: Extensions + - uses: ./.github/actions/generate-bindings-nugets diff --git a/scripts/generate-bindings.ps1 b/scripts/generate-bindings.ps1 index 8407409..cb7702c 100644 --- a/scripts/generate-bindings.ps1 +++ b/scripts/generate-bindings.ps1 @@ -11,7 +11,7 @@ #> param ( - [ValidateSet('Imgui', 'Imguizmo', 'Imnodes', 'Implot')][string]$ImX = "Imgui", + [string[]]$ImX = @('Imgui', 'Imguizmo', 'Imnodes', 'Implot'), [string]$buildVerbosity = "normal", [string]$buildConfiguration = "Release" ) @@ -19,49 +19,52 @@ param ( $ErrorActionPreference = "Stop" . "$PSScriptRoot\ps_support.ps1" -# Set working directory -Push-Location (Get-Location).Path -Set-Location $PSScriptRoot\..\Generator +# Iterate over each ImX value and generate packages +foreach ($item in $ImX) { + # Set working directory + Push-Location (Get-Location).Path + Set-Location $PSScriptRoot\..\Generator -$imxGenCsprojPath = "$($ImX)Gen\$($ImX)Gen.csproj" + $imxGenCsprojPath = "$($item)Gen\$($item)Gen.csproj" -# Utility functions -function LogDebug($line) -{ Write-Host "##[debug] $line" -Foreground Blue -Background Black -} + # Utility functions + function LogDebug($line) + { Write-Host "##[debug] $line" -Foreground Blue -Background Black + } -# Show variables -LogDebug "############## VARIABLES ##############" -LogDebug "Build configuration.: $buildConfiguration" -LogDebug "Build verbosity.....: $buildVerbosity" -LogDebug "#######################################" + # Show variables + LogDebug "############## VARIABLES ##############" + LogDebug "Build configuration.: $buildConfiguration" + LogDebug "Build verbosity.....: $buildVerbosity" + LogDebug "#######################################" -# Build generator -LogDebug "START generator build process" -dotnet publish "$imxGenCsprojPath" -v:$buildVerbosity -p:Configuration=$buildConfiguration -if($?) -{ - LogDebug "END generator build process" -} -else -{ - LogDebug "ERROR; Generator build failed" - exit -1 -} + # Build generator + LogDebug "START generator build process" + dotnet publish "$imxGenCsprojPath" -v:$buildVerbosity -p:Configuration=$buildConfiguration + if($?) + { + LogDebug "END generator build process" + } + else + { + LogDebug "ERROR; Generator build failed" + exit -1 + } -LogDebug "START bindings generator process" -$cmd = ".\publish\$($ImX)Gen.exe" -Push-Location .\$($ImX)Gen\bin\Release\net8.0 -$($cmd) -if($?) -{ - LogDebug "END bindings generator process" -} -else -{ - LogDebug "ERROR; Bindings generation failed" - exit -1 -} -Pop-Location + LogDebug "START bindings generator process" + $cmd = ".\publish\$($item)Gen.exe" + Push-Location .\$($item)Gen\bin\Release\net8.0 + $($cmd) + if($?) + { + LogDebug "END bindings generator process" + } + else + { + LogDebug "ERROR; Bindings generation failed" + exit -1 + } + Pop-Location -Pop-Location + Pop-Location +} \ No newline at end of file diff --git a/scripts/generate-nugets.ps1 b/scripts/generate-nugets.ps1 index 71a22a6..c486d43 100644 --- a/scripts/generate-nugets.ps1 +++ b/scripts/generate-nugets.ps1 @@ -11,34 +11,32 @@ #> param ( - [ValidateSet('Imgui', 'Imguizmo', 'Imnodes', 'Implot')][string]$ImX = "Imgui", - [string]$outputFolderBase = "nupkgs", - [string]$buildVerbosity = "normal", - [string]$buildConfiguration = "Release", - [string]$versionSuffix = "" + [string[]]$ImX = @('Imgui', 'Imguizmo', 'Imnodes', 'Implot'), + [string]$outputFolderBase = "nupkgs", + [string]$buildVerbosity = "normal", + [string]$buildConfiguration = "Release", + [string]$versionSuffix = "" ) $ErrorActionPreference = "Stop" . "$PSScriptRoot\ps_support.ps1" +# calculate version +$version = "$(Get-Date -Format "yyyy.M.d").$([string]([int]$(Get-Date -Format "HH")*60+[int]$(Get-Date -Format "mm")))" + +if ($versionSuffix -ne "") { + $version = "$version-$versionSuffix" +} + # Set working directory Push-Location (Get-Location).Path Set-Location $PSScriptRoot\.. -$csprojPath = "Evergine.Bindings.$($ImX)\Evergine.Bindings.$($ImX).csproj" - # Utility functions function LogDebug($line) { Write-Host "##[debug] $line" -Foreground Blue -Background Black } -# calculate version -$version = "$(Get-Date -Format "yyyy.M.d").$([string]([int]$(Get-Date -Format "HH")*60+[int]$(Get-Date -Format "mm")))" - -if ($versionSuffix -ne "") { - $version = "$version-$versionSuffix" -} - # Show variables LogDebug "############## VARIABLES ##############" LogDebug "Version.............: $version" @@ -59,15 +57,18 @@ if ($buildConfiguration -eq "Debug") { Set-Location .\Generator -# Generate packages -LogDebug "START packaging process" -dotnet pack "$csprojPath" -v:$buildVerbosity -p:Configuration=$buildConfiguration -p:PackageOutputPath="$absoluteOutputFolder" -p:IncludeSymbols=$symbols -p:Version=$version -if ($?) { - LogDebug "END packaging process" -} -else { - LogDebug "ERROR; packaging failed" - exit -1 +# Iterate over each ImX value and generate packages +foreach ($item in $ImX) { + LogDebug "START packaging process for $item" + $csprojPath = "Evergine.Bindings.$($item)\Evergine.Bindings.$($item).csproj" + dotnet pack "$csprojPath" -v:$buildVerbosity -p:Configuration=$buildConfiguration -p:PackageOutputPath="$absoluteOutputFolder" -p:IncludeSymbols=$symbols -p:Version=$version + if ($?) { + LogDebug "END packaging process for $item" + } + else { + LogDebug "ERROR; packaging failed for $item" + exit -1 + } } Pop-Location