88 lines
3.6 KiB
YAML
88 lines
3.6 KiB
YAML
name: Release PCL-ISE
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
|
|
jobs:
|
|
release:
|
|
# Register a Windows host runner with the label windows:host.
|
|
runs-on: ${{ vars.PCL_WINDOWS_RUNNER_LABEL || 'windows' }}
|
|
permissions:
|
|
contents: read
|
|
releases: write
|
|
env:
|
|
PCL_BUILD_CONFIGURATION: ${{ vars.PCL_BUILD_CONFIGURATION || 'Snapshot' }}
|
|
defaults:
|
|
run:
|
|
shell: pwsh
|
|
steps:
|
|
- name: Checkout
|
|
uses: https://github.com/actions/checkout@v4
|
|
with:
|
|
fetch-depth: 1
|
|
submodules: recursive
|
|
persist-credentials: false
|
|
|
|
- name: Setup .NET SDK
|
|
uses: https://github.com/actions/setup-dotnet@v4
|
|
with:
|
|
dotnet-version: '9.0.x'
|
|
|
|
- name: Prepare build configuration
|
|
env:
|
|
PCL_MS_CLIENT_ID: ${{ vars.PCL_MS_CLIENT_ID || '4609f0a4-9d6f-40f0-918e-6d3a00413903' }}
|
|
PCL_CURSEFORGE_API_KEY: ${{ secrets.PCL_CURSEFORGE_API_KEY }}
|
|
run: ./scripts/Write-BuildCredentials.ps1 -RequireMicrosoftClientId
|
|
|
|
- name: Restore NuGet packages
|
|
run: |
|
|
dotnet restore PCLCS/PCLCS.csproj
|
|
if ($LASTEXITCODE -ne 0) { throw 'NuGet restore failed.' }
|
|
|
|
- name: Build launcher
|
|
run: |
|
|
& ./.vscode/build.ps1 -Configuration $env:PCL_BUILD_CONFIGURATION
|
|
if ($LASTEXITCODE -ne 0) { throw 'Release build failed.' }
|
|
|
|
- name: Verify packaged configuration
|
|
env:
|
|
PCL_MS_CLIENT_ID: ${{ vars.PCL_MS_CLIENT_ID || '4609f0a4-9d6f-40f0-918e-6d3a00413903' }}
|
|
PCL_CURSEFORGE_API_KEY: ${{ secrets.PCL_CURSEFORGE_API_KEY }}
|
|
run: |
|
|
$checker = Join-Path $env:RUNNER_TEMP 'Check-BuildCredentials.exe'
|
|
$compiler = Join-Path $env:WINDIR 'Microsoft.NET\Framework\v4.0.30319\csc.exe'
|
|
$source = Join-Path (Get-Location) 'tests\Check-BuildCredentials.cs'
|
|
& $compiler /nologo /target:exe "/out:$checker" $source
|
|
if ($LASTEXITCODE -ne 0) { throw 'Configuration checker compilation failed.' }
|
|
& $checker 'Plain Craft Launcher 2/bin/Plain Craft Launcher 2.exe' packaged
|
|
if ($LASTEXITCODE -ne 0) { throw 'Packaged configuration verification failed.' }
|
|
|
|
- name: Verify update replacement
|
|
run: ./tests/Test-LauncherUpdate.ps1 -LauncherPath 'Plain Craft Launcher 2/bin/Plain Craft Launcher 2.exe'
|
|
|
|
- name: Prepare release assets
|
|
run: |
|
|
$artifactDirectory = Join-Path (Get-Location) 'artifacts/release'
|
|
[IO.Directory]::CreateDirectory($artifactDirectory) | Out-Null
|
|
$exePath = Join-Path $artifactDirectory 'PCL-ISE.exe'
|
|
Copy-Item -LiteralPath 'Plain Craft Launcher 2/bin/Plain Craft Launcher 2.exe' -Destination $exePath -Force
|
|
$hash = (Get-FileHash -LiteralPath $exePath -Algorithm SHA256).Hash.ToLowerInvariant()
|
|
[IO.File]::WriteAllText(($exePath + '.sha256'), "$hash PCL-ISE.exe`n", [Text.UTF8Encoding]::new($false))
|
|
|
|
- name: Publish release
|
|
env:
|
|
PCL_RELEASE_TOKEN: ${{ secrets.RELEASE_TOKEN || secrets.GITEA_TOKEN }}
|
|
PCL_GITEA_SERVER_URL: ${{ gitea.server_url }}
|
|
PCL_GITEA_REPOSITORY: ${{ gitea.repository }}
|
|
PCL_RELEASE_TAG: ${{ gitea.ref_name }}
|
|
run: |
|
|
./scripts/Publish-GiteaRelease.ps1 -ServerUrl $env:PCL_GITEA_SERVER_URL -Repository $env:PCL_GITEA_REPOSITORY -Tag $env:PCL_RELEASE_TAG
|
|
|
|
- name: Clean generated configuration
|
|
if: ${{ always() }}
|
|
run: |
|
|
$path = 'Plain Craft Launcher 2/obj/BuildCredentials.json'
|
|
if (Test-Path -LiteralPath $path) { Remove-Item -LiteralPath $path -Force }
|