|
| 1 | +name: CD Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [master] |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +env: |
| 12 | + MAX_VERSIONS: '2022 2023 2024 2025 2026' |
| 13 | + MAYA_VERSIONS: '2020 2022 2023 2024' |
| 14 | + |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + name: Build All |
| 18 | + runs-on: windows-latest |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + with: |
| 22 | + fetch-depth: 0 |
| 23 | + |
| 24 | + - name: Setup MSBuild |
| 25 | + uses: microsoft/setup-msbuild@v2 |
| 26 | + |
| 27 | + - name: Setup NuGet |
| 28 | + uses: nuget/setup-nuget@v2 |
| 29 | + with: |
| 30 | + nuget-version: '6.x' |
| 31 | + |
| 32 | + - name: Version Update - Max |
| 33 | + shell: pwsh |
| 34 | + run: | |
| 35 | + $content = Get-Content -Path '3ds Max\Max2Babylon\Exporter\BabylonExporter.cs' -Raw |
| 36 | + $content = $content -replace 'Custom\.Build\.Version', "${{ github.run_number }}" |
| 37 | + Set-Content -Path '3ds Max\Max2Babylon\Exporter\BabylonExporter.cs' -Value $content |
| 38 | +
|
| 39 | + - name: Version Update - Maya |
| 40 | + shell: pwsh |
| 41 | + run: | |
| 42 | + $content = Get-Content -Path 'Maya\Exporter\BabylonExporter.cs' -Raw |
| 43 | + $content = $content -replace 'Custom\.Build\.Version', "${{ github.run_number }}" |
| 44 | + Set-Content -Path 'Maya\Exporter\BabylonExporter.cs' -Value $content |
| 45 | +
|
| 46 | + # ── 3ds Max ── |
| 47 | + - name: NuGet Restore - Max |
| 48 | + run: nuget restore "3ds Max\Max2Babylon.sln" |
| 49 | + |
| 50 | + - name: Build Max |
| 51 | + run: msbuild "3ds Max\Max2Babylon.sln" /p:Configuration=Release /p:Platform=x64 /p:PostBuildEvent= /p:PreBuildEvent= /v:minimal |
| 52 | + |
| 53 | + # ── Maya ── |
| 54 | + - name: NuGet Restore - Maya |
| 55 | + run: nuget restore "Maya\Maya2Babylon.sln" |
| 56 | + |
| 57 | + - name: Build Maya |
| 58 | + run: msbuild "Maya\Maya2Babylon.sln" /p:Configuration=Release "/p:Platform=Any CPU" /p:PostBuildEvent= /p:PreBuildEvent= /v:minimal |
| 59 | + |
| 60 | + - name: Copy Maya Templates |
| 61 | + shell: pwsh |
| 62 | + run: | |
| 63 | + foreach ($year in "${{ env.MAYA_VERSIONS }}".Split(' ')) { |
| 64 | + $dest = "Maya\bin\Release\$year" |
| 65 | + if (Test-Path $dest) { |
| 66 | + Copy-Item -Path "Maya\AETemplates\*" -Destination $dest -Force -ErrorAction SilentlyContinue |
| 67 | + Copy-Item -Path "Maya\NETemplates\*" -Destination $dest -Force -ErrorAction SilentlyContinue |
| 68 | + } |
| 69 | + } |
| 70 | +
|
| 71 | + # ── Installer ── |
| 72 | + - name: NuGet Restore - Installer |
| 73 | + run: nuget restore "BabylonJS_Installer\BabylonJS_Installer.sln" |
| 74 | + |
| 75 | + - name: Build Installer |
| 76 | + run: msbuild "BabylonJS_Installer\BabylonJS_Installer.sln" /p:Configuration=Release "/p:Platform=Any CPU" /p:PostBuildEvent= /v:minimal |
| 77 | + |
| 78 | + # ── Package release zips ── |
| 79 | + - name: Package Artifacts |
| 80 | + shell: pwsh |
| 81 | + run: | |
| 82 | + $staging = "release-staging" |
| 83 | + New-Item -ItemType Directory -Path $staging -Force | Out-Null |
| 84 | +
|
| 85 | + # Max zips |
| 86 | + foreach ($year in "${{ env.MAX_VERSIONS }}".Split(' ')) { |
| 87 | + $src = "3ds Max\Max2Babylon\$year\bin\Release" |
| 88 | + if (Test-Path $src) { |
| 89 | + $tmp = "$staging\tmp\Release" |
| 90 | + New-Item -ItemType Directory -Path $tmp -Force | Out-Null |
| 91 | + Copy-Item -Path "$src\*.dll" -Destination $tmp -Force |
| 92 | + Compress-Archive -Path "$staging\tmp\Release" -DestinationPath "$staging\Max_$year.zip" -Force |
| 93 | + Remove-Item -Path "$staging\tmp" -Recurse -Force |
| 94 | + } |
| 95 | + } |
| 96 | +
|
| 97 | + # Maya zips |
| 98 | + foreach ($year in "${{ env.MAYA_VERSIONS }}".Split(' ')) { |
| 99 | + $src = "Maya\bin\Release\$year" |
| 100 | + if (Test-Path $src) { |
| 101 | + $tmp = "$staging\tmp" |
| 102 | + New-Item -ItemType Directory -Path $tmp -Force | Out-Null |
| 103 | + Copy-Item -Path "$src\*.dll" -Destination $tmp -Force |
| 104 | + Copy-Item -Path "Maya\AETemplates" -Destination "$tmp\Maya\AETemplates" -Recurse -Force -ErrorAction SilentlyContinue |
| 105 | + Copy-Item -Path "Maya\NETemplates" -Destination "$tmp\Maya\NETemplates" -Recurse -Force -ErrorAction SilentlyContinue |
| 106 | + Compress-Archive -Path "$tmp\*" -DestinationPath "$staging\Maya_$year.zip" -Force |
| 107 | + Remove-Item -Path $tmp -Recurse -Force |
| 108 | + } |
| 109 | + } |
| 110 | +
|
| 111 | + # Installer zip |
| 112 | + $installerDir = "BabylonJS_Installer\BabylonJS_Installer\bin\Release" |
| 113 | + if (Test-Path $installerDir) { |
| 114 | + Compress-Archive -Path "$installerDir\BabylonJS_Exporters.exe","BabylonJS_Installer\README.md" -DestinationPath "$staging\Installer.zip" -Force |
| 115 | + } |
| 116 | +
|
| 117 | + # Print manifest |
| 118 | + Get-ChildItem $staging -Filter *.zip | ForEach-Object { |
| 119 | + $hash = (Get-FileHash $_.FullName -Algorithm SHA256).Hash.ToLower() |
| 120 | + $size = [math]::Round($_.Length / 1KB) |
| 121 | + Write-Host "$($_.Name) sha256:$hash ${size} KB" |
| 122 | + } |
| 123 | +
|
| 124 | + # ── Create Release ── |
| 125 | + - name: Generate Release Info |
| 126 | + id: release_info |
| 127 | + shell: pwsh |
| 128 | + run: | |
| 129 | + $date = Get-Date -Format "yyyyMMdd" |
| 130 | + $patch = "${{ github.run_number }}" |
| 131 | + $tag = "v${date}.${patch}" |
| 132 | + $title = "CD Release ${date}.${patch}" |
| 133 | +
|
| 134 | + # Get commits since last tag |
| 135 | + $lastTag = git describe --tags --abbrev=0 2>$null |
| 136 | + if ($lastTag) { |
| 137 | + $log = git log --pretty=format:"- %s (%h)" "${lastTag}..HEAD" | Out-String |
| 138 | + } else { |
| 139 | + $log = git log --pretty=format:"- %s (%h)" -20 | Out-String |
| 140 | + } |
| 141 | +
|
| 142 | + $notes = "## What's Changed`n`n${log}" |
| 143 | +
|
| 144 | + # Write outputs |
| 145 | + "tag=$tag" | Out-File -FilePath $env:GITHUB_OUTPUT -Append |
| 146 | + "title=$title" | Out-File -FilePath $env:GITHUB_OUTPUT -Append |
| 147 | +
|
| 148 | + # Write body to a file to preserve multiline |
| 149 | + $notes | Out-File -FilePath "release-notes.md" -Encoding utf8 |
| 150 | +
|
| 151 | + - name: Create Tag |
| 152 | + run: | |
| 153 | + git tag ${{ steps.release_info.outputs.tag }} |
| 154 | + git push origin ${{ steps.release_info.outputs.tag }} |
| 155 | +
|
| 156 | + - name: Create GitHub Release and Upload Assets |
| 157 | + shell: pwsh |
| 158 | + env: |
| 159 | + GH_TOKEN: ${{ github.token }} |
| 160 | + run: | |
| 161 | + $tag = "${{ steps.release_info.outputs.tag }}" |
| 162 | + $title = "${{ steps.release_info.outputs.title }}" |
| 163 | + $assets = Get-ChildItem "release-staging\*.zip" | ForEach-Object { $_.FullName } |
| 164 | +
|
| 165 | + gh release create $tag @assets --title $title --notes-file "release-notes.md" --latest |
0 commit comments