From 2914ecde9730fa304469a3aa56bef01f62428016 Mon Sep 17 00:00:00 2001 From: Avasam Date: Sat, 13 Jul 2024 17:17:47 -0400 Subject: [PATCH] Pack dev versions --- .github/workflows/pack-randomizer.yaml | 16 +++++++++++++++- .../Entrance Randomizer/lib/constants.py | 4 +++- Dolphin scripts/pack-rando.ps1 | 12 +++++++++--- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pack-randomizer.yaml b/.github/workflows/pack-randomizer.yaml index db37c96..26190e7 100644 --- a/.github/workflows/pack-randomizer.yaml +++ b/.github/workflows/pack-randomizer.yaml @@ -30,6 +30,20 @@ jobs: - uses: actions/checkout@v4 - run: '& "Dolphin scripts/pack-rando.ps1"' shell: pwsh + # upload-artifact will double zip, so unpack first + # https://github.com/actions/upload-artifact/issues/39 + - name: Get pack filename + id: packname + run: | + echo "::set-output name=packname::$( + find -name 'Entrance Randomizer v*.zip' | sed 's/\.zip$//1' | sed 's/\.\/$//1' + )" + - name: Extract premade archive + run: | + 7z x \ + '${{ steps.packname.outputs.packname }}.zip' \ + -o'${{ steps.packname.outputs.packname }}' - uses: actions/upload-artifact@v4 with: - path: "Entrance Randomizer v*.zip" + name: ${{ steps.packname.outputs.packname }} + path: ${{ steps.packname.outputs.packname }}/* diff --git a/Dolphin scripts/Entrance Randomizer/lib/constants.py b/Dolphin scripts/Entrance Randomizer/lib/constants.py index b0613af..1ec3700 100644 --- a/Dolphin scripts/Entrance Randomizer/lib/constants.py +++ b/Dolphin scripts/Entrance Randomizer/lib/constants.py @@ -10,7 +10,7 @@ from dolphin import memory # pyright: ignore[reportMissingModuleSource] from lib.transition_infos import transition_infos -__version__ = "0.4.0" +__version = "0.4.0" """ Major: New major feature or functionality @@ -18,6 +18,8 @@ Patch: Does't affect seed (assuming same settings) """ +__dev_version = "local" +__version__ = f"{__version}-{__dev_version}" print(f"Python version: {sys.version}") print(f"Rando version: {__version__}") diff --git a/Dolphin scripts/pack-rando.ps1 b/Dolphin scripts/pack-rando.ps1 index 3d5c3a5..659d8e5 100644 --- a/Dolphin scripts/pack-rando.ps1 +++ b/Dolphin scripts/pack-rando.ps1 @@ -1,9 +1,15 @@ $ScriptsFolder = "$PSScriptRoot\Scripts" $RandoFolderName = 'Entrance Randomizer' -$VersionLine = Get-Content "$PSScriptRoot\$RandoFolderName/lib/constants.py" | Select-String -Pattern '^__version__\s*=\s*".*"' -$RandoVersion = $VersionLine -replace '^\s*__version__\s*=\s*"', '' -replace '".*$', '' +$VersionFilePath = "$ScriptsFolder\$RandoFolderName/lib/constants.py" Remove-Item -Path $ScriptsFolder -Recurse -ErrorAction SilentlyContinue Copy-Item -Path "$PSScriptRoot\$RandoFolderName" -Destination "$ScriptsFolder\$RandoFolderName" -Recurse Copy-Item -Path "$PSScriptRoot\..\Various technical notes\transition_infos.json" -Destination "$ScriptsFolder\$RandoFolderName\lib" -Compress-Archive -Path $ScriptsFolder -DestinationPath "$RandoFolderName v$RandoVersion.zip" -Force + +$VersionFileContent = Get-Content $VersionFilePath +$VersionLine = $VersionFileContent | Select-String -Pattern '^__version\s*=\s*".*"' +$RandoVersion = $VersionLine -replace '^\s*__version\s*=\s*"', '' -replace '".*$', '' +$DevVersion = git rev-parse --short HEAD +$VersionFileContent -replace '^\s*__dev_version.*', "__dev_version = `"$DevVersion`"" | Set-Content $VersionFilePath + +Compress-Archive -Path $ScriptsFolder -DestinationPath "$RandoFolderName v$RandoVersion-$DevVersion.zip" -Force Remove-Item -Path $ScriptsFolder -Recurse