Files
2025-09-29 19:10:02 +02:00

198 lines
7.6 KiB
YAML

variables:
VERS_MAIN: '1.0'
# NEXUS_PATH: 'LUX'
PROJ_PATH: ''
NUM_REL: '0.1.2.3'
NU_TYPE: 'Debug'
APP_NAME: 'Egw.Window.Data'
SOL_NAME: 'Egw.Window'
NUGET_PATH: 'C:\Tools\nuget.exe'
DEST: 'install'
# nota: cer creazione rules: https://docs.gitlab.com/ee/ci/jobs/job_control.html#common-if-clauses-for-rules
# helper x fix pacchetti nuget da repo locale nexus.steamware.net
.nuget-fix: &nuget-fix
- |
echo "esecuzione Nuget FIX steps"
dotnet nuget list source
$hasSource = dotnet nuget list source | Select-String -Pattern "Steamware Nexus Proxy"
if (! [String]::IsNullOrWhiteSpace($hasSource)) {
dotnet nuget remove source "`"Steamware Nexus Proxy`""
}
$hasSource = dotnet nuget list source | Select-String -Pattern "Steamware Nexus"
if (! [String]::IsNullOrWhiteSpace($hasSource)) {
dotnet nuget remove source "`"Steamware Nexus`""
}
$hasSource = dotnet nuget list source | Select-String -Pattern "nexus-proxy-v3"
if (! [String]::IsNullOrWhiteSpace($hasSource)) {
dotnet nuget remove source nexus-proxy-v3
}
$hasSource = dotnet nuget list source | Select-String -Pattern "nexus-hosted"
if (! [String]::IsNullOrWhiteSpace($hasSource)) {
dotnet nuget remove source nexus-hosted
}
$hasSource = dotnet nuget list source | Select-String -Pattern "Microsoft Visual Studio Offline Packages"
if (! [String]::IsNullOrWhiteSpace($hasSource)) {
dotnet nuget remove source 'Microsoft Visual Studio Offline Packages'
}
echo "Situazione sorgenti post remove:"
dotnet nuget list source
dotnet nuget add source https://nexus.steamware.net/repository/nuget-proxy-v3/index.json -n nexus-proxy-v3 -u nugetUser -p $NEXUS_PASSWD --store-password-in-clear-text
dotnet nuget add source https://nexus.steamware.net/repository/nuget-hosted/ -n nexus-hosted -u nugetUser -p $NEXUS_PASSWD --store-password-in-clear-text
$hasSource = dotnet nuget list source
echo "Situazione sorgenti FINALE:"
dotnet nuget list source
# helper creazione hash files x IIS
.hashBuild: &hashBuild
- |
$Target = $env:APP_NAME + "\bin\publish\" + $env:APP_NAME + ".zip"
$MD5 = Get-FileHash $Target -Algorithm MD5
$SHA1 = Get-FileHash $Target -Algorithm SHA1
New-Item $Target".md5"
New-Item $Target".sha1"
$MD5.Hash | Set-Content -Path $Target".md5"
$SHA1.Hash | Set-Content -Path $Target".sha1"
echo "Created HASH files for $Target"
# helper x send su NEXUS x pack
.nexusUpload: &nexusUpload
- |
Set-Alias mCurl C:\Windows\system32\curl.exe
$fileVers = $env:APP_NAME + "\Resources\VersNum.txt"
$VersNumb = Get-Content $fileVers
echo "Curr Version: $VersNumb"
if($CI_COMMIT_BRANCH -eq "master")
{
$version = "stable"
}
else
{
$version = "unstable"
}
$File2Send = Get-ChildItem($env:APP_NAME + "\bin\publish\*")
ForEach ($File in $File2Send) {
$FileName = Split-Path $File -leaf
mCurl -v -u GitLab:$NEXUS_PASSWD --upload-file $File https://nexus.steamware.net/repository/SWS/$env:NEXUS_PATH/$version/LAST/$FileName
mCurl -v -u GitLab:$NEXUS_PASSWD --upload-file $File https://nexus.steamware.net/repository/SWS/$env:NEXUS_PATH/$version/ARCHIVE/$VersNumb/$FileName
}
mCurl -v -u GitLab:$NEXUS_PASSWD --upload-file "$env:APP_NAME\Resources\manifest.xml" https://nexus.steamware.net/repository/SWS/$env:NEXUS_PATH/$version/LAST/manifest.xml
mCurl -v -u GitLab:$NEXUS_PASSWD --upload-file "$env:APP_NAME\Resources\ChangeLog.html" https://nexus.steamware.net/repository/SWS/$env:NEXUS_PATH/$version/LAST/ChangeLog.html
# helper x fix version number
.version-fix: &version-fix
- |
$env:NEW_REL = $env:VERS_MAIN+"."+(get-date -format yyMM)+"."+(get-date -format ddHH)
$env:NUM_REL = $env:VERS_MAIN+"."+(get-date -format yyMM)+"."+(get-date -format dHH)
$env:NUM_DEB = $env:VERS_MAIN+"."+(get-date -format yyMM)+"-beta."+(get-date -format dHH)
# display versioni generate
$resoconto = "Effettuato fix file VersGen | release v: " + $env:NUM_REL + " | debug v: " + $env:NUM_DEB;
Write-Output $resoconto;
echo "Replace completati"
# helper x fix nuspec file: se debug aggiunge -beta nel blocco 3 del SemVer
.nuspec-fix: &nuspec-fix
- |
echo "Modifica dati versione pacchetto nuget"
$fileNameRel = "$env:APP_NAME/$env:APP_NAME.csproj";
$fileContent = Get-Content $fileNameRel -Raw;
$pattern = '(?i)<Version>\s*(.*?)\s*</Version>'
$vers = if ($fileContent -match $pattern) { $matches[1] } else { $null }
echo "Versione corrente: $vers | NugetType: $env:NU_TYPE"
if ($env:NU_TYPE -eq "Debug")
{
$env:NUM_REL = $vers -replace '^(\d+)\.(\d+)\.(\d+)\.(\d+)$', '$1.$2.$3-beta.$4'
}
elseif($env:NU_TYPE -eq "Release")
{
$env:NUM_REL = $vers
}
echo "Versione calcolata: $env:NUM_REL"
$findVers = "<Version>(.|\n)*?</Version>";
$replVers = "<Version>" + $env:NUM_REL + "</Version>";
$newContent = $fileContent -replace $findVers, $replVers;
Set-Content -Path $fileNameRel -Value $newContent;
echo "Modifica dati file progetto x nuspec completata su file $fileNameRel"
# Stages previsti
stages:
- build
- deploy
- release
# --------------------------------
# BUILD
# --------------------------------
Egw.Window.Data:build:
stage: build
tags:
- win
variables:
APP_NAME: Egw.Window.Data
SOL_NAME: Egw.Window
rules:
- if: $CI_COMMIT_BRANCH == 'develop'
- if: $CI_COMMIT_BRANCH == 'main'
- if: $CI_COMMIT_BRANCH =~ /^feature\/Test.UI.+/
when: always
before_script:
- *nuget-fix
- dotnet restore "$env:SOL_NAME.sln"
script:
- echo $CI_COMMIT_BRANCH
- dotnet build $env:APP_NAME/$env:APP_NAME.csproj
# --------------------------------
# DEPLOY develop (IIS01 + beta nuget)
# --------------------------------
Egw.Window.Data:SDK:deploy:
stage: deploy
tags:
- win
variables:
APP_NAME: Egw.Window.Data
SOL_NAME: Egw.Window
NU_TYPE: Debug
before_script:
- *nuget-fix
- dotnet restore "$env:SOL_NAME.sln"
rules:
- if: $CI_COMMIT_BRANCH == 'develop'
- if: $CI_COMMIT_BRANCH =~ /^feature\/Test.UI.+/
when: always
needs: ["Egw.Window.Data:build"]
script:
- dotnet build $env:APP_NAME/$env:APP_NAME.csproj
- *nuspec-fix
- dotnet pack -p:Configuration=Debug -p:verbosity=quiet --output $env:APP_NAME/bin/ $env:APP_NAME/$env:APP_NAME.csproj
- '& "$env:NUGET_PATH" setapikey $NUGET_API_KEY -source http://nexus.steamware.net/repository/nuget-hosted'
- '& "$env:NUGET_PATH" push $env:APP_NAME/bin/$env:APP_NAME.$env:NUM_REL.nupkg -Source http://nexus.steamware.net/repository/nuget-hosted'
# --------------------------------
# RELEASE (main brach only)
# --------------------------------
Egw.Window.Data:SDK:SDK:release:
stage: release
tags:
- win
variables:
APP_NAME: Egw.Window.Data
SOL_NAME: Egw.Window
NU_TYPE: Release
before_script:
- *nuget-fix
- dotnet restore "$env:SOL_NAME.sln"
rules:
- if: $CI_COMMIT_BRANCH == 'main'
needs: ["Egw.Window.Data:build"]
script:
- dotnet build $env:APP_NAME/$env:APP_NAME.csproj
- *nuspec-fix
- dotnet pack -p:Configuration=Debug -p:verbosity=quiet --output $env:APP_NAME/bin/ $env:APP_NAME/$env:APP_NAME.csproj
- '& "$env:NUGET_PATH" setapikey $NUGET_API_KEY -source http://nexus.steamware.net/repository/nuget-hosted'
- '& "$env:NUGET_PATH" push $env:APP_NAME/bin/$env:APP_NAME.$env:NUM_REL.nupkg -Source http://nexus.steamware.net/repository/nuget-hosted'