build dolphin INI archive in addition to the GCM archive

This commit is contained in:
Matteias Collet 2020-03-09 15:35:43 +01:00
parent 342598f5c9
commit 5dad80d0d0
4 changed files with 47 additions and 12 deletions

View file

@ -11,10 +11,10 @@ variables:
steps: steps:
- task: PowerShell@2 - task: PowerShell@2
displayName: 'Update GCM Archive' displayName: 'Update archives'
inputs: inputs:
targetType: 'filePath' targetType: 'filePath'
filePath: './update_gcm_archive.azure.ps1' filePath: './update_archives.azure.ps1'
failOnStderr: true failOnStderr: true
workingDirectory: '.' workingDirectory: '.'
- task: PowerShell@2 - task: PowerShell@2
@ -26,7 +26,8 @@ steps:
git config --local user.name "BotPatty"; git config --local user.name "BotPatty";
git config --local user.email "ci@zint.ch"; git config --local user.email "ci@zint.ch";
git add ./files/GCMCodes.zip; git add ./files/GCMCodes.zip;
git commit -m "Update GCM Archive [skip ci]";' git add ./files/DolphinCodes.zip;
git commit -m "update archives [skip ci]";'
failOnStderr: true failOnStderr: true
workingDirectory: '.' workingDirectory: '.'
- task: PowerShell@2 - task: PowerShell@2

BIN
files/DolphinCodes.zip Normal file

Binary file not shown.

Binary file not shown.

View file

@ -1,7 +1,7 @@
$ErrorActionPreference = "Stop"; $ErrorActionPreference = "Stop";
# Retrieve commit hash from latest archive update # Retrieve commit hash from latest archive update
Write-Host -ForegroundColor Blue "Retrieving last update commit.." Write-Host -ForegroundColor Blue "Retrieving last update commit..";
$LastGCMUpdate = (git log -1 --pretty=format:"%H" ./files/GCMCodes.zip); $LastGCMUpdate = (git log -1 --pretty=format:"%H" ./files/GCMCodes.zip);
if ([string]::IsNullOrWhiteSpace($LastGCMUpdate)) { if ([string]::IsNullOrWhiteSpace($LastGCMUpdate)) {
@ -18,7 +18,7 @@ $CodeUpdates = (git diff --name-only $LastGCMUpdate HEAD -- './codes/*.xml')
if ([string]::IsNullOrWhiteSpace($CodeUpdates)) { if ([string]::IsNullOrWhiteSpace($CodeUpdates)) {
Write-Host -ForegroundColor Green "No code changes detected"; Write-Host -ForegroundColor Green "No code changes detected";
exit 0; exit 0;
} }
Write-Host "Changed files since last archive Update:" $CodeUpdates; Write-Host "Changed files since last archive Update:" $CodeUpdates;
@ -27,9 +27,9 @@ Write-Host "Changed files since last archive Update:" $CodeUpdates;
Write-Host -ForegroundColor Blue "Packing new archive..."; Write-Host -ForegroundColor Blue "Packing new archive...";
# Setup workspace # Setup workspace
New-Item -ItemType directory -Path "./.gcmbuild"; New-Item -ItemType directory -Path "./.build";
Copy-Item "./codes/*.xml" "./.gcmbuild/"; Copy-Item "./codes/*.xml" "./.build/";
Set-Location "./.gcmbuild"; Set-Location "./.build";
# Helper function to convert the XML files to the GCM txt format # Helper function to convert the XML files to the GCM txt format
function XmlToGcm($source, $destination, $versionname) { function XmlToGcm($source, $destination, $versionname) {
@ -47,18 +47,52 @@ function XmlToGcm($source, $destination, $versionname) {
}; };
}; };
# Convert files # Helper function to convert the XML files to the Dolphin INI format
Write-Host "Converting XML files.."; function XmlToIni($source, $destination, $versionname) {
[xml]$xml = Get-Content $source;
Add-Content $destination "Paste the following on top of your games .ini file:"
Add-Content $destination "[Gecko]" -NoNewline
foreach ($code in $xml.codes.code) {
Add-Content $destination "";
Add-Content $destination "`$$($code.title."#text") ($($code.date)) [$($code.author)]";
$codeSource = $code.source -replace " +$", "" -replace "^? [^a-zA-Z0-9]", "";
Add-Content $destination $codeSource.Trim() -NoNewline;
};
}
# Convert files to GCM format
Write-Host "Converting XML files to GCM format..";
XmlToGcm "GMSE01.xml" "GMSE01.txt" "GMSE01"; XmlToGcm "GMSE01.xml" "GMSE01.txt" "GMSE01";
XmlToGcm "GMSP01.xml" "GMSP01.txt" "GMSP01"; XmlToGcm "GMSP01.xml" "GMSP01.txt" "GMSP01";
XmlToGcm "GMSJ01.xml" "GMSJ01.txt" "GMSJ01"; XmlToGcm "GMSJ01.xml" "GMSJ01.txt" "GMSJ01";
XmlToGcm "GMSJ0A.xml" "GMSJ01 (A).txt" "GMSJ01"; XmlToGcm "GMSJ0A.xml" "GMSJ01 (A).txt" "GMSJ01";
# Replace zip file # Replace zip file
Write-Host "Compressing and replacing archive.."; Write-Host "Compressing and replacing GCM archive..";
Compress-Archive "./*.txt" "../files/GCMCodes.zip" -Force; Compress-Archive "./*.txt" "../files/GCMCodes.zip" -Force;
Write-Host -ForegroundColor Green "GCM Archive rebuilt";
# Convert files to Dolphin format
Remove-Item *.txt;
Write-Host "Converting XML files to Dolphin INI format..";
XmlToIni "GMSE01.xml" "GMSE01.txt" "GMSE01";
XmlToIni "GMSP01.xml" "GMSP01.txt" "GMSP01";
XmlToIni "GMSJ01.xml" "GMSJ01.txt" "GMSJ01";
XmlToIni "GMSJ0A.xml" "GMSJ01 (A).txt" "GMSJ01";
Write-Host "Compressing and replacing Dolphin archive..";
Compress-Archive "./*.txt" "../files/DolphinCodes.zip" -Force;
Write-Host -ForegroundColor Green "Dolphin Archive rebuilt";
# Cleanup
Write-Host "Cleaning up..";
Set-Location ..; Set-Location ..;
Remove-Item "./.gcmbuild" -Recurse; Remove-Item "./.build" -Recurse;
Write-Host -ForegroundColor Green "Done"; Write-Host -ForegroundColor Green "Done";
# Set Azure variable to commit and push changes # Set Azure variable to commit and push changes