develop #1
1 changed files with 46 additions and 18 deletions
Install .net sdk 10 on runner
commit
90c50358d1
|
|
@ -23,9 +23,23 @@ build_windows:
|
|||
tags:
|
||||
- saas-windows-medium-amd64
|
||||
script:
|
||||
- dotnet --info
|
||||
- dotnet restore
|
||||
- dotnet build "imagecatalog\ImageCatalog 2.csproj" -c $BUILD_CONFIG -v minimal
|
||||
- |
|
||||
powershell -NoProfile -Command {
|
||||
$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:
|
||||
paths:
|
||||
- "**/bin/$BUILD_CONFIG/net10.0-windows/**"
|
||||
|
|
@ -39,21 +53,35 @@ publish_release:
|
|||
needs:
|
||||
- build_windows
|
||||
script:
|
||||
# Publish the app
|
||||
- dotnet publish "imagecatalog\ImageCatalog 2.csproj" -c $BUILD_CONFIG -r win-x64 --self-contained false -o publish
|
||||
- echo "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"
|
||||
- |
|
||||
powershell -NoProfile -Command {
|
||||
# Ensure .NET 10 SDK is available (install to user folder if missing) and use that dotnet for publish
|
||||
$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 {
|
||||
$dotnetExe = 'dotnet'
|
||||
}
|
||||
|
||||
& $dotnetExe publish "imagecatalog\ImageCatalog 2.csproj" -c $env:BUILD_CONFIG -r win-x64 --self-contained false -o publish
|
||||
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:
|
||||
paths:
|
||||
- publish/*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue