Update publish directories to use 'Release' configuration #71
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: Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| env: | |
| UNP4K_VERSION: 4.0.${{ github.run_number }} | |
| jobs: | |
| build: | |
| runs-on: windows-latest | |
| strategy: | |
| matrix: | |
| rid: [win-x64, win-x86] | |
| dnv: [net10.0] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup .NET 10 | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '10.0.x' | |
| - name: Restore | |
| run: dotnet restore | |
| # If your .sln builds everything correctly, you can just publish the solution. | |
| # Otherwise, replace these with explicit paths to your .csproj/.fsproj files. | |
| - name: Publish ${{ matrix.rid }} | |
| shell: pwsh | |
| run: dotnet publish -c Release -r ${{ matrix.rid }} -f ${{ matrix.dnv }} | |
| - name: Remove PDBs and package artifacts | |
| shell: pwsh | |
| run: | | |
| $rid = "${{ matrix.rid }}" | |
| $dnv = "${{ matrix.dnv }}" | |
| # Publish directories for this RID | |
| $publishDirs = @( | |
| "src\unp4k.fs\bin\Release\$dnv\$rid\publish", | |
| "src\unforge.cli\bin\Release\$dnv\$rid\publish", | |
| "src\unp4k\bin\Release\$dnv\$rid\publish" | |
| ) | |
| # Strip PDBs from publish directories | |
| foreach ($dir in $publishDirs) { | |
| if (Test-Path $dir) { | |
| Get-ChildItem -Path $dir -Recurse -Filter *.pdb | Remove-Item -Force | |
| } | |
| } | |
| # Ensure an artifacts directory exists for this RID | |
| $artifactsRoot = "artifacts\$rid" | |
| New-Item -ItemType Directory -Path $artifactsRoot -Force | Out-Null | |
| # Zip each individual publish directory | |
| $map = @{ | |
| "unp4k.fs" = "src\unp4k.fs\bin\Release\$dnv\$rid\publish" | |
| "unforge.cli" = "src\unforge.cli\bin\Release\$dnv\$rid\publish" | |
| "unp4k" = "src\unp4k\bin\Release\$dnv\$rid\publish" | |
| } | |
| foreach ($name in $map.Keys) { | |
| $src = $map[$name] | |
| if (Test-Path $src) { | |
| $zipPath = Join-Path $artifactsRoot "$name-$rid-v${{ env.UNP4K_VERSION }}.zip" | |
| if (Test-Path $zipPath) { Remove-Item $zipPath -Force } | |
| Compress-Archive -Path (Join-Path $src '*') -DestinationPath $zipPath | |
| } | |
| } | |
| # Create a "suite" zip that contains all three publish directories | |
| # (kept as subdirectories inside the suite zip, rather than flattened) | |
| $suiteZip = Join-Path $artifactsRoot "suite-$rid-v${{ env.UNP4K_VERSION }}.zip" | |
| if (Test-Path $suiteZip) { Remove-Item $suiteZip -Force } | |
| $pathsToInclude = @() | |
| foreach ($dir in $publishDirs) { | |
| if (Test-Path $dir) { | |
| $pathsToInclude += $dir | |
| } | |
| } | |
| if ($pathsToInclude.Count -gt 0) { | |
| Compress-Archive -Path $pathsToInclude -DestinationPath $suiteZip | |
| } | |
| - name: Upload build artifacts (per RID) | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: unp4k-${{ matrix.rid }}-v${{ env.UNP4K_VERSION }} | |
| path: artifacts/${{ matrix.rid }}/*.zip | |
| if-no-files-found: error | |
| release: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: (github.event_name == 'push') | |
| outputs: | |
| id: ${{ steps.create_release.outputs.id }} | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Load README | |
| run: | | |
| echo "README<<EOF" >> $GITHUB_ENV | |
| cat README.md >> $GITHUB_ENV | |
| echo 'EOF' >> $GITHUB_ENV | |
| - name: Create Release | |
| id: create_release | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: v${{ env.UNP4K_VERSION }} | |
| release_name: unp4k Tools for Star Citizen | |
| body: ${{ env.README }} | |
| draft: true | |
| prerelease: false | |
| upload: | |
| needs: release | |
| runs-on: ubuntu-latest | |
| if: (github.event_name == 'push') | |
| strategy: | |
| max-parallel: 3 | |
| matrix: | |
| artifact: [ unp4k, unp4k-suite, unforge ] | |
| steps: | |
| - name: Load Artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ${{ matrix.artifact }}-v${{ env.UNP4K_VERSION }} | |
| path: ${{ matrix.artifact }} | |
| - name: Compress Artifacts | |
| run: (cd ${{ matrix.artifact }} && zip -r ../${{ matrix.artifact }}.zip .) | |
| - name: Upload Artifacts | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ needs.release.outputs.upload_url }} | |
| asset_path: ${{ matrix.artifact }}.zip | |
| asset_name: ${{ matrix.artifact }}-v${{ env.UNP4K_VERSION }}.zip | |
| asset_content_type: application/zip | |
| publish: | |
| needs: [ upload, release ] | |
| runs-on: ubuntu-latest | |
| if: (github.event_name == 'push') | |
| steps: | |
| - name: Publish Release | |
| uses: StuYarrow/publish-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| id: ${{ needs.release.outputs.id }} |