175 lines
5.6 KiB
YAML
175 lines
5.6 KiB
YAML
variables:
|
|
APP_NAME: 'IOB-WIN-PSER'
|
|
CONFIG: ''
|
|
V_MAJ: '2'
|
|
V_MIN: '9'
|
|
V_REL: '0'
|
|
V_BLD: '0'
|
|
NEW_REL: ''
|
|
NEW_NUM: ''
|
|
VERS_FILE: 'file_version_info_orig.txt'
|
|
OUTPUT_DIR: ''
|
|
NEXUS_PATH: 'MAPO/IOB-WIN-NEXT'
|
|
URL_VERSIONS_LOG: "https://liman.egalware.com/ELM.API/api/release/save"
|
|
CRITICAL_STRING: "#critical#"
|
|
|
|
|
|
# helper x fix version number
|
|
.version-fix: &version-fix
|
|
- |
|
|
$env:V_REL = (get-date -format yyMM)
|
|
$env:V_BLD = (get-date -format ddHH)
|
|
$env:NEW_REL = "($env:V_MAJ, $env:V_MIN, $env:V_REL, $env:V_BLD)"
|
|
$env:NEW_NUM = "$env:V_MAJ.$env:V_MIN.$env:V_REL.$env:V_BLD"
|
|
Write-Output "Get-Content -path '$env:VERS_FILE' -Raw"
|
|
$contenuto = Get-Content -path "$env:VERS_FILE" -Raw
|
|
$newContenuto = $contenuto -replace '(0, 0, 0, 0)', $env:NEW_REL
|
|
$newContenuto = $newContenuto -replace '0.0.0.0', $env:NEW_NUM
|
|
$newContenuto | Set-Content -Path "$env:VERS_FILE"
|
|
# display versioni generate
|
|
$resoconto = "Effettuato fix file VersGen | REL: " + $env:NEW_REL + " | NUM: " + $env:NEW_NUM;
|
|
Write-Output $resoconto;
|
|
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 "dist"
|
|
$Source = "$env:APP_NAME.exe"
|
|
7zip a -tzip $Target $Source
|
|
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_NUM
|
|
echo "Curr Version: $VersNumb"
|
|
if($CI_COMMIT_BRANCH -eq "main")
|
|
{
|
|
$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
|
|
}
|
|
|
|
# helper invio notifica a log versioni online (LiMan)
|
|
.SendToVersionsLog: &SendToVersionsLog
|
|
- |
|
|
echo "----------------------------------------------"
|
|
echo " Invio versione a Liman x log online"
|
|
echo "----------------------------------------------"
|
|
$tags = ""
|
|
# se critico scrive tag
|
|
if ( $CI_COMMIT_MESSAGE | Select-String -Pattern $env:CRITICAL_STRING) {
|
|
$tags = "CRITICAL"
|
|
}
|
|
$date = (Get-Date).toString("yyyy-MM-ddTHH:mm:ss.fffZ")
|
|
$body =
|
|
@{
|
|
codInst = "EgalWare"
|
|
codApp = $env:APP_NAME
|
|
uplAppId = "UpdateManager"
|
|
masterKey = $LiMan_Key
|
|
tipo = "WinApp"
|
|
versNum = $env:NEW_NUM
|
|
versText = $env:NEW_NUM
|
|
releaseDate = $date
|
|
relTags = $tags
|
|
}
|
|
$jsonBody = ConvertTo-Json -InputObject $body
|
|
echo $jsonBody
|
|
Invoke-WebRequest -Method Post -URI $env:URL_VERSIONS_LOG -ContentType "application/json" -Body $jsonBody -UseBasicParsing
|
|
|
|
|
|
stages:
|
|
- build
|
|
- release
|
|
|
|
# --------------------------------
|
|
# BUILD
|
|
# --------------------------------
|
|
IOB-WIN-PSER:build:
|
|
stage: build
|
|
tags:
|
|
- win
|
|
before_script:
|
|
- 'cd $env:APP_NAME'
|
|
- *version-fix
|
|
- '& .\venv\Scripts\Activate.ps1'
|
|
- python --version
|
|
script:
|
|
- python -m PyInstaller --onefile --icon SteamWare.ico "$env:APP_NAME.py"
|
|
- deactivate
|
|
|
|
# --------------------------------
|
|
# RELEASE
|
|
# --------------------------------
|
|
IOB-WIN-PSER:release:
|
|
stage: release
|
|
needs: ["IOB-WIN-PSER:build"]
|
|
tags:
|
|
- win
|
|
variables:
|
|
APP_NAME: IOB-WIN-PSER
|
|
NEXUS_PATH: MAPO/IOB-WIN-PSER
|
|
rules:
|
|
- if: $CI_COMMIT_BRANCH == 'main'
|
|
# changes:
|
|
# - $env:APP_NAME/*
|
|
when: always
|
|
before_script:
|
|
- 'cd $env:APP_NAME'
|
|
- *version-fix
|
|
- *cleanup-zip
|
|
- '& .\venv\Scripts\Activate.ps1'
|
|
- python --version
|
|
script:
|
|
- python -m PyInstaller --onefile --icon SteamWare.ico "$env:APP_NAME.py"
|
|
- python .\venv\Scripts\pyi-set_version.exe "$env:VERS_FILE" "dist\$env:APP_NAME.exe"
|
|
- deactivate
|
|
- *zipper
|
|
- *hashBuild
|
|
- *nexusUpload
|
|
- *SendToVersionsLog
|