|
| 1 | +name: Release Windows portable package |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + version: |
| 7 | + description: 'Version label, for example 1.2.0-public-beta' |
| 8 | + required: true |
| 9 | + default: '1.2.0-public-beta' |
| 10 | + publish_release: |
| 11 | + description: 'Create or update a GitHub Release' |
| 12 | + required: true |
| 13 | + default: false |
| 14 | + type: boolean |
| 15 | + prerelease: |
| 16 | + description: 'Mark GitHub Release as prerelease' |
| 17 | + required: true |
| 18 | + default: true |
| 19 | + type: boolean |
| 20 | + draft: |
| 21 | + description: 'Create GitHub Release as draft' |
| 22 | + required: true |
| 23 | + default: false |
| 24 | + type: boolean |
| 25 | + release_notes_file: |
| 26 | + description: 'Markdown file used as release body' |
| 27 | + required: true |
| 28 | + default: 'docs/RELEASE_NOTES_v1.2.0.md' |
| 29 | + push: |
| 30 | + tags: |
| 31 | + - 'v*' |
| 32 | + |
| 33 | +permissions: |
| 34 | + contents: write |
| 35 | + |
| 36 | +jobs: |
| 37 | + package: |
| 38 | + name: Build portable Windows package |
| 39 | + runs-on: windows-latest |
| 40 | + |
| 41 | + steps: |
| 42 | + - name: Checkout |
| 43 | + uses: actions/checkout@v4 |
| 44 | + with: |
| 45 | + fetch-depth: 0 |
| 46 | + |
| 47 | + - name: Setup .NET |
| 48 | + uses: actions/setup-dotnet@v4 |
| 49 | + with: |
| 50 | + dotnet-version: 8.0.x |
| 51 | + |
| 52 | + - name: Resolve release version |
| 53 | + id: version |
| 54 | + shell: pwsh |
| 55 | + run: | |
| 56 | + $version = '${{ github.event.inputs.version }}' |
| 57 | + if ([string]::IsNullOrWhiteSpace($version)) { |
| 58 | + $version = '${{ github.ref_name }}' |
| 59 | + } |
| 60 | + $version = $version.Trim() |
| 61 | + if ($version.StartsWith('v')) { $version = $version.Substring(1) } |
| 62 | + if ([string]::IsNullOrWhiteSpace($version)) { throw 'Unable to resolve release version.' } |
| 63 | + "value=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8 |
| 64 | + Write-Host "Release version: $version" |
| 65 | +
|
| 66 | + - name: Restore |
| 67 | + run: dotnet restore .\ProcessBusSuite.sln |
| 68 | + |
| 69 | + - name: Build |
| 70 | + run: dotnet build .\ProcessBusSuite.sln -c Release --no-restore /p:ContinuousIntegrationBuild=true |
| 71 | + |
| 72 | + - name: Publish portable package |
| 73 | + shell: pwsh |
| 74 | + run: | |
| 75 | + .\scripts\publish-windows-portable.ps1 -Version '${{ steps.version.outputs.value }}' -Configuration Release -Runtime win-x64 |
| 76 | +
|
| 77 | + - name: Verify portable package |
| 78 | + shell: pwsh |
| 79 | + run: | |
| 80 | + $zip = ".\artifacts\release\ProcessBusInsight-v${{ steps.version.outputs.value }}-win-x64-portable.zip" |
| 81 | + .\scripts\verify-release-package.ps1 -PackageZip $zip |
| 82 | +
|
| 83 | + - name: Upload workflow artifact |
| 84 | + uses: actions/upload-artifact@v4 |
| 85 | + with: |
| 86 | + name: ProcessBusInsight-v${{ steps.version.outputs.value }}-win-x64-portable |
| 87 | + path: | |
| 88 | + artifacts/release/ProcessBusInsight-v${{ steps.version.outputs.value }}-win-x64-portable.zip |
| 89 | + artifacts/release/SHA256SUMS.txt |
| 90 | + if-no-files-found: error |
| 91 | + |
| 92 | + - name: Publish GitHub Release |
| 93 | + if: ${{ github.event_name == 'push' || github.event.inputs.publish_release == 'true' }} |
| 94 | + shell: pwsh |
| 95 | + env: |
| 96 | + GH_TOKEN: ${{ github.token }} |
| 97 | + run: | |
| 98 | + $version = '${{ steps.version.outputs.value }}' |
| 99 | + $tag = "v$version" |
| 100 | + $zip = "artifacts/release/ProcessBusInsight-v$version-win-x64-portable.zip" |
| 101 | + $sha = "artifacts/release/SHA256SUMS.txt" |
| 102 | + $notesFile = '${{ github.event.inputs.release_notes_file }}' |
| 103 | + if ([string]::IsNullOrWhiteSpace($notesFile)) { $notesFile = 'docs/RELEASE_NOTES_v1.2.0.md' } |
| 104 | + if (-not (Test-Path $notesFile)) { $notesFile = 'docs/RELEASE_NOTES_v1.2.0.md' } |
| 105 | + if (-not (Test-Path $notesFile)) { throw "Release notes file not found: $notesFile" } |
| 106 | +
|
| 107 | + $releaseArgs = @('release','create',$tag,$zip,$sha,'--title',"Process Bus Insight $tag",'--notes-file',$notesFile,'--target','${{ github.sha }}') |
| 108 | +
|
| 109 | + $isDraft = '${{ github.event.inputs.draft }}' |
| 110 | + $isPrerelease = '${{ github.event.inputs.prerelease }}' |
| 111 | + if ('${{ github.event_name }}' -eq 'push') { $isPrerelease = 'false' } |
| 112 | + if ($isDraft -eq 'true') { $releaseArgs += '--draft' } |
| 113 | + if ($isPrerelease -eq 'true') { $releaseArgs += '--prerelease' } |
| 114 | +
|
| 115 | + gh release view $tag *> $null |
| 116 | + if ($LASTEXITCODE -eq 0) { |
| 117 | + gh release upload $tag $zip $sha --clobber |
| 118 | + } |
| 119 | + else { |
| 120 | + gh @releaseArgs |
| 121 | + } |
0 commit comments