Files
limanapp/.gitlab-ci.yml
2025-01-04 12:44:38 +01:00

281 lines
9.1 KiB
YAML

variables:
VERS_MAIN: '2.1'
NEXUS_PATH: 'LiMan'
APP_NAME: 'LiMan.UI'
SOL_NAME: 'LiMan.UI'
NUGET_PATH: 'C:\Tools\nuget.exe'
MSBUILD_PATH: 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\MSBuild.exe'
SRC_ZIP_PATH: 'bin\publish\net6.0'
# 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
}
dotnet nuget add source https://nexus.steamware.net/repository/nuget-group-3/index.json -n "Steamware Nexus" -u nugetUser -p $NEXUS_PASSWD --store-password-in-clear-text
echo "Steamware Nexus Source added, final state:"
dotnet nuget list source
# helper creazione files zip
.zipper: &zipper
- |
$7zipPath = $env:ProgramFiles+"\7-Zip\7z.exe"
if (-not (Test-Path -Path $7zipPath -PathType Leaf)) {
throw "7 zip file '$7zipPath' not found"
}
Set-Alias 7zip $7zipPath
$Target = "$env:APP_NAME\Releases\" + $CI_COMMIT_BRANCH + "\" + $env:APP_NAME + ".zip"
$Source = "$env:APP_NAME\$SRC_ZIP_PATH\*"
echo "calling 7zip $Source --> $Target"
7zip a -tzip $Target $Source -xr!DATA
#cd "$env:APP_NAME\bin\publish\net6.0"
# helper creazione hash files x IIS
.hashBuild: &hashBuild
- |
$Target = "$env:APP_NAME\Releases\" + $CI_COMMIT_BRANCH + "\" + $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
$currentDate = get-date -format yyMM;
$currentTime = get-date -format ddHH;
$fileVers = $env:APP_NAME + "\Resources\VersNum.txt"
$VersNumb = Get-Content $fileVers
echo "Curr Version: $VersNumb"
if($CI_COMMIT_BRANCH -eq "main")
{
$version = "stable"
}
else
{
$version = "unstable"
}
$File2Send = Get-ChildItem("$env:APP_NAME\Releases\" + $CI_COMMIT_BRANCH + "\*")
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
echo "mCurl -v -u GitLab:$NEXUS_PASSWD --upload-file $File https://nexus.steamware.net/repository/SWS/$env:NEXUS_PATH/$version/LAST/$FileName"
}
# mCurl -v -u $env:NEXUS_USER:$env:NEXUS_PASSWD --upload-file bin/release/$env:APP_NAME.zip $env:NEXUS_SERVER/utility/$env:NEXUS_PATH/$version/$env:APP_NAME-$version.zip
# image: mcr.microsoft.com/dotnet/sdk:6.0
# 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)
$env:NEW_COPYRIGHT = "EgalWare @ 2021-" + (get-date -format yyyy)
#$contenuto = Get-Content -path 'VersGen\VersGen.cs' -Raw
#$newContenuto = $contenuto -replace '0.0.0.0', $env:NEW_REL
#$newContenuto = $newContenuto -replace 'EgalWare © 2021', $env:NEW_COPYRIGHT
#$newContenuto | Set-Content -Path 'VersGen\VersGen.cs'
# 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
.nuspec-fix: &nuspec-fix
- |
echo "Modifica dati file nuspec Release"
$currRelease = $env:NUM_REL
$currDebug = $env:NUM_DEB
$find = "<version>(.|\n)*?</version>";
$fileNameRel = "$env:APP_NAME.Release.nuspec";
$replRel = "<version>" + $currRelease + "</version>";
$nuspDataRel = Get-Content $fileNameRel;
$nuspDataRelUpd = $nuspDataRel -replace $find, $replRel;
$nuspDataRelUpd = $nuspDataRelUpd -replace "#copyright#", $replCopy;
$nuspDataRelUpd = $nuspDataRelUpd -replace "#releaseNotes#", "Build $adesso";
Set-Content -Path $fileNameRel -Value $nuspDataRelUpd;
echo "Modifica dati file nuspec Debug"
$fileNameDeb = "$env:APP_NAME.Debug.nuspec";
$replDeb = "<version>" + $currDebug + "</version>";
$nuspDataDeb = Get-Content $fileNameDeb;
$nuspDataDebUpd = $nuspDataDeb -replace $find, $replDeb;
$nuspDataDebUpd = $nuspDataDebUpd -replace "#copyright#", $replCopy;
$nuspDataDebUpd = $nuspDataDebUpd -replace "#releaseNotes#", "Build $adesso";
Set-Content -Path $fileNameDeb -Value $nuspDataDebUpd;
echo "replace completati"
stages:
- build
- deploy
- release
# --------------------------------
# BUILD
# --------------------------------
UI:build:
stage: build
tags:
- win
except:
- EgwAppControlCenter
variables:
SOL_NAME: LiMan
APP_NAME: LiMan.UI
before_script:
- *nuget-fix
- dotnet restore "$env:SOL_NAME.sln"
script:
- dotnet build $env:APP_NAME/$env:APP_NAME.csproj
API:build:
stage: build
tags:
- win
except:
- EgwAppControlCenter
variables:
SOL_NAME: LiMan
APP_NAME: LiMan.Api
before_script:
- *nuget-fix
- dotnet restore "$env:SOL_NAME.sln"
script:
- dotnet build $env:APP_NAME/$env:APP_NAME.csproj
Transfer:build:
stage: build
tags:
- win
except:
- EgwAppControlCenter
variables:
SOL_NAME: LiMan
APP_NAME: LiMan.Transfer
before_script:
- *nuget-fix
- dotnet restore "$env:SOL_NAME.sln"
script:
- dotnet build $env:APP_NAME/$env:APP_NAME.csproj
# --------------------------------
# DEPLOY
# --------------------------------
UI:IIS01:deploy:
stage: deploy
tags:
- win
variables:
SOL_NAME: LiMan
APP_NAME: LiMan.UI
SRC_ZIP_PATH: bin\Release\net6.0
only:
- develop
needs: ["UI:build"]
before_script:
- *nuget-fix
script:
- dotnet publish -p:PublishProfile=IIS01.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=$IIS_PWD -p:AllowUntrustedCertificate=true $env:APP_NAME/$env:APP_NAME.csproj
- *zipper
- *hashBuild
- *nexusUpload
API:IIS01:deploy:
stage: deploy
tags:
- win
variables:
SOL_NAME: LiMan
APP_NAME: LiMan.Api
SRC_ZIP_PATH: bin\Release\net6.0
only:
- develop
needs: ["API:build"]
before_script:
- *nuget-fix
script:
- dotnet publish -p:PublishProfile=IIS01.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=$IIS_PWD -p:AllowUntrustedCertificate=true $env:APP_NAME/$env:APP_NAME.csproj
- *zipper
- *hashBuild
- *nexusUpload
UI:IIS04:deploy:
stage: deploy
tags:
- win
variables:
SOL_NAME: LiMan
APP_NAME: LiMan.UI
SRC_ZIP_PATH: bin\Release\net6.0
only:
- main
needs: ["UI:build"]
before_script:
- *nuget-fix
script:
- dotnet publish -p:PublishProfile=IIS04.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=$IIS_PWD -p:AllowUntrustedCertificate=true $env:APP_NAME/$env:APP_NAME.csproj
- *zipper
- *hashBuild
- *nexusUpload
API:IIS04:deploy:
stage: deploy
tags:
- win
except:
- EgwAppControlCenter
variables:
SOL_NAME: LiMan
APP_NAME: LiMan.Api
SRC_ZIP_PATH: bin\Release\net6.0
only:
- main
needs: ["API:build"]
before_script:
- *nuget-fix
script:
- dotnet publish -p:PublishProfile=IIS04.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=$IIS_PWD -p:AllowUntrustedCertificate=true $env:APP_NAME/$env:APP_NAME.csproj
- *zipper
- *hashBuild
- *nexusUpload
Transfer:deploy:
stage: deploy
tags:
- win
except:
- EgwAppControlCenter
variables:
SOL_NAME: LiMan
APP_NAME: LiMan.Transfer
needs: ["Transfer:build"]
before_script:
- *nuget-fix
script:
- dotnet build $env:APP_NAME/$env:APP_NAME.csproj
- dotnet publish -p:PublishProfile=SingleFileX86.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release $env:APP_NAME/$env:APP_NAME.csproj
- *zipper
- *hashBuild
- *nexusUpload