Files
SHERPA/.gitlab-ci.yml
2023-07-17 18:34:56 +02:00

238 lines
8.6 KiB
YAML

variables:
NUGET_PATH: 'C:\Tools\nuget.exe'
MSBUILD_PATH: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MSBuild.exe'
ASPNET_MERGE_PATH: 'C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools'
EXE_RELEASE_FOLDER: 'c:\Projetcs\Compiled\MoonPro\Release'
DEPLOY_FOLDER: 'c:\Projects\Deploy\MoonPro\Builds'
VERS_MAIN: '1.18'
NEW_REL: ''
NEXUS_PATH: 'SHERPA.BBM.UI'
APP_NAME: 'SHERPA.BBM.UI'
SOL_NAME: 'SHERPA.BBM.UI'
.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"
# 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
$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 "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
# 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
# helper x fix version number
.version-fix: &version-fix
- |
$env:NEW_REL = $env:VERS_MAIN+"."+(get-date -format yyMM)+"."+(get-date -format dHH)
echo "Set vers: $env:NEW_REL"
$contenuto = Get-Content -path 'VersGen\VersGen.cs' -Raw
$newContenuto = $contenuto -replace '0.0.0.0', $env:NEW_REL
$newContenuto | Set-Content -Path 'VersGen\VersGen.cs'
stages:
- build
# - test
- deploy
# - installer
- release
# --------------------- BUILD stage ---------------------
SHERPA.BBM.UI:build:
stage: build
tags:
- win
before_script:
- *nuget-fix
- dotnet restore "$env:APP_NAME.sln"
- dotnet restore "$env:APP_NAME/$env:APP_NAME.csproj"
script:
- dotnet build "$env:APP_NAME/$env:APP_NAME.csproj"
Net:build:
stage: build
variables:
APP_NAME: 'SHERPA'
tags:
- win
before_script:
- *nuget-fix
- '& "$env:NUGET_PATH" restore SHERPA.sln -verbosity quiet'
- *version-fix
script:
- '& "$env:MSBUILD_PATH" SHERPA/SHERPA.csproj -target:Build /p:Configuration=Release /p:Platform="Any CPU" /p:OutputPath=bin/ /verbosity:minimal /m'
SHERPA.AD:build:
stage: build
tags:
- win
variables:
APP_NAME: 'SHERPA.AD'
SOL_NAME: 'SHERPA.BBM.UI'
before_script:
- *nuget-fix
- dotnet restore "$env:SOL_NAME.sln"
- dotnet restore "$env:APP_NAME/$env:APP_NAME.csproj"
script:
- dotnet build "$env:APP_NAME/$env:APP_NAME.csproj"
# --------------------- DEPLOY stage ---------------------
SHERPA.BBM.UI:IIS01:deploy:
stage: deploy
tags:
- win
variables:
APP_NAME: 'SHERPA.BBM.UI'
SOL_NAME: 'SHERPA.BBM.UI'
only:
- develop
needs: ["SHERPA.BBM.UI:build"]
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
SHERPA.AD:IIS01:deploy:
stage: deploy
tags:
- win
variables:
APP_NAME: 'SHERPA.AD'
SOL_NAME: 'SHERPA.BBM.UI'
only:
- develop
needs: ["SHERPA.AD:build"]
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
Net:IIS01:deploy:
stage: deploy
variables:
APP_NAME: 'SHERPA'
tags:
- win
only:
- develop
needs: ["Net:build"]
before_script:
- *nuget-fix
- '& "$env:NUGET_PATH" restore SHERPA.sln -verbosity quiet'
- *version-fix
script:
- '& "$env:MSBUILD_PATH" SHERPA/SHERPA.csproj -target:Build /p:Configuration=Release /p:Platform="Any CPU" /p:OutputPath=bin/ /verbosity:minimal /m'
- '& "$env:MSBUILD_PATH" /p:AspnetMergePath=$env:ASPNET_MERGE_PATH /p:DeployOnBuild=true /p:Targets=Publish /p:PublishProfile=IIS01.pubxml /p:RunCodeAnalysis=false /p:Configuration=Release /p:username=jenkins /p:Password=$IIS_PWD /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ /verbosity:minimal SHERPA/SHERPA.csproj'
# --------------------- RELEASE stage ---------------------
SHERPA.BBM.UI:IIS04:release:
stage: release
tags:
- win
variables:
APP_NAME: 'SHERPA.BBM.UI'
SOL_NAME: 'SHERPA.BBM.UI'
only:
- master
needs: ["SHERPA.BBM.UI:build"]
script:
- dotnet publish -p:PublishProfile=IISProfile.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release -p:username=jenkins -p:Password=$IIS_PWD -p:AllowUntrustedCertificate=true $env:APP_NAME/$env:APP_NAME.csproj
Net:IIS04:release:
stage: release
variables:
APP_NAME: 'SHERPA'
tags:
- win
only:
- master
needs: ["Net:build"]
before_script:
- *nuget-fix
- '& "$env:NUGET_PATH" restore SHERPA.sln -verbosity quiet'
- *version-fix
script:
- '& "$env:MSBUILD_PATH" SHERPA/SHERPA.csproj -target:Build /p:Configuration=Release /p:Platform="Any CPU" /p:OutputPath=bin/ /verbosity:minimal /m'
- '& "$env:MSBUILD_PATH" /p:AspnetMergePath=$env:ASPNET_MERGE_PATH /p:DeployOnBuild=true /p:Targets=Publish /p:PublishProfile=IIS-PROD.pubxml /p:RunCodeAnalysis=false /p:Configuration=Release /p:username=jenkins /p:Password=$IIS_PWD /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ /verbosity:minimal SHERPA/SHERPA.csproj'
Net:IIS02:release:
stage: release
variables:
APP_NAME: 'SHERPA'
tags:
- win
only:
- master
needs: ["Net:build"]
before_script:
- *nuget-fix
- '& "$env:NUGET_PATH" restore SHERPA.sln -verbosity quiet'
- *version-fix
script:
- '& "$env:MSBUILD_PATH" SHERPA/SHERPA.csproj -target:Build /p:Configuration=Release /p:Platform="Any CPU" /p:OutputPath=bin/ /verbosity:minimal /m'
- '& "$env:MSBUILD_PATH" /p:AspnetMergePath=$env:ASPNET_MERGE_PATH /p:DeployOnBuild=true /p:Targets=Publish /p:PublishProfile=IIS02.pubxml /p:RunCodeAnalysis=false /p:Configuration=Release /p:username=jenkins /p:Password=$IIS_PWD /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ /verbosity:minimal SHERPA/SHERPA.csproj'
SHERPA.AD:IIS04:release:
stage: release
tags:
- win
variables:
APP_NAME: 'SHERPA.AD'
SOL_NAME: 'SHERPA.BBM.UI'
only:
- master
needs: ["SHERPA.AD:build"]
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