Skip to content

Commit

Permalink
Implement workflow generating latest tile images
Browse files Browse the repository at this point in the history
There appears to be a bug with making directories, solved using
os.makedirs before calling the problematic method
  • Loading branch information
TWCCarlson committed Jul 27, 2024
1 parent 15aa672 commit 161e0e7
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 4 deletions.
88 changes: 88 additions & 0 deletions .github/workflows/buildNewestWikiMaps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Build Latest MapIDs

on: [workflow_dispatch]

jobs:
fetch-cache:
name: Build Latest Wiki Maps
runs-on: ubuntu-22.04

steps:
- name: 1. Install Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

- name: 2. Checkout
uses: actions/checkout@v4

- name: 3. Load Vips Binaries
run: |
sudo apt-get -y update
sudo apt-get -y install libvips-dev --no-install-recommends
- name: 4. Install Requirements
run: |
pip install -r requirements.txt
pip show pyvips
- name: 5. Download Latest Cache
run: |
python scripts/buildWikiMaps.py getCache
CACHE_VER=$(cat lastVersion.txt)
echo "CACHE_VER=$CACHE_VER" >> $GITHUB_ENV
- name: 6. Checkout RuneLite
run: |
git clone https://github.com/runelite/runelite.git RuneLite
- name: 7. Set up JDK 11
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11

- name: 8. Build RuneLite
run: |
cd RuneLite
mvn install -q -f pom.xml -DskipTests
- name: 9. Build MapExport
run: |
mvn -q clean package
- name: 10. Run MapExport
working-directory: ./osrs-wiki-maps
run: |
java -jar target/osrs-wiki-maps-1.10.26-shaded.jar $CACHE_VER
- name: 11. Generate Base Tiles
run: |
python scripts/buildWikiMaps.py createBaseTiles $CACHE_VER
- name: 12. Build All MapID Tiles
run: |
python scripts/buildWikiMaps.py buildAllMapIDs $CACHE_VER
- name: 13. Timestamp Release
id: tag
run: |
echo "::set-output name=release_tag::WikiMapGen_$(date +"%Y.%m.%d_%H-%M")"
echo "::set-output name=release_count::${{github.run_number}}"
- name: 14. Package
run: |
zip -r -q rendered.zip osrs-wiki-maps/out/mapgen/versions/${{env.CACHE_VER}}/tiles/rendered
- name: 15. Package and Release
uses: softprops/action-gh-release@v2
with:
name: ${{env.CACHE_VER}}
tag_name: ${{steps.tag.outputs.release_tag}}
body: |
Release No. ${{steps.tag.outputs.release_count}}
Using openRS2 Cache ${{env.CACHE_VER}}
token: ${{secrets.GITHUB_TOKEN}}
files: |
rendered.zip
make_latest: true
12 changes: 9 additions & 3 deletions scripts/buildWikiMaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@

BASE_DIRECTORY = "osrs-wiki-maps/out/mapgen/versions"

def getCache(version=None):
def getCache(reqVersion=None):
import cache
# Fetch the latest, or the version supplied as an argument, game cache
cache.download(f"./osrs-wiki-maps/out/mapgen/versions", version)
foundVersion = cache.download(f"./osrs-wiki-maps/out/mapgen/versions",
reqVersion)
with open("lastVersion.txt", 'w') as out:
out.write(foundVersion)

def createBaseTiles(version):
# Pyvips import is OS-dependent, use dispatcher file
Expand Down Expand Up @@ -40,7 +43,10 @@ def createBaseTiles(version):

# Load the image and slice
planeImage = pv.Image.new_from_file(planeImagePath)
planeImage.dzsave(os.path.join(dzSaveOutPath, f"plane_{planeNum}/2"),
resultDir = os.path.join(dzSaveOutPath, f"plane_{planeNum}/2")
if not os.path.exists(resultDir):
os.makedirs(resultDir)
planeImage.dzsave(resultDir,
tile_size= 256,
suffix= '.png[Q=100]',
depth= 'one',
Expand Down
10 changes: 9 additions & 1 deletion scripts/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,17 @@


def make_output_folder(date_str: str, sub_ver: int, working_dir: str) -> str:
# Determine the name of the output folder
version_count = 0
letter = "a"
out_folder = os.path.join(working_dir, f"{date_str}_{sub_ver}_{letter}")

# In a fresh install the out paths may not exist
out_dir = os.path.dirname(out_folder)
if not os.path.exists(out_dir):
os.makedirs(out_dir)

# If the output folder already exists, increment the letter version
while os.path.exists(out_folder):
version_count += 1
letter = ascii_lowercase[version_count]
Expand Down Expand Up @@ -159,7 +167,7 @@ def download(working_dir, version=None):
download_xteas(cache_id, out_folder)
download_cache(cache_id, out_folder)

return out_folder
return os.path.basename(out_folder)

if __name__ == "__main__":
download("osrs-wiki-maps/out/mapgen/versions", "2024-05-29_0")

0 comments on commit 161e0e7

Please sign in to comment.