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