From 54b815dcf206c46e8f034230d89f733381a3de7e Mon Sep 17 00:00:00 2001 From: George Peppard Date: Wed, 5 Aug 2026 21:35:33 +0100 Subject: [PATCH 1/4] Add install script generator --- .gitignore | 1 + assets/install.bat | 7 ++++++ pyproject.toml | 4 ++++ scripts/generate_installer.py | 40 +++++++++++++++++++++++++++++++++++ 4 files changed, 52 insertions(+) create mode 100644 assets/install.bat create mode 100644 scripts/generate_installer.py diff --git a/.gitignore b/.gitignore index a4f8db0..abc0434 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ __pycache__/ build/ develop-eggs/ dist/ +dist-gh-release/ downloads/ eggs/ .eggs/ diff --git a/assets/install.bat b/assets/install.bat new file mode 100644 index 0000000..8a5e373 --- /dev/null +++ b/assets/install.bat @@ -0,0 +1,7 @@ +:: sbot_simulator install script +:: This script has been generated for sbot_simulator version __RELEASE__. + +wget https://github.com/sourcebots/sbot_simulator/releases/download/__RELEASE__/sbot-simulator-__RELEASE__.zip +unzip -d sbot-simulator-__RELEASE__/ sbot-simulator-__RELEASE__.zip +cd sbot-simulator-__RELEASE__/ +C:\Apps\Python315\python.exe scripts/setup.py diff --git a/pyproject.toml b/pyproject.toml index 956b6f9..8e86c70 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -101,6 +101,10 @@ cmd = "ruff check --fix-only $PYFOLDERS" help = "Build the release archive." cmd = "python ./scripts/generate_release.py" +[tool.poe.tasks.installer] +help = "Build the installer script" +cmd = "python ./scripts/generate_installer.py" + [tool.poe.tasks.setup] help = "Setup the virtual environment for running Webots." cmd = "python -m ./scripts/setup.py" diff --git a/scripts/generate_installer.py b/scripts/generate_installer.py new file mode 100644 index 0000000..a4c28e3 --- /dev/null +++ b/scripts/generate_installer.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 +""" +Generates an install.bat script for running on a target to install the simulator. +""" +import logging +import os +import subprocess +import sys +import re +from pathlib import Path + + +logging.basicConfig(level=logging.INFO) +logger = logging.getLogger(__name__) +project_root = Path(__file__).parents[1] + + +try: + version = subprocess.check_output( + ['git', 'describe', '--tags', '--always'], + cwd=str(project_root), + ).decode().strip() +except subprocess.CalledProcessError: + logger.exception("Failed to get version from git") + exit(1) + +(project_root / "dist-gh-release").mkdir(exist_ok=True) +os.chdir(str(project_root / "dist-gh-release")) + +logger.info("Loading template") +with open((project_root / "assets" / "install.bat"), "r") as f: + source = f.read() + +script = re.sub("__RELEASE__", version, source) + +logger.info("Writing script") +with open((project_root / "dist-gh-release" / "install.bat"), "w") as f: + f.write(script) + +logger.info("Success") \ No newline at end of file From 673a65071a998afce01b79ea752c856a9c750bdf Mon Sep 17 00:00:00 2001 From: George Peppard Date: Wed, 5 Aug 2026 21:39:25 +0100 Subject: [PATCH 2/4] Build install.bat and upload as artifact --- .github/workflows/check.yml | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 9e68079..e4a657a 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -81,10 +81,10 @@ jobs: - uses: actions/checkout@v6 with: fetch-depth: 0 - - name: Set up Python 3.10 + - name: Set up Python 3.13 uses: actions/setup-python@v6 with: - python-version: "3.10" + python-version: "3.13" - name: Install release dependencies run: | # pandoc is required for README.rst -> README.md conversion @@ -108,3 +108,28 @@ jobs: name: ${{ steps.release.outputs.RELEASE_NAME }} path: | dist/* + + installer: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + with: + fetch-depth: 0 + - name: Set up Python 3.13 + uses: actions/setup-python@v6 + with: + python-version: "3.13" + - name: Install release dependencies + run: | + sudo apt-get update + python -m pip install --upgrade pip + python -m pip install -r dev_requirements.txt + - name: Make installer + run: | + poe installer + - name: Save installer + uses: actions/upload-artifact@v6 + with: + name: "install.bat" + path: | + dist-gh-release/install.bat From 16b8ce53c831237e5bb5739a5d140870e3f66e1f Mon Sep 17 00:00:00 2001 From: George Peppard Date: Wed, 5 Aug 2026 21:40:43 +0100 Subject: [PATCH 3/4] lint: fix issues --- .github/workflows/check.yml | 2 +- scripts/generate_installer.py | 10 +++------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index e4a657a..a2fc3aa 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -128,7 +128,7 @@ jobs: run: | poe installer - name: Save installer - uses: actions/upload-artifact@v6 + uses: actions/upload-artifact@v6 with: name: "install.bat" path: | diff --git a/scripts/generate_installer.py b/scripts/generate_installer.py index a4c28e3..d49aedb 100644 --- a/scripts/generate_installer.py +++ b/scripts/generate_installer.py @@ -1,15 +1,11 @@ #!/usr/bin/env python3 -""" -Generates an install.bat script for running on a target to install the simulator. -""" +"""Generates an install.bat script for running on a target to install the simulator.""" import logging import os -import subprocess -import sys import re +import subprocess from pathlib import Path - logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) project_root = Path(__file__).parents[1] @@ -37,4 +33,4 @@ with open((project_root / "dist-gh-release" / "install.bat"), "w") as f: f.write(script) -logger.info("Success") \ No newline at end of file +logger.info("Success") From 5dfd3d35c47926daefba4688f6ce0db163ad7b37 Mon Sep 17 00:00:00 2001 From: George Peppard Date: Wed, 5 Aug 2026 22:07:30 +0100 Subject: [PATCH 4/4] ci: merge release and install tasks --- .github/workflows/check.yml | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index a2fc3aa..14d5fff 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -102,34 +102,16 @@ jobs: # Extract the release the release to avoid the double zip unzip dist/*.zip -d dist/ rm dist/sbot-simulator*.zip + - name: Make installer + run: poe installer - name: Save built release uses: actions/upload-artifact@v6 with: name: ${{ steps.release.outputs.RELEASE_NAME }} path: | dist/* - - installer: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v6 - with: - fetch-depth: 0 - - name: Set up Python 3.13 - uses: actions/setup-python@v6 - with: - python-version: "3.13" - - name: Install release dependencies - run: | - sudo apt-get update - python -m pip install --upgrade pip - python -m pip install -r dev_requirements.txt - - name: Make installer - run: | - poe installer - - name: Save installer + - name: Save built installer uses: actions/upload-artifact@v6 with: - name: "install.bat" - path: | - dist-gh-release/install.bat + name: install.bat + path: dist-gh-release/install.bat