|
| 1 | +name: 'Publish Release' |
| 2 | +on: |
| 3 | + push: |
| 4 | + tags: |
| 5 | + - v* |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + version: |
| 9 | + description: 'Version tag in format x.y.z[-pre]' |
| 10 | + required: true |
| 11 | + type: string |
| 12 | +env: |
| 13 | + dotnet_version: '8.0' |
| 14 | +jobs: |
| 15 | + publish: |
| 16 | + strategy: |
| 17 | + fail-fast: false |
| 18 | + matrix: |
| 19 | + os: [windows-latest, ubuntu-latest, macos-latest] |
| 20 | + include: |
| 21 | + - os: windows-latest |
| 22 | + configuration: Release |
| 23 | + target: '-windows' |
| 24 | + rid: win-x64 |
| 25 | + command_extra: '' |
| 26 | + - os: ubuntu-latest |
| 27 | + configuration: Linux |
| 28 | + target: '' |
| 29 | + rid: linux-x64 |
| 30 | + command_extra: '' |
| 31 | + - os: macos-latest |
| 32 | + configuration: MacOS |
| 33 | + target: '' |
| 34 | + rid: 'osx-arm64' |
| 35 | + command_extra: '-t:BundleApp' |
| 36 | + runs-on: '${{ matrix.os }}' |
| 37 | + env: |
| 38 | + version_full: '${{ github.ref_name }}' |
| 39 | + version_short: '${{ github.ref_name }}' |
| 40 | + artifact_name: 'ps3-disc-dumper_vX.Y.Z.zip' |
| 41 | + permissions: |
| 42 | + contents: write |
| 43 | + steps: |
| 44 | + - uses: actions/checkout@v4 |
| 45 | + - name: 'Replace full version with custom input value' |
| 46 | + if: '${{ inputs.version }}' |
| 47 | + shell: pwsh |
| 48 | + run: 'Write-Output "version_full=${{ inputs.version }}" >> $env:GITHUB_ENV' |
| 49 | + - name: 'Generate short version' |
| 50 | + shell: pwsh |
| 51 | + run: | |
| 52 | + $ver = [SemVer]('${{ env.version_full }}'.TrimStart('v')) |
| 53 | + $short_ver = "$($ver.Major).$($ver.Minor).$($ver.Patch)" |
| 54 | + Write-Host "Got $short_ver from ${{ env.version_full }}" |
| 55 | + Write-Output "version_short=$short_ver" >> $env:GITHUB_ENV |
| 56 | + - uses: actions/setup-dotnet@v3 |
| 57 | + with: |
| 58 | + dotnet-version: '${{ env.dotnet_version }}.x' |
| 59 | + - name: "Download current redump snapshot" |
| 60 | + shell: pwsh |
| 61 | + run: | |
| 62 | + $uri = 'http://redump.org/keys/ps3/' |
| 63 | + $response = Invoke-WebRequest -Uri $uri -Method HEAD |
| 64 | + $fname = $response.Headers['Content-Disposition'].Split('=', 2)[1].Trim('"') |
| 65 | + Invoke-WebRequest -Uri $uri -OutFile "$fname" |
| 66 | + Write-Host "Got $fname" |
| 67 | + - name: 'Build release' |
| 68 | + run: >- |
| 69 | + dotnet publish |
| 70 | + -v:q |
| 71 | + --runtime ${{ matrix.rid }} |
| 72 | + --framework net${{ env.dotnet_version }}${{ matrix.target }} |
| 73 | + --self-contained |
| 74 | + --configuration ${{ matrix.configuration}} |
| 75 | + --output distrib |
| 76 | + UI.Avalonia/UI.Avalonia.csproj |
| 77 | + -p:PublishTrimmed=False |
| 78 | + -p:PublishSingleFile=True |
| 79 | + -p:DebugType=None |
| 80 | + -p:DebugSymbols=False |
| 81 | + -p:VersionPrefix=${{ env.version_short }} |
| 82 | + -p:Version=${{ env.version_full }} |
| 83 | + ${{ matrix.command_extra }} |
| 84 | + - name: 'Make artifact' |
| 85 | + shell: pwsh |
| 86 | + run: | |
| 87 | + cd distrib |
| 88 | + Get-ChildItem -Recurse | Write-Host |
| 89 | + $artifact_name = "ps3-disc-dumper_v${{ env.version_full }}.zip" |
| 90 | + if ($IsWindows) |
| 91 | + { |
| 92 | + $artifact_name = "ps3-disc-dumper_windows_v${{ env.version_full }}.zip" |
| 93 | + Compress-Archive -LiteralPath ps3-disc-dumper.exe -DestinationPath "$artifact_name" -CompressionLevel Optimal -Force |
| 94 | + } |
| 95 | + elseif ($IsLinux) # Compress-Archive does not preserve rwx attributes, so use zip on *nix |
| 96 | + { |
| 97 | + $artifact_name = "ps3-disc-dumper_linux_v${{ env.version_full }}.zip" |
| 98 | + zip -v9 "$artifact_name" ps3-disc-dumper |
| 99 | + } |
| 100 | + elseif ($IsMacOs) |
| 101 | + { |
| 102 | + $artifact_name = "ps3-disc-dumper_macos_v${{ env.version_full }}.zip" |
| 103 | + codesign --deep -fs - 'PS3 Disc Dumper.app' |
| 104 | + zip -vr9 "$artifact_name" 'PS3 Disc Dumper.app/' -x '*.DS_Store' |
| 105 | + } |
| 106 | + Write-Output "artifact_name=$artifact_name" >> $env:GITHUB_ENV |
| 107 | + - name: 'Create or update GitHub release draft' |
| 108 | + if: ${{ inputs.version }} |
| 109 | + uses: ncipollo/release-action@v1 |
| 110 | + with: |
| 111 | + commit: '${{ github.sha }}' |
| 112 | + tag: '${{ env.version_full }}' |
| 113 | + draft: true |
| 114 | + prerelease: true |
| 115 | + allowUpdates: true |
| 116 | + generateReleaseNotes: true |
| 117 | + artifacts: 'distrib/ps3-disc-dumper_*.zip' |
| 118 | + artifactContentType: application/zip |
| 119 | + replacesArtifacts: true |
| 120 | + omitBodyDuringUpdate: true |
| 121 | + omitNameDuringUpdate: true |
| 122 | + omitPrereleaseDuringUpdate: true |
| 123 | + - name: 'Create or update GitHub custom release draft' |
| 124 | + if: ${{ github.event_name == 'push' }} |
| 125 | + uses: ncipollo/release-action@v1 |
| 126 | + with: |
| 127 | + draft: true |
| 128 | + prerelease: true |
| 129 | + allowUpdates: true |
| 130 | + generateReleaseNotes: true |
| 131 | + artifacts: 'distrib/ps3-disc-dumper_*.zip' |
| 132 | + artifactContentType: application/zip |
| 133 | + replacesArtifacts: true |
| 134 | + omitBodyDuringUpdate: true |
| 135 | + omitNameDuringUpdate: true |
| 136 | + omitPrereleaseDuringUpdate: true |
| 137 | + |
| 138 | + |
0 commit comments