From 510dd50daef64f9e0a694e5182bcaf5c7a97e038 Mon Sep 17 00:00:00 2001 From: Avasam Date: Sat, 13 Jul 2024 18:00:50 -0400 Subject: [PATCH] Pack and upload dev versions (#69) --- .github/workflows/pack-randomizer.yaml | 16 +++++++++++++++- .../Entrance Randomizer/lib/constants.py | 4 +++- Dolphin scripts/README.md | 8 +++++--- Dolphin scripts/pack-rando.ps1 | 12 +++++++++--- 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pack-randomizer.yaml b/.github/workflows/pack-randomizer.yaml index db37c96..2bed7d1 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 "packname=$( + find -name 'Entrance Randomizer v*.zip' | sed 's/\.zip$//1' | sed 's/^\.\///1' + )" >> $GITHUB_OUTPUT + - 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/README.md b/Dolphin scripts/README.md index 0256513..915a688 100644 --- a/Dolphin scripts/README.md +++ b/Dolphin scripts/README.md @@ -33,7 +33,10 @@ Shaman Shop: 1. Use this fork of Dolphin . 2. Turn on "Scripting" logs and set Verbosity to "Error" or any option below (not "Notice"). -3. Download the zip file from Discord or zip it yourself using `pack-rando.ps1`. +3. Download the randomizer zip file, either: + - from Discord; + - zip it yourself using `pack-rando.ps1`; + - download an unreleased [development build](https://github.com/Avasam/ptle-tools/actions/workflows/pack-randomizer.yaml?query=branch%3Amain+is%3Asuccess) (requires a GitHub account); 4. Open this zip file and drop "Scripts" at the root of your Dolphin installation (the location and names are important!). 5. Configurations are found in `Scripts/Entrance Randomizer/CONFIGS.py`. 6. In Dolphin, under "Scripts", click "Add new Scripts" and select `Scripts/Entrance Randomizer/__main__.py`. @@ -57,12 +60,11 @@ In order to display the generated map take these steps: - Some seeds will result in impossible to complete configurations, because you might need some items to progress that you don't have yet. - When using `LINKED_TRANSITIONS = False` the generated `.graphml` map will become very hard to read, given the extreme amount of connections that will be drawn. - In rare occasions, a transition might send you to the game-intended level instead of the level decided by the randomizer (this is an issue with the script patching the destination). -- In very rare occasions, a transition might not make you enter a level from the correct entrance, but make you enter from the default entrance instead +- In rare occasions, a transition might not make you enter a level from the correct entrance, but make you enter from the default entrance instead - The odds of this happening increase dramatically if at any point in the run Harry died or a save file was loaded. - Some linked transitions are not spawning at the right entrance and use the default entrance instead. Known cases: - Jungle Canyon from Punchau Shrine - Bittenbinder's Camp from Mysterious Temple -- With `LINKED_TRANSITIONS = True`, one-way transitions are not randomized at all. ### Developing 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