diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 19e4f3db..1156a995 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,6 +9,39 @@ variables: NEXUS_PATH: 'MP-STATS' APP_NAME: 'MP.Stats' +# # helper x fix version number +# .version-fix: &version-fix +# - | +# $env:NEW_REL = $env:VERS_MAIN+"."+(get-date –format yyMM)+"."+$CI_PIPELINE_IID +# echo "Set vers: $env:NEW_REL" +# $contenuto = Get-Content -path 'VersGen\GPW.cs' -Raw +# $newContenuto = $contenuto -replace '0.0.0.0', $env:NEW_REL +# $newContenuto | Set-Content -Path 'VersGen\GPW.cs' + +# helper pulizia files zip +.cleanup-zip: &cleanup-zip + - | + $env:OUTPUT_DIR = $env:APP_NAME + "\bin\Release\*.zip" + 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 = $env:APP_NAME + "\bin\Release\" + $env:APP_NAME + ".zip" + $Source = $env:APP_NAME + "\bin\Release\*" + 7zip a -tzip $Target $Source + echo "called ZIP $Source --> $Target" + + # helper x fix pacchetti nuget da repo locale nexus.steamware.net .nuget-fix: &nuget-fix - | @@ -23,7 +56,7 @@ variables: # helper creazione hash files .hashBuild: &hashBuild - | - $Target = $env:APP_NAME + "\bin\publish\" + $env:APP_NAME + ".zip" + $Target = $env:APP_NAME + "\bin\Release\" + $env:APP_NAME + ".zip" $MD5 = Get-FileHash $Target -Algorithm MD5 $SHA1 = Get-FileHash $Target -Algorithm SHA1 New-Item $Target".md5" @@ -33,8 +66,43 @@ variables: echo "Created HASH files for $Target" +# helper creazione hash files x IIS +.hashBuildIIS: &hashBuildIIS + - | + $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 .nexusUpload: &nexusUpload + - | + Set-Alias mCurl C:\Windows\system32\curl.exe + $currentDate = get-date -format yyMM; + $currentTime = get-date -format ddHH; + $VersNumb = Get-Content "Resources\VersNum.txt" + echo "Curr Version: $VersNumb" + if($CI_COMMIT_BRANCH -eq "master") + { + $version = "stable" + } + else + { + $version = "unstable" + } + $File2Send = Get-ChildItem($env:APP_NAME + "\bin\Release\*.zip*") + ForEach ($File in $File2Send) { + $FileName = Split-Path $File -leaf + mCurl -v -u GitLab:$NEXUS_PASSWD --upload-file $File http://nexus.steamware.net/repository/SWS/$env:NEXUS_PATH/$version/SLS/$FileName + } + +# helper x send su NEXUS x pack IIS +.nexusUploadIIS: &nexusUploadIIS - | Set-Alias mCurl C:\Windows\system32\curl.exe $currentDate = get-date -format yyMM; @@ -123,11 +191,26 @@ staging: # - *cleanup-zip script: - dotnet publish -p:PublishProfile=IISProfile.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release MP.Stats/MP.Stats.csproj - # da fare qui il deploy su nexus... + # deploy su nexus... # - *zipper - *hashBuild - *nexusUpload +staging: + stage: installerIIS + only: + - develop + - master + needs: ["build"] + before_script: + # - *nuget-fix + # - dotnet restore + script: + - dotnet publish -p:PublishProfile=IISProfile.pubxml -p:RunCodeAnalysis=false -p:Configuration=Release MP.Stats/MP.Stats.csproj + # qui il deploy su nexus... + - *hashBuildIIS + - *nexusUploadIIS + release: stage: release only: