Files
CMS-MTConn/.gitlab-ci.yml
Samuele Locatelli 133041d030 bozza yaml iniziale
2022-08-03 16:38:57 +02:00

244 lines
8.7 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 (Any CPU)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MSBuild.exe'
SOL_NAME: 'SCMA'
APP_NAME: 'SCMA'
NUM_REL: '0.1.2.3'
NUM_DEB: '0.1.2-beta.3'
CONFIG: ''
VERS_MAIN: '2.2'
NEW_REL: ''
OUTPUT_DIR: ''
NEXUS_PATH: 'SCM/SCMA'
# 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 "`"$NEXUS_PASSWD`""
} else {
C:\Tools\nuget.exe sources Update -Name "`"Steamware Nexus`"" -Source https://nexus.steamware.net/repository/nuget-group -username "`"nugetUser`"" -password "`"$NEXUS_PASSWD`""
}
echo $hasSource
# 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 @ 2006-" + (get-date -format yyyy)
$contenuto = Get-Content -path 'VersGen\VersGen.cs' -Raw
$newContenuto = $contenuto -replace '1.0.0.0', $env:NEW_REL
$newContenuto = $newContenuto -replace 'EgalWare © 2006', $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"
# helper pulizia files zip
.cleanup-zip: &cleanup-zip
- |
$env:OUTPUT_DIR = "Releases\" + $CI_COMMIT_BRANCH + "\*"
if ((Test-Path $env:OUTPUT_DIR))
{
Remove-Item $env:OUTPUT_DIR -Force -Recurse -ErrorAction Ignore
}
echo "Clening ZIP dir: $env:OUTPUT_DIR"
# 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 = "Releases\" + $CI_COMMIT_BRANCH + "\" + $env:APP_NAME + ".zip"
cd "$env:APP_NAME\bin\"
$Source = "*"
7zip a -tzip $Target $Source -xr!DATA
echo "called ZIP $Source --> $Target"
# helper creazione hash files
.hashBuild: &hashBuild
- |
$Target = "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"
.nexusUpload: &nexusUpload
- |
Set-Alias mCurl C:\Windows\system32\curl.exe
$VersNumb = $env:NEW_REL
echo "Curr Version: $VersNumb"
if($CI_COMMIT_BRANCH -eq "master")
{
$version = "stable"
}
else
{
$version = "unstable"
}
$File2Send = Get-ChildItem("Releases\" + $CI_COMMIT_BRANCH + "\" + $env:APP_NAME + ".*")
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 "Upload area utility for Releases\$CI_COMMIT_BRANCH\$env:APP_NAME.*"
$FileUtility = Get-ChildItem("Releases\$CI_COMMIT_BRANCH\$env:APP_NAME.*")
ForEach ($File in $FileUtility) {
$FileName = Split-Path $File -leaf
mCurl -v -u GitLab:$NEXUS_PASSWD --upload-file $File https://nexus.steamware.net/repository/utility/MAPO/$env:APP_NAME/$version/$FileName
}
stages:
- build
- release
# --------------------------------
# BUILD
# --------------------------------
SCMA:build:
stage: build
tags:
- win
variables:
APP_NAME: SCMA
only:
refs:
- develop
- main
- master
before_script:
- *nuget-fix
- '& "$env:NUGET_PATH" restore "MTC_Adapter\$env:SOL_NAME.sln" -verbosity quiet'
- *version-fix
script:
- '& "$env:MSBUILD_PATH" "MTC_Adapter\$env:APP_NAME\$env:APP_NAME.csproj" -target:Build /p:Configuration=Release /p:Platform="Any CPU" /p:DefineConstants=\"FS30D=1,SIEMENS=1\" /p:OutputPath=bin/ /verbosity:minimal /m'
MTC-ADB:build:
stage: build
tags:
- win
variables:
APP_NAME: MTC-ADB
only:
refs:
- develop
- main
- master
before_script:
- *nuget-fix
- '& "$env:NUGET_PATH" restore "MTC_Adapter\$env:SOL_NAME.sln" -verbosity quiet'
- *version-fix
script:
- '& "$env:MSBUILD_PATH" "MTC_Adapter\$env:APP_NAME\$env:APP_NAME.csproj" -target:Build /p:Configuration=Release /p:Platform="Any CPU" /p:OutputPath=bin/ /verbosity:minimal /m'
# --------------------------------
# RELEASE
# --------------------------------
SCMA:release:
stage: release
needs: ["SCMA:build"]
tags:
- win
variables:
APP_NAME: SCMA
NEXUS_PATH: MAPO/SCMA
only:
refs:
- main
- master
before_script:
- *nuget-fix
- '& "$env:NUGET_PATH" restore "MTC_Adapter\$env:SOL_NAME.sln" -verbosity quiet'
- *version-fix
- *cleanup-zip
script:
- '& "$env:MSBUILD_PATH" "MTC_Adapter\$env:APP_NAME\$env:APP_NAME.csproj" -target:Build /p:Configuration=Release /p:DebugSymbols=false /p:DebugType=None /p:DefineConstants=\"FS30D=1,SIEMENS=1\" /p:Platform="Any CPU" /p:OutputPath=bin/ /verbosity:minimal /m'
- *zipper
- *hashBuild
- *nexusUpload
MTC-ADB:release:
stage: release
needs: ["MTC-ADB:build"]
tags:
- win
variables:
APP_NAME: MTC-ADB
NEXUS_PATH: MAPO/MTC-ADB
only:
refs:
- main
- master
before_script:
- *nuget-fix
- '& "$env:NUGET_PATH" restore "MTC_Adapter\$env:SOL_NAME.sln" -verbosity quiet'
- *version-fix
- *cleanup-zip
script:
- '& "$env:MSBUILD_PATH" "MTC_Adapter\$env:APP_NAME\$env:APP_NAME.csproj" -target:Build /p:Configuration=Release /p:DebugSymbols=false /p:DebugType=None /p:Platform="Any CPU" /p:OutputPath=bin/ /verbosity:minimal /m'
- *zipper
- *hashBuild
- *nexusUpload
EgwProxy.Icoel:build:release:
stage: release
needs: ["EgwProxy.Icoel:build"]
tags:
- win
variables:
CONFIG: Release
APP_NAME: EgwProxy.Icoel
only:
refs:
- SDK/Icoel
before_script:
- *nuget-fix
- '& "$env:NUGET_PATH" restore "$env:APP_NAME.sln" -verbosity quiet'
- *version-fix
- *nuspec-fix
script:
- '& "$env:MSBUILD_PATH" "$env:APP_NAME\$env:APP_NAME.csproj" -target:Build /p:Configuration=$env:CONFIG /p:Platform="Any CPU" /p:OutputPath=bin/$env:CONFIG /verbosity:minimal /m'
- '& Remove-Item *.nupkg'
- '& $env:NUGET_PATH pack "$env:APP_NAME.Release.nuspec"'
# - '& "$env:NUGET_PATH" pack "$env:APP_NAME\$env:APP_NAME.csproj" -properties Configuration=$env:CONFIG -Version $env:NUM_REL'
- '& "$env:NUGET_PATH" setapikey fe387daa-d07c-3207-877e-96c8be1be91b -source http://nexus.steamware.net/repository/nuget-hosted'
- '& "$env:NUGET_PATH" push *$env:NUM_REL.nupkg -Source http://nexus.steamware.net/repository/nuget-hosted'