Install .net sdk 10 on runner
This commit is contained in:
parent
3898c002f2
commit
90c50358d1
1 changed files with 46 additions and 18 deletions
|
|
@ -23,9 +23,23 @@ build_windows:
|
||||||
tags:
|
tags:
|
||||||
- saas-windows-medium-amd64
|
- saas-windows-medium-amd64
|
||||||
script:
|
script:
|
||||||
- dotnet --info
|
- |
|
||||||
- dotnet restore
|
powershell -NoProfile -Command {
|
||||||
- dotnet build "imagecatalog\ImageCatalog 2.csproj" -c $BUILD_CONFIG -v minimal
|
$needsInstall = -not (dotnet --list-sdks 2>$null | Select-String '^10\.')
|
||||||
|
if ($needsInstall) {
|
||||||
|
Write-Host 'Installing .NET 10 SDK using dotnet-install.ps1'
|
||||||
|
Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile dotnet-install.ps1 -UseBasicParsing
|
||||||
|
.\dotnet-install.ps1 -Channel 10.0 -InstallDir $env:USERPROFILE\.dotnet
|
||||||
|
$dotnetExe = Join-Path $env:USERPROFILE '.dotnet\dotnet.exe'
|
||||||
|
} else {
|
||||||
|
Write-Host '.NET 10 SDK already present on PATH'
|
||||||
|
$dotnetExe = 'dotnet'
|
||||||
|
}
|
||||||
|
|
||||||
|
& $dotnetExe --info
|
||||||
|
& $dotnetExe restore
|
||||||
|
& $dotnetExe build "imagecatalog\ImageCatalog 2.csproj" -c $env:BUILD_CONFIG -v minimal
|
||||||
|
}
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- "**/bin/$BUILD_CONFIG/net10.0-windows/**"
|
- "**/bin/$BUILD_CONFIG/net10.0-windows/**"
|
||||||
|
|
@ -39,21 +53,35 @@ publish_release:
|
||||||
needs:
|
needs:
|
||||||
- build_windows
|
- build_windows
|
||||||
script:
|
script:
|
||||||
# Publish the app
|
- |
|
||||||
- dotnet publish "imagecatalog\ImageCatalog 2.csproj" -c $BUILD_CONFIG -r win-x64 --self-contained false -o publish
|
powershell -NoProfile -Command {
|
||||||
- echo "Published to $(pwd)\\publish"
|
# Ensure .NET 10 SDK is available (install to user folder if missing) and use that dotnet for publish
|
||||||
# Find first file in publish folder
|
$needsInstall = -not (dotnet --list-sdks 2>$null | Select-String '^10\.')
|
||||||
- $file = Get-ChildItem -Path publish -File | Select-Object -First 1; Write-Host "Uploading $($file.FullName)"
|
if ($needsInstall) {
|
||||||
# Upload to GitLab project uploads API to get a public URL for the artifact
|
Write-Host 'Installing .NET 10 SDK using dotnet-install.ps1'
|
||||||
- $uploadUrl = "$env:CI_API_V4_URL/projects/$env:CI_PROJECT_ID/uploads"
|
Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile dotnet-install.ps1 -UseBasicParsing
|
||||||
- $formData = "file=@$($file.FullName)"
|
.\dotnet-install.ps1 -Channel 10.0 -InstallDir $env:USERPROFILE\.dotnet
|
||||||
- $uploadResp = curl --silent --show-error --header "JOB-TOKEN:$env:CI_JOB_TOKEN" --form $formData $uploadUrl
|
$dotnetExe = Join-Path $env:USERPROFILE '.dotnet\dotnet.exe'
|
||||||
- $uploadJson = $uploadResp | ConvertFrom-Json
|
} else {
|
||||||
- $assetUrl = "$env:CI_SERVER_URL$($uploadJson.url)"
|
$dotnetExe = 'dotnet'
|
||||||
- 'Write-Host "Uploaded asset url: $assetUrl"'
|
}
|
||||||
# Create the release using uploads URL
|
|
||||||
- $body = @{ name = $env:CI_COMMIT_TAG; tag_name = $env:CI_COMMIT_TAG; description = "Automated release from CI"; assets = @{ links = @(@{ name = "$($file.Name)"; url = $assetUrl }) } } | ConvertTo-Json -Depth 10
|
& $dotnetExe publish "imagecatalog\ImageCatalog 2.csproj" -c $env:BUILD_CONFIG -r win-x64 --self-contained false -o publish
|
||||||
- Invoke-RestMethod -Method Post -Uri "$env:CI_API_V4_URL/projects/$env:CI_PROJECT_ID/releases" -Headers @{ "JOB-TOKEN" = $env:CI_JOB_TOKEN } -Body $body -ContentType "application/json"
|
Write-Host "Published to $(pwd)\\publish"
|
||||||
|
|
||||||
|
# Find first file in publish folder
|
||||||
|
$file = Get-ChildItem -Path publish -File | Select-Object -First 1; Write-Host "Uploading $($file.FullName)"
|
||||||
|
# Upload to GitLab project uploads API to get a public URL for the artifact
|
||||||
|
$uploadUrl = "$env:CI_API_V4_URL/projects/$env:CI_PROJECT_ID/uploads"
|
||||||
|
$formData = "file=@$($file.FullName)"
|
||||||
|
$uploadResp = curl --silent --show-error --header "JOB-TOKEN:$env:CI_JOB_TOKEN" --form $formData $uploadUrl
|
||||||
|
$uploadJson = $uploadResp | ConvertFrom-Json
|
||||||
|
$assetUrl = "$env:CI_SERVER_URL$($uploadJson.url)"
|
||||||
|
Write-Host "Uploaded asset url: $assetUrl"
|
||||||
|
# Create the release using uploads URL
|
||||||
|
$body = @{ name = $env:CI_COMMIT_TAG; tag_name = $env:CI_COMMIT_TAG; description = "Automated release from CI"; assets = @{ links = @(@{ name = "$($file.Name)"; url = $assetUrl }) } } | ConvertTo-Json -Depth 10
|
||||||
|
Invoke-RestMethod -Method Post -Uri "$env:CI_API_V4_URL/projects/$env:CI_PROJECT_ID/releases" -Headers @{ "JOB-TOKEN" = $env:CI_JOB_TOKEN } -Body $body -ContentType "application/json"
|
||||||
|
}
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- publish/*
|
- publish/*
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue