variables: VERS_MAIN: '0.1' NEW_REL: '' APP_NAME: '' APP_CONF: 'Release' SOL_NAME: '' INST_NAME: '' # Step esecuzione script powershell x code obfuscation (tool install + esecuzione) .obfuscate: &obfuscate - | obfuscate.ps1 # 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 x fix version number .version-fix: &version-fix - | $env:VERS_MAIN = Get-Content "MajMin.vers" $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) # fix messaggio log in manifest... # preparo file e contenuto da log messages $FileCLogIn="Resources\ChangeLog-original.html" $FileCLogOut="Resources\ChangeLog.html" $LastMessages = git log -3 --pretty=%B # replace x ChangeLog $clogData = Get-Content $FileCLogIn $clogData = $clogData -replace "{{LAST-CHANGES}}", $LastMessages Set-Content -Path $FileCLogOut -Value $clogData # 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 creazione hash files x Nexus .hashBuild: &hashBuild - | $Target = "$env:INST_NAME\bin\x64\" + $env:APP_CONF + "\en-US\" + $env:INST_NAME + ".msi" $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 if($CI_COMMIT_BRANCH -eq "main") { $version = "stable" $fileVers = $env:NUM_REL } else { $version = "unstable" $fileVers = $env:NUM_DEB } echo "Curr Version: $fileVers | $version" $File2Send = Get-ChildItem("$env:INST_NAME\bin\x64\" + $env:APP_CONF + "\en-US\*") 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:INST_NAME/$version/LAST/$FileName mCurl -v -u GitLab:$NEXUS_PASSWD --upload-file $File https://nexus.steamware.net/repository/SWS/$env:INST_NAME/$version/ARCHIVE/$fileVers/$FileName echo "mCurl -v -u GitLab:$NEXUS_PASSWD --upload-file $File https://nexus.steamware.net/repository/SWS/$env:INST_NAME/$version/LAST/$FileName" } mCurl -v -u GitLab:$NEXUS_PASSWD --upload-file "Resources\manifest.xml" https://nexus.steamware.net/repository/SWS/$env:INST_NAME/$version/LAST/manifest.xml mCurl -v -u GitLab:$NEXUS_PASSWD --upload-file "Resources\ChangeLog.html" https://nexus.steamware.net/repository/SWS/$env:INST_NAME/$version/LAST/ChangeLog.html # helper creazione files zip x app console .artifactZipper: &artifactZipper - | $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\bin\$env:APP_CONF\net6.0\publish\win-x64\*" 7zip a -tzip $Target $Source -xr!DATA echo "called ZIP $Source --> $Target" # helper copia pubblicati in dir x upload .artifactMover: &artifactMover - | $Target = "$env:APP_NAME\Releases\" + $CI_COMMIT_BRANCH + "\" $Source = "$env:APP_NAME\bin\publish\net6.0\" ROBOCOPY $Source $Target /MIR echo "called ROBOCOPY $Source --> $Target" stages: - build - deploy # - pack #--------- BUILD --------- # Runner:build: stage: build tags: - win variables: APP_NAME: Maat.Runner SOL_NAME: Maat.Runner before_script: - *nuget-fix - dotnet restore $env:SOL_NAME.sln - *version-fix script: - dotnet build $env:APP_NAME/$env:APP_NAME.csproj #--------- Deploy --------- # Runner:deploy-dev: stage: deploy tags: - win variables: APP_NAME: Maat.Runner SOL_NAME: Maat.Runner INST_NAME: Maat.Installer APP_CONF: Debug only: - develop needs: ["Runner:build"] before_script: - *nuget-fix - dotnet restore $env:SOL_NAME.sln - *version-fix script: # pubblicazione come singleApp - dotnet publish -p:PublishProfile=SingleAppDebug.pubxml -p:RunCodeAnalysis=false -p:Configuration=$env:APP_CONF $env:APP_NAME/$env:APP_NAME.csproj # creazione installer WIX - dotnet build $env:INST_NAME/$env:INST_NAME.wixproj -p:Configuration=$env:APP_CONF -p:Platform=x64 #- *artifactZipper - *hashBuild - *nexusUpload Runner:deploy: stage: deploy tags: - win variables: APP_NAME: Maat.Runner SOL_NAME: Maat.Runner INST_NAME: Maat.Installer APP_CONF: Release only: - main needs: ["Runner:build"] before_script: - *nuget-fix - dotnet restore $env:SOL_NAME.sln - *version-fix script: # pubblicazione come singleApp - dotnet publish -p:PublishProfile=SingleApp.pubxml -p:RunCodeAnalysis=false -p:Configuration=$env:APP_CONF $env:APP_NAME/$env:APP_NAME.csproj # creazione installer WIX - dotnet build $env:INST_NAME/$env:INST_NAME.wixproj -p:Configuration=$env:APP_CONF -p:Platform=x64 #- *artifactZipper - *hashBuild - *nexusUpload # #--------- PACK --------- # # ADAPTER:packDebug: # stage: pack # tags: # - win # only: # - develop # variables: # APP_NAME: MP.MONO.ADAPTER.OPC # APP_CONF: Debug # needs: ["ADAPTER:build"] # script: # - dotnet publish -p:PublishProfile=SingleAppDebug.pubxml -p:RunCodeAnalysis=false -p:Configuration=$env:APP_CONF $env:APP_NAME/$env:APP_NAME.csproj # - *artifactZipper # - *hashBuild # - *nexusUpload # ADAPTER:packRelease: # stage: pack # tags: # - win # only: # - main # variables: # APP_NAME: MP.MONO.ADAPTER.OPC # APP_CONF: Release # needs: ["ADAPTER:build"] # script: # - dotnet publish -p:PublishProfile=SingleApp.pubxml -p:RunCodeAnalysis=false -p:Configuration=$env:APP_CONF $env:APP_NAME/$env:APP_NAME.csproj # - *artifactZipper # - *hashBuild # - *nexusUpload