обновление json parse
All checks were successful
Release / pack-and-publish (release) Successful in 45s
All checks were successful
Release / pack-and-publish (release) Successful in 45s
This commit is contained in:
100
YandexMusic.API/nuget-publish.ps1
Normal file
100
YandexMusic.API/nuget-publish.ps1
Normal file
@@ -0,0 +1,100 @@
|
||||
param(
|
||||
[string]$Version
|
||||
)
|
||||
|
||||
Write-Host "=== YandexMusic Manual Publisher ===" -ForegroundColor Cyan
|
||||
|
||||
# --- Ask for version if not provided ---
|
||||
if (-not $Version) {
|
||||
$Version = Read-Host "Введите версию пакета (например 1.2.3). Пусто = взять из git-тега"
|
||||
|
||||
if (-not $Version) {
|
||||
Write-Host "Читаю версию из git..." -ForegroundColor Yellow
|
||||
$tag = git describe --tags --abbrev=0 2>$null
|
||||
|
||||
if (-not $tag) {
|
||||
Write-Host "ОШИБКА: версия не указана и git-тег не найден." -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
$Version = $tag.TrimStart("v")
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host "Используемая версия: $Version" -ForegroundColor Green
|
||||
|
||||
# --- Paths ---
|
||||
$csprojPath = "YandexMusic/YandexMusic.csproj"
|
||||
$backupPath = "$csprojPath.bak"
|
||||
$artifacts = "artifacts"
|
||||
|
||||
# --- Backup original csproj ---
|
||||
Write-Host "Создаю резервную копию $csprojPath ..." -ForegroundColor Cyan
|
||||
Copy-Item $csprojPath $backupPath -Force
|
||||
|
||||
# --- Replace ProjectReference with PackageReference ---
|
||||
Write-Host "Патчу csproj..." -ForegroundColor Cyan
|
||||
|
||||
(Get-Content $csprojPath) `
|
||||
-replace '<ProjectReference Include="..\/YandexMusic.API\/YandexMusic.API.csproj" \/>',
|
||||
"<PackageReference Include=`"YandexMusic.API`" Version=`"$Version`" />" |
|
||||
Set-Content $csprojPath
|
||||
|
||||
Write-Host "ProjectReference → PackageReference заменён." -ForegroundColor Green
|
||||
|
||||
# --- Build & Pack ---
|
||||
$projects = @(
|
||||
"YandexMusic.API",
|
||||
"YandexMusic"
|
||||
)
|
||||
|
||||
if (Test-Path $artifacts) {
|
||||
Remove-Item $artifacts -Recurse -Force
|
||||
}
|
||||
New-Item -ItemType Directory -Path $artifacts | Out-Null
|
||||
|
||||
try {
|
||||
foreach ($proj in $projects) {
|
||||
Write-Host "Restoring $proj ..." -ForegroundColor Cyan
|
||||
dotnet restore $proj
|
||||
|
||||
Write-Host "Building $proj ..." -ForegroundColor Cyan
|
||||
dotnet build $proj -c Release -p:Version=$Version
|
||||
|
||||
Write-Host "Packing $proj ..." -ForegroundColor Cyan
|
||||
dotnet pack $proj -c Release --no-build -p:PackageVersion=$Version -o $artifacts
|
||||
}
|
||||
|
||||
Write-Host "Сборка и упаковка завершены." -ForegroundColor Green
|
||||
|
||||
# --- Publish ---
|
||||
$apiKey = $env:NUGET_API_KEY
|
||||
if (-not $apiKey) {
|
||||
Write-Host "ОШИБКА: переменная окружения NUGET_API_KEY не установлена." -ForegroundColor Red
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "Публикую пакеты..." -ForegroundColor Cyan
|
||||
|
||||
dotnet nuget push "$artifacts\*.nupkg" `
|
||||
--source "https://git.frigat.duckdns.org/api/packages/FrigaT/nuget/index.json" `
|
||||
--api-key $apiKey `
|
||||
--skip-duplicate
|
||||
|
||||
Write-Host "Публикация завершена." -ForegroundColor Green
|
||||
}
|
||||
finally {
|
||||
# --- Restore original csproj ---
|
||||
Write-Host "Восстанавливаю оригинальный csproj..." -ForegroundColor Cyan
|
||||
Move-Item $backupPath $csprojPath -Force
|
||||
|
||||
# --- Cleanup artifacts ---
|
||||
if (Test-Path $artifacts) {
|
||||
Write-Host "Удаляю artifacts..." -ForegroundColor Cyan
|
||||
Remove-Item $artifacts -Recurse -Force
|
||||
}
|
||||
|
||||
Write-Host "Откат завершён." -ForegroundColor Green
|
||||
}
|
||||
|
||||
Write-Host "Готово." -ForegroundColor Cyan
|
||||
Reference in New Issue
Block a user