feat: prepare PCL-ISE 0.1.2 update test release
Release PCL-ISE / release (push) Canceled after 0s

This commit is contained in:
Coldsmile_7 committed 2026-10-27 23:57:25 +08:00
1 parent 5d549ff66a
commit e831d0dfe0
28 files changed
+1026 -286

No files matched your search

+57
View File
@@ -0,0 +1,57 @@
#Requires -Version 7.0
[CmdletBinding()]
param(
[Parameter(Mandatory)][string]$ServerUrl,
[Parameter(Mandatory)][string]$Repository,
[Parameter(Mandatory)][string]$Tag,
[string]$ArtifactDirectory = (Join-Path $PSScriptRoot '..\artifacts\release')
)
$ErrorActionPreference = 'Stop'
if ([string]::IsNullOrWhiteSpace($env:PCL_RELEASE_TOKEN)) {
throw 'Provide the job token GITEA_TOKEN or repository secret RELEASE_TOKEN with permission to publish releases.'
}
if ($Tag -cnotmatch '^v\d+\.\d+\.\d+$') { throw 'Release tags must use vMAJOR.MINOR.PATCH, for example v0.1.2.' }
if ($Repository -notmatch '^[^/]+/[^/]+$') { throw 'Repository must use owner/repository format.' }
$exePath = Join-Path $ArtifactDirectory 'PCL-ISE.exe'
$hashPath = Join-Path $ArtifactDirectory 'PCL-ISE.exe.sha256'
foreach ($path in @($exePath, $hashPath)) {
if (-not (Test-Path -LiteralPath $path -PathType Leaf)) { throw 'A release asset is missing.' }
}
$version = [Reflection.AssemblyName]::GetAssemblyName($exePath).Version
if ($version -ne [Version]($Tag.Substring(1) + '.0')) { throw 'Release tag does not match the executable assembly version.' }
$expectedHash = (Get-FileHash -LiteralPath $exePath -Algorithm SHA256).Hash.ToLowerInvariant()
$checksum = [IO.File]::ReadAllText($hashPath).Trim()
if ($checksum -cne "$expectedHash PCL-ISE.exe") { throw 'The release checksum does not match the executable.' }
$repositoryPath = ($Repository.Split('/') | ForEach-Object { [Uri]::EscapeDataString($_) }) -join '/'
$apiUrl = $ServerUrl.TrimEnd('/') + '/api/v1/repos/' + $repositoryPath + '/releases'
$headers = @{ Authorization = 'token ' + $env:PCL_RELEASE_TOKEN }
try {
$null = Invoke-RestMethod -Method Get -Uri "$apiUrl/tags/$Tag" -Headers $headers
throw 'A release already exists for this tag. Existing releases are never overwritten.'
} catch {
if (-not $_.Exception.Response -or [int]$_.Exception.Response.StatusCode -ne 404) { throw }
}
$notesPath = Join-Path $PSScriptRoot ('..\docs\changelog\' + $Tag.Substring(1) + '.md')
if (-not (Test-Path -LiteralPath $notesPath -PathType Leaf)) {
throw 'Add docs/changelog/MAJOR.MINOR.PATCH.md before publishing a release.'
}
$payload = @{
tag_name = $Tag
name = "PCL-ISE $Tag"
body = [IO.File]::ReadAllText($notesPath)
draft = $true
prerelease = $false
} | ConvertTo-Json
$release = Invoke-RestMethod -Method Post -Uri $apiUrl -Headers $headers -ContentType 'application/json; charset=utf-8' -Body ([Text.Encoding]::UTF8.GetBytes($payload))
# Keep the release as a draft if either asset upload fails.
foreach ($path in @($exePath, $hashPath)) {
$name = [Uri]::EscapeDataString([IO.Path]::GetFileName($path))
$null = Invoke-RestMethod -Method Post -Uri "$apiUrl/$($release.id)/assets?name=$name" -Headers $headers -Form @{ attachment = Get-Item -LiteralPath $path }
}
$published = Invoke-RestMethod -Method Patch -Uri "$apiUrl/$($release.id)" -Headers $headers -ContentType 'application/json' -Body '{"draft":false}'
Write-Host ('Published release: ' + $published.html_url)
+31
View File
@@ -0,0 +1,31 @@
[CmdletBinding()]
param(
[string]$OutputPath = (Join-Path $PSScriptRoot '..\Plain Craft Launcher 2\obj\BuildCredentials.json'),
[switch]$RequireMicrosoftClientId
)
$ErrorActionPreference = 'Stop'
$OutputPath = [IO.Path]::GetFullPath($OutputPath)
# Remove credentials from a previous run before validating new input.
if (Test-Path -LiteralPath $OutputPath) { Remove-Item -LiteralPath $OutputPath -Force }
$clientId = $env:PCL_MS_CLIENT_ID
if ($clientId) { $clientId = $clientId.Trim() }
if ($RequireMicrosoftClientId -and [string]::IsNullOrWhiteSpace($clientId)) {
throw 'Set the repository variable PCL_MS_CLIENT_ID before building a release.'
}
if (-not [string]::IsNullOrWhiteSpace($clientId)) {
$parsedId = [Guid]::Empty
if (-not [Guid]::TryParse($clientId, [ref]$parsedId) -or $parsedId -eq [Guid]::Empty) {
throw 'PCL_MS_CLIENT_ID must be a non-empty application client GUID.'
}
}
$credentials = [ordered]@{
PCL_MS_CLIENT_ID = [string]$clientId
PCL_CURSEFORGE_API_KEY = [string]$env:PCL_CURSEFORGE_API_KEY
}
[IO.Directory]::CreateDirectory((Split-Path $OutputPath -Parent)) | Out-Null
[IO.File]::WriteAllText($OutputPath, ($credentials | ConvertTo-Json -Compress), [Text.UTF8Encoding]::new($false))
Write-Host ('Microsoft Client ID embedded: ' + (-not [string]::IsNullOrWhiteSpace($clientId)))
Write-Host ('CurseForge API key embedded: ' + (-not [string]::IsNullOrWhiteSpace($env:PCL_CURSEFORGE_API_KEY)))