Skip to content

Commit

Permalink
feat: add workflow instruction and clean version value
Browse files Browse the repository at this point in the history
  • Loading branch information
maugde committed Jun 18, 2024
1 parent 63f834a commit 48fedde
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,19 @@ jobs:

- name: Check typing with mypy
run: hatch run types:check

- name: Build Windows Installer
if: matrix.os == 'windows-latest'
run: hatch run pyinstaller:build AntaresWebInstaller.exe
working-directory: dist/

- name: Build Ubuntu Installer
if: matrix.os == 'ubuntu-20.04'
run: hatch run pyinstaller:build AntaresWebInstaller
working-directory: dist/

- name: Upload binaries
uses: action/upload-artifact@v4
with:
name: AntaresWebInstaller-${{ matrix.os }}
path: dist/AntaresWebInstaller.zip
12 changes: 10 additions & 2 deletions src/antares_web_installer/app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import dataclasses
import logging
import os
import re
import subprocess
import textwrap
import time
Expand Down Expand Up @@ -87,11 +88,12 @@ def install_files(self):
# update config file
config_path = self.target_dir.joinpath("config.yaml")
update_config(config_path, config_path, version)
logger.info(f"New application version : {version}.")

# copy binaries
self.copy_files()

version = self.check_version()
logger.info(f"New application version : {version}.")

else:
# copy all files from package
copytree(self.source_dir, self.target_dir, dirs_exist_ok=True)
Expand All @@ -104,6 +106,9 @@ def copy_files(self):
write or if self.target_dir already exists.
"""
for elt_path in self.source_dir.iterdir():
if elt_path.is_dir():
os.mkdir(self.target_dir.joinpath(elt_path.name))
logger.info(f"{elt_path.name} directory created.")
if elt_path.name not in EXCLUDED_FILES:
try:
if elt_path.is_file():
Expand Down Expand Up @@ -135,6 +140,9 @@ def check_version(self) -> str:
reason = textwrap.indent(e.stderr, " | ", predicate=lambda line: True)
raise InstallError(f"Can't check version:\n{reason}") from e

# ensure the version number is in the form 'x.x' or 'x.x.x'
version = re.match(r"^(\d(.\d)+)+", version).group()

logger.info("Version found.")
return version

Expand Down

0 comments on commit 48fedde

Please sign in to comment.