Release v1.0.0 #5
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: | |
| pull_request: | |
| branches: [main] | |
| types: [closed] | |
| permissions: | |
| contents: write | |
| jobs: | |
| release: | |
| if: github.event.pull_request.merged == true && github.event.pull_request.head.ref == 'dev' | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Get version | |
| id: version | |
| shell: pwsh | |
| run: | | |
| $version = ([xml](Get-Content src/PlanViewer.App/PlanViewer.App.csproj)).Project.PropertyGroup.Version | Where-Object { $_ } | |
| echo "VERSION=$version" >> $env:GITHUB_OUTPUT | |
| - name: Check if release already exists | |
| id: check | |
| shell: bash | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| if gh release view "v${{ steps.version.outputs.VERSION }}" > /dev/null 2>&1; then | |
| echo "EXISTS=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "EXISTS=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Create release | |
| if: steps.check.outputs.EXISTS == 'false' | |
| shell: bash | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh release create "v${{ steps.version.outputs.VERSION }}" --title "v${{ steps.version.outputs.VERSION }}" --generate-notes --target main | |
| - name: Setup .NET 8.0 | |
| if: steps.check.outputs.EXISTS == 'false' | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 8.0.x | |
| - name: Build and test | |
| if: steps.check.outputs.EXISTS == 'false' | |
| run: | | |
| dotnet restore | |
| dotnet build -c Release | |
| dotnet test tests/PlanViewer.Core.Tests/PlanViewer.Core.Tests.csproj -c Release --no-build --verbosity normal | |
| - name: Publish App (all platforms) | |
| if: steps.check.outputs.EXISTS == 'false' | |
| run: | | |
| dotnet publish src/PlanViewer.App/PlanViewer.App.csproj -c Release -r win-x64 --self-contained -o publish/win-x64 | |
| dotnet publish src/PlanViewer.App/PlanViewer.App.csproj -c Release -r linux-x64 --self-contained -o publish/linux-x64 | |
| dotnet publish src/PlanViewer.App/PlanViewer.App.csproj -c Release -r osx-x64 --self-contained -o publish/osx-x64 | |
| dotnet publish src/PlanViewer.App/PlanViewer.App.csproj -c Release -r osx-arm64 --self-contained -o publish/osx-arm64 | |
| - name: Package and upload | |
| if: steps.check.outputs.EXISTS == 'false' | |
| shell: pwsh | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| VERSION: ${{ steps.version.outputs.VERSION }} | |
| run: | | |
| New-Item -ItemType Directory -Force -Path releases | |
| # Package Windows and Linux as flat zips | |
| foreach ($rid in @('win-x64', 'linux-x64')) { | |
| if (Test-Path 'README.md') { Copy-Item 'README.md' "publish/$rid/" } | |
| if (Test-Path 'LICENSE') { Copy-Item 'LICENSE' "publish/$rid/" } | |
| Compress-Archive -Path "publish/$rid/*" -DestinationPath "releases/PerformanceStudio-$rid.zip" -Force | |
| } | |
| # Package macOS as proper .app bundles | |
| foreach ($rid in @('osx-x64', 'osx-arm64')) { | |
| $appName = "PerformanceStudio.app" | |
| $bundleDir = "publish/$rid-bundle/$appName" | |
| # Create .app bundle structure | |
| New-Item -ItemType Directory -Force -Path "$bundleDir/Contents/MacOS" | |
| New-Item -ItemType Directory -Force -Path "$bundleDir/Contents/Resources" | |
| # Copy all published files into Contents/MacOS | |
| Copy-Item -Path "publish/$rid/*" -Destination "$bundleDir/Contents/MacOS/" -Recurse | |
| # Move Info.plist to Contents/ (it was copied to MacOS/ with the publish output) | |
| if (Test-Path "$bundleDir/Contents/MacOS/Info.plist") { | |
| Move-Item -Path "$bundleDir/Contents/MacOS/Info.plist" -Destination "$bundleDir/Contents/Info.plist" -Force | |
| } | |
| # Update version in Info.plist to match csproj | |
| $plist = Get-Content "$bundleDir/Contents/Info.plist" -Raw | |
| $plist = $plist -replace '(<key>CFBundleVersion</key>\s*<string>)[^<]*(</string>)', "`${1}$env:VERSION`${2}" | |
| $plist = $plist -replace '(<key>CFBundleShortVersionString</key>\s*<string>)[^<]*(</string>)', "`${1}$env:VERSION`${2}" | |
| Set-Content -Path "$bundleDir/Contents/Info.plist" -Value $plist -NoNewline | |
| # Move icon to Contents/Resources | |
| if (Test-Path "$bundleDir/Contents/MacOS/EDD.icns") { | |
| Move-Item -Path "$bundleDir/Contents/MacOS/EDD.icns" -Destination "$bundleDir/Contents/Resources/EDD.icns" -Force | |
| } | |
| # Add README and LICENSE alongside the .app bundle | |
| $wrapperDir = "publish/$rid-bundle" | |
| if (Test-Path 'README.md') { Copy-Item 'README.md' "$wrapperDir/" } | |
| if (Test-Path 'LICENSE') { Copy-Item 'LICENSE' "$wrapperDir/" } | |
| Compress-Archive -Path "$wrapperDir/*" -DestinationPath "releases/PerformanceStudio-$rid.zip" -Force | |
| } | |
| # Checksums | |
| $checksums = Get-ChildItem releases/*.zip | ForEach-Object { | |
| $hash = (Get-FileHash $_.FullName -Algorithm SHA256).Hash.ToLower() | |
| "$hash $($_.Name)" | |
| } | |
| $checksums | Out-File -FilePath releases/SHA256SUMS.txt -Encoding utf8 | |
| Write-Host "Checksums:" | |
| $checksums | ForEach-Object { Write-Host $_ } | |
| # Upload | |
| gh release upload "v$env:VERSION" releases/*.zip releases/SHA256SUMS.txt --clobber |