Files
QRC-UTILS/.gitlab-ci.yml
Samuele Locatelli 24974927b2 typo
2022-04-12 08:48:01 +02:00

179 lines
6.9 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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'
VERS_MAIN: '1.2'
NEW_REL: ''
NEXUS_PATH: 'ZCode'
APP_NAME: 'QR-GEN'
APP_CONF: 'Release'
PROJ_NAME: 'QR-GEN'
# helper x fix pacchetti nuget da repo locale nexus.steamware.net
.nuget-fix: &nuget-fix
- |
$hasSource = C:\Tools\nuget.exe sources list | find "`"Steamware Nexus`"" /C
if ($hasSource -eq 0) {
C:\Tools\nuget.exe sources Add -Name "`"Steamware Nexus`"" -Source https://nexus.steamware.net/repository/nuget-group -username "`"nugetUser`"" -password "`"viaDante16`""
} else {
C:\Tools\nuget.exe sources Update -Name "`"Steamware Nexus`"" -Source https://nexus.steamware.net/repository/nuget-group -username "`"nugetUser`"" -password "`"viaDante16`""
}
echo $hasSource
# helper x fix version number
.version-fix: &version-fix
- |
# Esecuzione fix numero versione x pack nuget
$fileNameAss = ".\$env:APP_NAME\Properties\AssemblyInfo.cs";
$find = "assembly: AssemblyVersion";
$riga = Select-String $fileNameAss -Pattern $find;
# recupero il valore della versione release/debug
$idxVers = $riga.ToString().IndexOf("AssemblyVersion(");
$currRelease = $riga.ToString().Substring($idxVers).Replace("AssemblyVersion(","").Replace(")]","").Replace("""","");
# calcolo nuova
$env:NEW_REL = $env:VERS_MAIN+"."+(get-date format yyMM)+"."+(get-date format ddHH)
echo "New vers: $env:NEW_REL"
# aggiorno file
$contenuto = Get-Content -path $fileNameAss -Raw
$newContenuto = $contenuto -replace $currRelease, $env:NEW_REL
$newContenuto | Set-Content -path $fileNameAss
# helper creazione hash files
.hashBuild: &hashBuild
- |
# hashBuild per elaborato
$Target = ".\$env:APP_NAME\Release\$env:APP_NAME.zip"
echo "Request hash for $Target"
$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
.nexusUpload: &nexusUpload
- |
Set-Alias mCurl C:\Windows\system32\curl.exe
$currentDate = get-date -format yyMM;
$currentTime = get-date -format ddHH;
$VersNumb = $env:NEW_REL
echo "Curr Version: $VersNumb"
if($CI_COMMIT_BRANCH -eq "master")
{
$version = "stable"
}
else
{
$version = "unstable"
}
$File2Send = Get-ChildItem("$env:PROJ_NAME\Release\*")
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/$CI_COMMIT_BRANCH/LAST/$FileName
mCurl -v -u GitLab:$NEXUS_PASSWD --upload-file $File https://nexus.steamware.net/repository/SWS/$env:NEXUS_PATH/$CI_COMMIT_BRANCH/ARCHIVE/$VersNumb/$FileName
}
#mCurl -v -u GitLab:$NEXUS_PASSWD --upload-file "$env:PROJ_NAME\Resources\manifest.xml" https://nexus.steamware.net/repository/SWS/$env:NEXUS_PATH/$CI_COMMIT_BRANCH/LAST/manifest.xml
#mCurl -v -u GitLab:$NEXUS_PASSWD --upload-file "$env:PROJ_NAME\Resources\ChangeLog.html" https://nexus.steamware.net/repository/SWS/$env:NEXUS_PATH/$CI_COMMIT_BRANCH/LAST/ChangeLog.html
stages:
- build
- deploy
- release
Zcode:build:
stage: build
tags:
- win
before_script:
- *nuget-fix
- '& "$env:NUGET_PATH" restore $env:APP_NAME.sln -Verbosity quiet'
- *version-fix
script:
- '& "$env:MSBUILD_PATH" $env:APP_NAME/$env:APP_NAME.csproj -target:Build /p:Configuration=Release /p:Platform="Any CPU" /p:OutputPath=bin/ /verbosity:minimal /m'
Zcode:IIS01:deploy:
stage: deploy
tags:
- win
except:
refs:
- main
- master
before_script:
- *nuget-fix
- '& "$env:NUGET_PATH" restore $env:APP_NAME.sln -Verbosity quiet'
- *version-fix
script:
- '& "$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=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ /verbosity:minimal $env:APP_NAME/$env:APP_NAME.csproj'
needs: ["Zcode:build"]
Zcode:IIS02:deploy:
stage: deploy
tags:
- win
only:
refs:
- main
- master
before_script:
- *nuget-fix
- '& "$env:NUGET_PATH" restore $env:APP_NAME.sln -Verbosity quiet'
- *version-fix
script:
- '& "$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=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ /verbosity:minimal $env:APP_NAME/$env:APP_NAME.csproj'
needs: ["Zcode:build"]
Zcode:IIS03:deploy:
stage: deploy
tags:
- win
only:
refs:
- main
- master
before_script:
- *nuget-fix
- '& "$env:NUGET_PATH" restore $env:APP_NAME.sln -Verbosity quiet'
- *version-fix
script:
- '& "$env:MSBUILD_PATH" /p:AspnetMergePath=$env:ASPNET_MERGE_PATH /p:DeployOnBuild=true /p:Targets=Publish /p:PublishProfile=IIS03.pubxml /p:RunCodeAnalysis=false /p:Configuration=Release /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ /verbosity:minimal $env:APP_NAME/$env:APP_NAME.csproj'
needs: ["Zcode:build"]
Zcode:OVH:release:
stage: release
tags:
- win
only:
refs:
- main
- master
before_script:
- *nuget-fix
- '& "$env:NUGET_PATH" restore $env:APP_NAME.sln -Verbosity quiet'
- *version-fix
script:
- '& "$env:MSBUILD_PATH" /p:AspnetMergePath=$env:ASPNET_MERGE_PATH /p:DeployOnBuild=true /p:Targets=Publish /p:PublishProfile=OVH-PROD.pubxml /p:RunCodeAnalysis=false /p:Configuration=Release /p:username=steamware /p:Password=viaD@nte16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ /verbosity:minimal $env:APP_NAME/$env:APP_NAME.csproj'
needs: ["Zcode:build"]
Zcode:File:release:
stage: release
tags:
- win
only:
refs:
- main
- master
before_script:
- *nuget-fix
- '& "$env:NUGET_PATH" restore $env:APP_NAME.sln -Verbosity quiet'
- *version-fix
script:
- '& "$env:MSBUILD_PATH" /p:AspnetMergePath=$env:ASPNET_MERGE_PATH /p:DeployOnBuild=true /p:Targets=Publish /p:PublishProfile=FileExport.pubxml /p:RunCodeAnalysis=false /p:Configuration=Release /p:username=jenkins /p:Password=viadante16 /p:AllowUntrustedCertificate=true /p:OutputPath=bin/ /verbosity:minimal $env:APP_NAME/$env:APP_NAME.csproj'
- *hashBuild
- *nexusUpload
needs: ["Zcode:build"]